Hexnr. through serial COM port
I´d like to send hexnumbers through the serial interface of a PC to a µ processor.
It works with a terminal, when I hit a key, for example 'a', 0100001 is stored in the µp register.
This I`d like to accomplish with the following C++ routine:
while(i<rows &&fgets(buff, sizeof(buff), HexCode) != NULL
for ( j=0; j<=1; j++ )
( Im intending to grab the first two chars of a textfile, resembling the byte in Hex format, like:
The send routine through Com1 looks like this:
WriteFile(hCom, &x, sizeof (x ), &dwWritten, NULL);
The PC crashes upon compilation, though.
Im I doing the right thing to achiev what I want?
I`d appreciate any help.