-->
Page 1 of 3

Sending bytes to serial port

PostPosted: Mon Apr 04, 2016 9:19 am
by Electroguard
I need to be able to send out a serial sequence of byte values (preferably as hex if possible).

Say I need to send a hex value of 0D for instance.

I don't know if there is a print format that allows sending in hex, so I just tried sending the decimal equivalent instead (serialprintln 13).

But it appears to the serial monitor as the ascii representation of the number, rather than the actual value 13, which should be seen as a carraige return.
I also tried assigning the required value to a numeric variable (let var1 = 13) and sending the variable, but it still sends the ascii representation instead of the numeric value.

So is it possible to send a byte value to the serial port?

Re: Sending bytes to serial port

PostPosted: Mon Apr 04, 2016 9:35 am
by cicciocb
Yes you can.
serialprint chr(13)

Re: Sending bytes to serial port

PostPosted: Mon Apr 04, 2016 9:55 am
by Electroguard
Thanks.
Although it's not ascii chars I'm trying to send, it's serial hex control sequences to a voice module, thereforce they will all need conversion if needs be - but at least I can do that if I must.

But is that the only way? cos I've seen that the "&" character is now available as a print option, and was wondering if perhaps there were other undocumented format options that might now be available?

Re: Sending bytes to serial port

PostPosted: Mon Apr 04, 2016 10:28 am
by cicciocb
I think you can do a function for that.
What is the hex string you need to send ?