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: CanadaPosts: 59 |
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 KingdomPosts: 3772 |
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. John |
||||
ajkw Senior Member Joined: 29/06/2011 Location: AustraliaPosts: 290 |
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. |
||||
TassyJim Guru Joined: 07/08/2011 Location: AustraliaPosts: 6060 |
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: CanadaPosts: 59 |
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 |