rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Ok. On Windows, a text newline ('\n') IS a carriage-return+linefeed ('\r\n') combination. You would only need to use the latter representation if you were reading the file from Unix/Linux systems. On Windows, it is still encoded as '\n'. IE, don't sweat it unless you are reading a file from one system type on another and have not passed the file through a filter to convert newlines accordingly, which normally a tool like ftp will do for you if the transfer is specified as text-type. There are also other tools which will convert newlines for you - this is a very common problem.

So, if you execute the function fprintf(outfile, "Hello World.\n"); on Windows, the file will contain a '\r\n' terminator on the line. On Linux/Unix, it would contain only a linefeed ('\n'). Reading back, the same code should work appropriately on either system, making programming applications that is intended to work on both types of systems much easier. Again, problems only occur when you are processing data written on one system type on the other.

And welcome to cross-platform programming and all the little warts you will encounter in that endeavor! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Can you boot into safe mode? What about by-passing the boot process and go into recovery mode? My guess is that you may have system damage other than just the disc. Often power failures are also accompanied with a power surge, damaging other components unless you have a newish, good surge suppressor, or a UPS that your system is attached to. For my system components (including laptops when tethered at home), I have them all connected to an industrial-class UPS that has serious surge suppression capabilities. As a result, I have never had such a problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Anything we can do you for? :-) And, welcome!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

string types keep track of the length of the data internally - adding the NUL byte is not required, and is actually appended to the internal buffer, incrementing the length. Don't worry about it, and don't try to do the string class' work for it... :-) As mentioned, if you want a properly NUL-terminated C-style string from a C++ string object, then use the c_str() method to get it. Internally, actually, the buffer IS NUL terminated (usually - not required), but the NUL is not part of the length count. As said, adding a NUL byte specifically to the string WILL increment the length AND it will add another NUL byte to the buffer, making it pretty useless for most stuff.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The easiest way is to convert each character to a hexadecimal representation of the original text, and write that to disc. The only downside to this is that the size doubles. IE, 10 characters of input data will result in 20 characters of output data. To read it back, you read 2 characters at a time, and then convert that to an integer value, cast to a char, and append that to a string. The actual coding for this I leave to you. Once you make an effort to code it, we will be happy to help with any problems you may have.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From your question, I assume you are using a Windows system? Do you know if the files are in MS, or in Unix/Linux format?

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Huh? I'm clueless here as to what you are getting at. Please be more specific and provide code example.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Show your current code please. And no, arrays are NOT a series of pointers. They ARE a pointer, to the first element of the array. IE:

int array[] = {0,1,2,3};
int *parray1 = array;
int *parray2 = &array[0];

/* parray1 should == parray2 */

In any case, the statement int array[1]; is declaring (and defining) that 'array' is an array of integers with ONLY one element, and IT CANNOT BE RESIZED! It is fixed in size. Setting an index > 0 on this array will result in "undefined behavior", which usually means a segfault...

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

An n-tier architecture is sometimes called a peer-to-peer architecture, where clients can be servers and vice-versa. A 2-tier architecture is a pure client-server situation. The client asks, and the server delivers. So, please tell us what you are trying to work out, other than the abstraction you mention. N-tier has nothing to do, specifically, with C# or any other programming language, although there are some that are designed to deal with such abstractions.

In any case, some Google searches for the terms you are interested in will probably help.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Re. Smeagel13:

1500+ lines in a few (2) days...
Either that includes a hell of lot of blank lines, copying and pasting, or there was no testing because that's just daft!

Well, after 30+ years of writing code that runs a lot of the biggest manufacturing enterprises in the world, a first cut of 1500 lines to solve a problem is, for me, about 2-3 days effort. One day of that was to design/model it in a top-end UML tool. FWIW, I wrote a complete TCP/IP stack for an embedded real-time operating system in the early 1990's, and that was 6 months from start to first formal system-level test. Every line of code is original. If you are interested, check out US Patent # 7185325. I am the sole inventor of it (although Applied Materials owns it): http://www.google.com/patents/US7185325

FWIW, the SAR project is now about 6000 lines of C++ code (started about 9 months ago), not including support scripts, rpm file specs, etc, and that is only a part of what I have been doing, such as mastering the Amazon cloud, Hadoop, developing algorithms (including all the math) for predictive analytics to determine when systems will fail using the data that the tool captures. We are collecting with this tool in real-time, data from a number of our world-wide data centers (about 1 billion data points per DC per day), and soon will be analyzing it, also in real-time. Do you know what a Kalman …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Also, what exactly are you trying to accomplish - describe the problem domain a bit more fully please.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Argh! I haven't written any prolog in probably 25 years. I'll have to do some review of my copy of Clocksin and Mellish (the bible of prolog) and get back to you on this. Are you in a hurry? :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Let's see. Over 30+ years, the computer languages I have used professionally to earn a living have included Fortran, Assembler (of various sorts), Basic, dBase (II, III, and IV), SQL, Quel, Cobol, Dibol, C, C++, Java, Lisp, SmallTalk, Prolog, Snobol, sh, csh, bash, ksh, Ada and PL/SQL (a derivative of Ada), Transact-SQL, Perl, Python,... And a bunch more I don't remember any longer. Will it disappoint you that I have never used Nimrod? :-) I have looked at, but never used APL (though a mathematician friend of mine is a big proponent of it).

In any case, it sounds like a good example of my favorite language, YAPL. YAPL - Yet Another Programming Language. :-) Check it out, and let us know what you think.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What kind of system are you talking to, and what terminal type are you using? If you are connected to a Unix/Linux system, then you can use the stty command to change the apparent terminal size so output will be wrapped to fit the screen. There are also telnet commands to help with that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

There is no guarantee that the ack gets back to the sender, as in the lost ack scenario. However, each packet has a sequence # and CRC, so the receiving network stack will keep track, especially if there are missing packets in between the ones it got. If it gets a duplicate, then it will discard the new copy, yet ack that as well so more don't get sent (hopefully). Naks are for packets that were received with a bad CRC. If the connection is really flaky, then it is possible that a duplicate will be received after the original one has been transmitted to the receiving application; however, the stack (driver) will STILL know that the current window has passed by the duplicate packet, and it will ack/discard it.

This is a problem at the network stack level - and not at the application level. I do network programming in high-volume, high-speed environments (multiple thousands of interacting systems world wide with 10 gigabit network connections internally, and multi-gigabit connections to the internet. This is NOT a problem! :-) It is a good school problem, however, which will impact hardware and firmware designers. My suggestion is that you develop a rigorous finite-state-machine representation of how to deal with this situation. I always find that it clarifies such edge cases very nicely.

FWIW, I have implemented a full TCP/IP stack for real-time embedded systems in the past (around 1990), so this is an issue I am intimately familiar with, and that …

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You need another break; statment at the end of each outer switch block, before the next case statement, as in (from lines 46-48):

            }
            break;
    case 2://Not Enough Heat
            cout<<"What type of Heating system do you have?\n"<<endl;

plus breaks for the others.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Yech! I used to have an AT&T 2Wire as well, and it is an absolute piece of junk. I had them replace it with a Motorola Netopia device - been working for over 4 years now without a hiccup! Anyway, if you go into the configuration web pages for the router, you should be able to change its configuration from router to bridge. Then, just hook your netgear to that, and let it do the routing. I did that with a Linksys router (switched to bridge mode) to good effect. Anyway, it is worth a try. Assuming you are running DSL and not U-verse, it may be easier to just get a DSL modem to hook to the netgear.

A final note. I think you will need to connect a port on the 2Wire to the WAN port on the netgear router for this to work. You may need a patch cable to do that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your problem is here: long int fib[user]; on line 8. You have sized the array at 1 (the value of the 'user' variable). The fact that it doesn't segfault on you more quickly is probably accidental. In any case, you are munging the stack. Instead, you should make the variable 'fib' a pointer, and then allocate it after you accept the user input, as in long int* fib = calloc(user, sizeof(long int));.

Using calloc() instead of malloc() allows you to skip setting the array elements to 0.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Whereas printf will sometimes handle upgrading variables to the appropriate type, scanf is not so nice. y is a 16bit value, but you are scanning for a 32bit value - it doesn't fit so you will lose bits. In printf, the 16bit variable can be promoted to a 32bit value without losing anything.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Your printArray() functions don't return anything, so there will be no operator << associated with them. Remove the outfile << in main() from lines 32 and 33.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Not easily. It is what I would do. IE:

 int num;
 int numdigits = 0;
 int digitarray[10]; // This is assuming that you will not get more than 10 digits.
 c.print ("Enter a postive number: ");
 num = c.readInt ();
 // Accumulate digits into array.
 while (num > 0)
 {
     digitarray[numdigits++] = (num % 10);
     num = num / 10;
 }
 // Print digits in proper order.
 for (int i = numdigits; i > 0; i--)
 {
     c.println(digitarray[i-1]);
 }

So, as you can see, the change in your code is not extensive.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A number of systems will default to the onboard NIC unless you disable it in the BIOS, otherwise your add-in card may not work. Plug the display into the on-board port and boot into the BIOS to see if that is the case.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I've used Xen, VMware, and VirtualBox. I have had the best results with VirtualBox. It may have changed, but it used to be that you could not install a native nVidia video driver on a system running Xen, so you could not get full use out of modern displays. That may have been fixed (it was 5 years ago when I last used it). That's why I changed to VirtualBox. I've been using it ever since on both Linux and Windows hosts, running a variety of operating systems including Linux, QNX, DOS, Windows, Solaris, and BSD Unix. Works great, and it is FOSS (Free and Open Source Software), so you can even get the source code for it.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

The cdata construct in xml is to encode non-printable text into hexadecimal ascii numbers. IE, the letter 'A' would be encoded as 41. So, the string 946890... would be a double-right quotation mark + h + 0x90 (hex 90 - no printable representation)... So, the answer for cdata is that it cannot be made into letters because it is encoded this way because it is BINARY data. Some of the codes may represent letters, and if you want to extract the printable characters, that is possible.

So, you need to read two characters at a time into a string, and then convert that to a hex value.

I don't know what the APID tag is for, but it seems to be a random identifier. Show the XML that contains this please.

The 39.025... number is a double-precision floating point value. There are functions in every programming language to read a string like this into a double variable.

FWIW, none of this is relevant to the xml version and encoding.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Try running it in a debugger so you can get a stack trace when it crashes. Then, you can look at where it crashed, and what your variables were set to. This sort of problem is often due to improperly initialized variables, or buffer overruns.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You really didn't do anything wrong, except that you need to reverse the numbers. So, place the extracted digits in an array or vector, and reverse the order on output.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

BTW, if you want to do this on ALL terminal types, don't inject the VT-specific codes into the printf statements. It is much preferable to use the ncurses library to perform cursor-addressable output to console or xterm windows.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What TnTinMN said. The VT102 terminal is the foundation of the ANSI terminal type that is what you get in a standard Linux console or the xterm terminal type you get with an X-Windows command-line window. To see what your terminal type is, try the command: echo $TERM

As for escape codes, those are well documented - I actually own a VT102 terminal manual from DEC from the 1980's - I had to write a terminal emulator to handle all terminal types (including ones that weren't VT types) around 1990 for a real-time operating system, which is why I have that resource. In any case, a Google search should come up with the information you need.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You need to create this file: /home/svenson/CSci591/OpenCV-2.4.4/release/modules/java/test/.build/lib
The configuration and make tools should have created it, but see what happens when you create it yourself, then try make again.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

For analog decoding, you need to apply Kalman filters to extract the actual data from the signal/noise. Usually, this is done with C or C++ code. Java would work as well; however, since this is highly performance sensitive, VB would not be recommended, and C# would be equivalent (IMO) to Java. Personally, I'd use C/C++ as appropriate to deal with this.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

It is saying that it can't find the class org.apache.derby.jdbc.EmbeddedDriver. I think you need to add the appropriate directory to your CLASSPATH variable. I see that you set DERBY_HOME to CLASSPATH, but I think that you are not going far enough.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A crore == 10M, right? lahk == 10K as I recall... :-)

An array of 200M elements (assuming array of pointers pointers) on a 64-bit machine will take 200Mx8 bytes (minimum) of memory, which is 1.6GB. Most systems won't allow you to allocate such sizes on the stack, so you may need to allocate it on the heap with calloc/malloc calls. On some systems, you can allow users to allocate huge stacks, but it really isn't a good idea.

So, can you provide some indication of what you are trying to accomplish? We may be able to provide more relevant advice in how to manage that much memory if we knew.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

As AHarrisGsy said - use your knowledge and tools to build something of interest to you. Another approach would be to go to the web site of any number of open source projects and try to solve some of the currently unresolved issues posted on the site. www.apache.org is a good place to go as a start, or explore the projects hosted on sourceforge.net.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

What Moschops said. This is why we do exception handling (try/catch/throw) in C++. That will allow you to detect this sort of error and terminate after output of a meaningful error message that will help you fix the problem.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

How do you think it should be done? This is a C programming question (class exercise I presume), no? Show us how you think it could be solved, and then we will try to help. Just don't ask us to do your work (school or otherwise) for you.

Hint: try casting the hex value to a float, and print the resulting value.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I think basically got it correct, with Momerath's comments applied. Actually, it may not error on line 12 if -1 is not a valid index, though it should; however, -1 IS a valid array index in theory. If this code was provided as part of the test, you might get extra credit if you point that out! :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please, if this is a class assignment/project, make an effort to solve the problem yourself. We will be happy to critique and help correct your work, but we aren't here to help you cheat, which is what you are asking in effect... :-(

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Deceptikon is correct. One method to do this is to have a correlary to the in-memory tree for the on-disc version. For your case, it might look like this:

struct disc_bst
{
    size_t offsetofleft;
    size_t offsetofright;
    size_t sizeofvalue;
    unsigned char[] valuedata;
    /* Some compilers will require the above array to be declared as unsigned char[0]. */
};

In your code, when you map from the in-memory tree to disc, you will convert each node, as you write it, to one of the disc_bst structures, allocating the structure dynamically to hold the entire contents of the value element, setting the sizeofvalue to the actual size of value, computing the size of the left and right elements (including the size of their value data) so you can set their offsets in disc_bst, which is where they will be found relative to the top of the data file. Then you go to left and right and do all of this all over again... All this time, you need to keep track of the current size of the file. :-)

As you can tell, this is not simple. Of course, you could use a memory-mapped file for your tree so you don't need to go through all of this stuff, but that has a lot of other challenges to get it "right"... (more smileys here).

Welcome to software engineering 101!

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Decepticon is mostly correct in that pointers are almost always the same size. Actually, I don't know of any modern systems where they aren't, otherwise virtual memory would be very difficult to deal with; however, the size of the data they point to can vary quite a bit, such as this:

typedef struct foo {
    int intpart;
    double dblpart;
    char carraypart[128];
} foo_t;
size_t intptrsize = sizeof(int*);
size_t fooptrsize = sizeof (foo_t*);
size_t intsize = sizeof(int);
size_t foosize = sizeof(foo_t);

intptrsize should equal fooptrsize, but intsize won't equal foosize. So, to get the size of the array (4 int pointers) would be sizeof(arr), which should equal to 4x the size of an int pointer. That is NOT the size of the data contained in the array, which depends upon what is allocated and assigned to each element. Since this is an array of double pointers, each element COULD be an array of doubles. Maybe this will make it clearer:

double* arr[4] = {0,0,0,0}; /* Four null pointers to doubles - 4*sizeof(double*) */
foot_t* farr[4] = {0,0,0,0}; /* Four null pointers to foot_t - 4*sizeof(foo_t*) */
arr[0] = (double*)calloc(100, sizeof(double));
farr[0] = (foo_t*)calloc(100, sizeof(foo_t));
/* The sizeof(arr) and sizeof(farr) should be the same in ALL modern systems.
   arr[0] now contains an array of 100 doubles, but sizeof(arr) is still the same.
   farr[0] now contains an array of 100 foo_t's, but sizeof(farr) is still the same.
   Also, sizeof(arr[0]) == sizeof(double*), not 100*sizeof(double), etc.
   Total size of arr is sizeof(arr) …
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Another useful man option is -k which will return all the matching pages, along with their sections. Example: man -k open

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

AFAIK, FAT file systems are all encoded in the format used by Intel x86 processors - LittleEndian. Use this to test:

#include <endian.h>
#if __BYTE_ORDER == __LITTLE_ENDIAN
/* We have a LittleEndian machine - Intel most likely, but possibly an ARM or MIPS in LE configuration. */
#elif __BYTE_ORDER == __BIG_ENDIAN
/* We have a BigEndian machine - an old 68000 system perhaps? */
#else
/* We have something else - probably an old PDP-11 */
#endif

This construct is commonly used in system-level programming.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

If you have two microphones (built-in and external such as bluetooth, usb headset, or physical mic plugged into headphone/mic port), then the built-in may not be enabled. As suggested by AHarrisGsy, go to the device manager, right click on the microphone icon, and see if it is enabled. If not, change that.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

hey how long did it take to builit TCP/IP proto set from the scratch to those guys from ARPANET in history? inventing and doing

Quite a bit longer I think. After all, Cerf et al at BBN were inventing something that had never been done like that before! My hat is definitely off to those folks! The fact that we could implement such complex stuff from just the specs says a lot to the deep thinking that went into TCP/IP, and why it is still prevelant today, running the Internet/WWW from end-to-end! OSI came along, trying to structure network stacks even more clearly, but the fact is that OSI is more a footnote today, other than conceptually, and TCP/IP still rules the roost! So, today you need to know about OSI for school exams, but you need to KNOW TCP/IP to program networks in real life.

And FWIW? Today, Vint Cerf is VP of Engineering at Google... :-)

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Having programs on your system won't slow it down unless they are part of some autostarted services. Look at the services running on the system, and either disable, or specify manual startup, for the ones you don't need. I find that this has the best impact on overall system performance. Also, look for applications that are using too much memory, causing the system to hit the swap space.

Finally, check for running viruses, trojans, and botnets running.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You can do what JorgeM suggests, or you can separate the clients from the router, physically, and turn your server into a router. That way, they can ONLY get their IP addresses from the server. It will require more work on your part, and all the client traffic will get routed through your server's two NICs, but it WILL key the clients from accessing the router directly.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

Please provide the full C code, but to start.

  1. Line 1 - push x and y onto stack
  2. Line 3 - move x into the esi register
  3. Line 4 - move y into the ebx register
  4. Lines 5 and 6 are the initialization of the result and mask variables. %edx is mask and %edi is result.
  5. Line 7 is the loop invariant.

You should be able to figure out the rest - please don't ask us to solve your homework problems for you.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

A GUI has little to do with an operating system. There are currently about two core operating system types:

  • Monolithic kernel
  • Micro kernel

as well as

  • Determinist real time
  • Non-deterministic not real time
  • Non-deterministic soft real time

There may be some that are, at least on the surface, a combination of those first two. Linux is an example of a monolithic kernel. QNX, now the operating system used by Blackberry (RIM) on their new BB-10 devices, is a micro kernel design. MS Windows is a bit of both.

If you want a system that can be used for applications such as fly-by-wire avionics, nuclear power plant controls, high-speed industrial control systems, then you need a deterministic real time operating system. If you are running a workstation, web server, etc, then a non-deterministic not real time system will work just fine. If you need something that can run many industrial systems such as warehouse conveyor systems, then a non-deterministic soft real time system may be the thing. Again, QNX is an example of the first type, Windows an example of the second, and Linux (with RT scheduling enabled) is an example of the third.

There are also variations of how user-space (applications) communicates with the kernel and drivers. For that there is the system call method, ioctl calls (both of which are used by Linux), and then there is the message passing method (used by QNX and some other operating systems). There has been a great deal of debate …

mike_2000_17 commented: Great summary! +13
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

From what you say, if you are receiving duplicate packets, I can only assume that you are utilizing the UDP or other packet-based protocol, as opposed to a stream-oriented one such as TCP. The TCP protocol will discard duplicates - you should never see them. UDP will not discard them, and it is up to you to detect and discard them.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

I'll send you a list of tools tomorrow that can be used to build/run nokia phone apps. What models do you want to program for? If for their Windows phones, you will need to go to the MS Phone developers site, sign up, and get the tools you need. For Nokia series 40 and symbian phones, you will need to go to their site. You can run/test Nokia phone apps in an emulator that can run on Linux or Windows systems, but in either case, you will need to register as an app developer before you can load them onto a real phone, and you will need an unlocked device to do that in all likelyhood.

rubberman 1,355 Nearly a Posting Virtuoso Featured Poster

You may need to edit your BIOS/UEFI settings to disable the onboard chip and enable the external adapter, or to tell it to use both. My guess is that it is set to only use the onboard chip so it is objecting to the "unknown" hardware. Since it won't boot with the nVidia card inserted into the system, I think you will need to boot into the BIOS and disable the on-board chip first. Then, if it boots, you may be able to set it to use both video adapters.

One other thing is power. The GTX650 is pretty power-hungry, so it is possible that there is not enough juice to run everything with the nVidia onboard.