PDA

View Full Version : Help in sending hex string using serout



mbox
- 3rd May 2010, 12:46
Hello everybody,
I'm trying to send hex values with SEROUT, unfortunately I'm getting errors with the syntax and also tried to use

SerOut PortC.6,84, ["0x02 0x52 0x04 0x0b 00 0x61 0x0A 0x4D 0x6f 0x62 0x6f 0x74 0x20 0x49 0x49 0x49 00 0x03"]

hope someone here can help..

regards,
mbox

Ioannis
- 3rd May 2010, 13:01
The command that you posted, is not correct. Use modedefs.bas with the Serout and at mode the nams like T2400 or N9600 etc. Look at the manual for he correct syntax.

Now about the numbers, since they are inside "" they are treated as a long string message.

Ioannis

mbox
- 3rd May 2010, 15:06
Hello Ioannis,
Thanks for the reply....

The command that you posted, is not correct. Use modedefs.bas with the Serout and at mode the nams like T2400 or N9600 etc. Look at the manual for he correct syntax.

Now about the numbers, since they are inside "" they are treated as a long string message.

Ioannis
Here is the whole code
Include "modedefs.bas"
CLEAR
TRISC = %10000000'set TX (PORTC.6) to out, rest in
TRISB = %00000000
PortB = %00000000
pause 20
SerOut PortC.6,T9600, ["0x02 0x52 0x04 0x0b 00 0x61 0x0A 0x4D 0x6f 0x62 0x6f 0x74 0x20 0x49 0x49 0x49 00 0x03"]
pause 10
SerOut PortC.6,T9600,["0x02 0x52 0x66 00 00 0xb8 0x03"]
pause 10
Serout PortC.6,T9600, ["0x02 0x52 0x04 0x0b 00 0x61 0x0A 0x4D 0x6f 0x62 0x6f 0x74 0x20 0x49 0x49 0x49 00 0x03"]


Can you help me send the hex values in the proper format?

regards,
mbox

mackrackit
- 3rd May 2010, 16:21
Take a look at SEROUT2.
Then you can format it something like this
HEX 42, HEX 24, ...

Ioannis
- 3rd May 2010, 18:11
And note that with Serout2 that Dave showed you, a HEX modifier can have a digit also impying the number of digits to follow.

HEX2 means 2 hex digits etc.

Ioannis

mbox
- 4th May 2010, 09:47
Thanks everyone for the responce... I finally got it...:cool:
I use this in my code to send
SerOut2 PortC.6,84, [$02,$52,$27,$06,$00,$7F,$12,$13,$23,$17,$09,$00,$0 3]