jaxrpc
asked on
How to format manufacter given command?
Hi, i have written an app that writes a datastring to the comm port every second. When i used the monitoring ultility provided by the multi port board vendor...it appears..that the port has been successfully opened and data are transmitting. But my device don't seems to be acting upon receiving the data...... Anyway maybe i could have the datastring format screwed up.
Here's the datastring format given
<STX><POL><5 byte Ascii data><Space><PCS><CR><LF>
STX is chr(12),
POL which is either -ve or +ve...which is always chr(43) in my case
5 byte Ascii Data - i hardcoded it to be 55555
Space which is chr(32)
PCS which are 3 bytes chr(80), chr(67) and chr(83)
CR - return carriage chr(13)
LF - LineFeed chr(10)
In my code...i put it as
myValue = 55555
str_tx = chr(12) & chr(43) & myValue & chr(32) & chr(80) & chr(67) & chr(83) & _
chr(13) & chr(10)
I am not sure if it is the way present my datastring.... By the way....if i were to type to above string using hyperterminal...how do i present it? like? STX+55555 PCS
what about the CR and LF and space character when testing it with hyperterminal?
Here's the datastring format given
<STX><POL><5 byte Ascii data><Space><PCS><CR><LF>
STX is chr(12),
POL which is either -ve or +ve...which is always chr(43) in my case
5 byte Ascii Data - i hardcoded it to be 55555
Space which is chr(32)
PCS which are 3 bytes chr(80), chr(67) and chr(83)
CR - return carriage chr(13)
LF - LineFeed chr(10)
In my code...i put it as
myValue = 55555
str_tx = chr(12) & chr(43) & myValue & chr(32) & chr(80) & chr(67) & chr(83) & _
chr(13) & chr(10)
I am not sure if it is the way present my datastring.... By the way....if i were to type to above string using hyperterminal...how do i present it? like? STX+55555 PCS
what about the CR and LF and space character when testing it with hyperterminal?
Hi jaxrpc,
Another point to consider -- whenever you're dealing with character data as a binary value, represent it in hex instead of decimal. It's more universally done this way and adds a bit of readability to your code.
Good Luck!
Kent
Another point to consider -- whenever you're dealing with character data as a binary value, represent it in hex instead of decimal. It's more universally done this way and adds a bit of readability to your code.
Good Luck!
Kent
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
to be more specific
sprintf(str_tx,"%c%c%5d PCS\r\n",12,43,myValue);
sprintf(str_tx,"%c%c%5d PCS\r\n",12,43,myValue);
ASKER
haha sorry...i copied the vb.net code...
You should also verify that you've set the right baud rate, stop bits, and parity.