Home
JAQForum Ver 20.06
Log In or Join  
Active Topics
Local Time 06:40 30 Apr 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 Send Hex String to (XBEE)

Author Message
2001cpx

Regular Member

Joined: 03/10/2013
Location: Canada
Posts: 59
Posted: 08:45am 13 Jan 2016
Copy link to clipboard 
Print this post

Hi!

i`ve tried to find answer by Searching all the forum whitout succes.

My Problem,same as 3 years ago,is i want to send (i Use MAXIMITE) Hex string to
xbee (Api Mode)but if i wrote a line with chr$(&h7e) etc
i have an error,like line too long.

i want to send this via serial to xbee

7E 00 10 17 01 00 00 00 00 00 00 FF FF FF FE 02 44 30 05 71

Does anyone have some tips about this?

i need to use API mode,i can`t use Ascii

Thanks in Advance!!



"Color Maximite,(Duinomite-Mega,Mini),CGmmStick,GCmicroboard2b,Micromite + explore 64,100,LCD backpack,Lcd Backpack V2,TFT Backpack,Micromite Extreme,Armmite L,F,H,CMM2"
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 3659
Posted: 08:59am 13 Jan 2016
Copy link to clipboard 
Print this post

chr$(&h7e) will work fine.

If using PRINT or the like you need either chr$(...)+chr$(...)+...
or use ; instead of each +

If you got line too long it had an error - post the line so we can figure out what.

JohnEdited by JohnS 2016-01-14
 
ajkw
Senior Member

Joined: 29/06/2011
Location: Australia
Posts: 290
Posted: 03:35pm 13 Jan 2016
Copy link to clipboard 
Print this post

Perhaps something like this

Dim out$(20) = "7E","00","10","17","01","00","00","00",....
Outpos = 0
Do
Print #1,val(out$(outpos)) ' send to the serial port 1 the value of the array element
Outpos = outpos + 1
Loop until outpos = 20

Sample code not checked or verified working. I am away from my mite to check the Print output structure is correct.

Edit perhaps it should be

Print#1,chr$(val("&H"+out$(outpos)))

There will be a better way but hopefully this helps.Edited by ajkw 2016-01-15
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 5905
Posted: 05:28pm 13 Jan 2016
Copy link to clipboard 
Print this post

using
PRINT #1, chr$(&h7e)+chr$(&h7e)+chr$(&h7e)+chr$(&h7e)+chr$(&h7e) ...
will make the line too long for MMBasic
You can print the line in two or more stages provided you end the line with ; to suppress the CR

PRINT #1, chr$(&h7e)+chr$(&h7e)+chr$(&h7e);
PRINT #1, chr$(&h7e)+chr$(&h7e)+chr$(&h7e);
PRINT #1, chr$(&h7e)+chr$(&h7e)+chr$(&h7e);

You might be able to divide the string up into meaningful sub-strings.
Strings can contain chr(0) so it is OK to do this:

header$=chr$(&h7e)+chr$(&h7e)+chr$(&h7e)
body$ = chr$(&h7e)+chr$(&h7e)+chr$(&h7e)
end$ = chr$(&h7e)+chr$(&h7e)+chr$(&h7e)

PRINT #, header$+body$+end$;

If you need the CR at the end, leave the ; off.

Jim
VK7JH
MMedit   MMBasic Help
 
2001cpx

Regular Member

Joined: 03/10/2013
Location: Canada
Posts: 59
Posted: 05:41am 14 Jan 2016
Copy link to clipboard 
Print this post

Thanks!,

i will try it



"Color Maximite,(Duinomite-Mega,Mini),CGmmStick,GCmicroboard2b,Micromite + explore 64,100,LCD backpack,Lcd Backpack V2,TFT Backpack,Micromite Extreme,Armmite L,F,H,CMM2"
 
Print this page


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

© JAQ Software 2024