Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
I am working with a micromite with an LCD backpack. Can anyone suggest where I am going wrong here please. I am trying to send a stream of data to an external device. One of streams I want to send out is, with ascii character and hex value in brackets) : C (0x43) U (0x55) 0 (0x30) 7 (0x37) 23 (0x17)
Checking with my logic probe shows what is actually going out is: 6 (0x36) 7 (0x37) 8 (0x38) 5 (0x35) 4 (0x35) 8 (0x38) 5 (0x35) 5 (0x35) 2 (0x32) 3 (0x33) The receiver is not able to handle this as it expects the former stream of 5 bytes of data not the 10 bytes being sent. It is like each byte is being split into two. My code related to serial tx:
dim integer aByte(9)=(&H52,&H30,&H30,&H31,&H42,&H35,&H38,&H44,&H43,&H17) '7000rpm dim integer uartselect(4)=(&H43,&H55,&H30,&H37,&H17) dim integer increment open "com1: 115200, 512" as #5 for increment=0 to 4 print #5; str$(uartselect(increment)); next
Thank you for any suggestions. Peter
twofingers Guru Joined: 02/06/2014 Location: GermanyPosts: 1672
Posted: 04:03pm 01 Jun 2019
Copy link to clipboard
Print this post
Hi Peter
hmm, this code gives me
Dim integer uartselect(4)=(&H43,&H55,&H30,&H37,&H17) 'open "com1: 115200, 512" as #5 Print "Str$" For increment=0 To 4 Print Str$(uartselect(increment)),increment Next Print Print "Chr$" For increment=0 To 4 Print Chr$(uartselect(increment)),increment Next Print Print "Hex$" For increment=0 To 4 Print Hex$(uartselect(increment)),increment Next Print
End
this output:
Str$ 67 0 85 1 48 2 55 3 23 4
Chr$ C 0 U 1 0 2 7 3 4
Hex$ 43 0 55 1 30 2 37 3 17 4
edit: Maybe, if you want to send bytes (uartselect()) then you should replace
Print #5; Str$(uartselect(increment))
with
Print #5; Chr$(uartselect(increment))
That's exactly what you are sending with
Print #5; Str$(uartselect(increment)).
67, 85, 48, 55, 23.
MichaelEdited by twofingers 2019-06-03causality ≠ correlation ≠ coincidence
Thank you for that. Spot on! Changed to Chr$ and it worked immediately. A careful reread of the manual and I understand the different- Chr$ returns a ONE character string.