![]() |
Forum Index : Microcontroller and PC projects : How to send control characters in hex
Author | Message | ||||
Canada_Cold Regular Member ![]() Joined: 11/01/2020 Location: CanadaPosts: 42 |
Hi, I’m programming a picomite to communicate to another processor via the com1 and send control characters in hex. I’ve tried Print #1, CHR$(0A), CHR$(0D) but that gives me an error msg. I did do a search on the manual, but did not find anything re sending hex characters. Any help would be great. |
||||
Plasmamac![]() Guru ![]() Joined: 31/01/2019 Location: GermanyPosts: 579 |
A = 10 so send chr$(10) and so on Plasma |
||||
thwill![]() Guru ![]() Joined: 16/09/2019 Location: United KingdomPosts: 4311 |
You need to use an &h prefix, it's in the manual somewhere: Print #1, CHR$(&h0A), CHR$(&h0D) Best wishes, Tom MMBasic for Linux, Game*Mite, CMM2 Welcome Tape, Creaky old text adventures |
||||
Mixtel90![]() Guru ![]() Joined: 05/10/2019 Location: United KingdomPosts: 7937 |
If you want to send actual hex codes then send CHR$(&H0A). Mick Zilog Inside! nascom.info for Nascom & Gemini Preliminary MMBasic docs & my PCB designs |
||||
ElectroPI Newbie ![]() Joined: 27/04/2012 Location: AustraliaPosts: 37 |
Just remember what happens with the PRINT command. If you print variables and put commas in between then the command inserts spaces between the numbers printed. I haven't tried it with control characters but I assume the same. So you should use semi-colons instead. So let's say you need to send ESC followed by the characters S1 followed by cr then lf, the command would be PRINT #1, CHR$(27);"S1";CHR$(13);CHR$(10); Of course the 27, 13 & 10 could be replaced with &H1B, &H0D and &H0A. Note the ; at the end of the line to suppress sending an extra cr/lf. |
||||
Canada_Cold Regular Member ![]() Joined: 11/01/2020 Location: CanadaPosts: 42 |
Thanks, that works great. |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |