Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 20:53 28 Nov 2024 Privacy Policy
Jump to

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.

Forum Index : Microcontroller and PC projects : How to TX Raw Hex data in MM Basic?

Author Message
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 07:26pm 23 Jan 2014
Copy link to clipboard 
Print this post

RE: MM Basic, Duinomite with 4 com ports including 2 hardware ports.

Need to output raw hex bytes on serial com port, no CR and no LF.

Advice would be appreciated.

ThanksEdited by JohnL 2014-01-25
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6101
Posted: 08:22pm 23 Jan 2014
Copy link to clipboard 
Print this post

To send the data
PRINT chr$(x);

where x is the value from 0-255 and the semicolon suppresses the CR/LF

if you need the data to appear as hex

PRINT HEX$( x );



Jim
VK7JH
MMedit   MMBasic Help
 
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 08:35pm 23 Jan 2014
Copy link to clipboard 
Print this post

Perfect, works like a charm!

Thanks Jim
Cheers
 
MicroBlocks

Guru

Joined: 12/05/2012
Location: Thailand
Posts: 2209
Posted: 01:17am 24 Jan 2014
Copy link to clipboard 
Print this post

Or
[code]
Print right$("0" + hex$(x),2);
[/code]
when you want to have a leading zero. The values will then always be 2 characters long.
You will probably need a separator otherwise when a character is missed the receiver will interpret the values wrong.
Easiest is to use a space.
[code]
Print " " right$("0" + hex$(x),2);
[/code]

Microblocks. Build with logic.
 
JohnL
Senior Member

Joined: 10/01/2014
Location: Seychelles
Posts: 128
Posted: 02:23am 24 Jan 2014
Copy link to clipboard 
Print this post

Thanks TZ,

Will try that later.

At this stage I am using ASC(INPUT$(X, #Y) for receiving same single byte data by a MMbasic slave.

Any other suggestions?




 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024