Bluesmirf reading hex value with propeller
This does involve a wireless topic but it's more of a propeller issue. When sending an ASCII command to a bluesmirf ('L'), the bluesmirf returns as an example:
RSSI=ff,fa
(the bluesmirf returns the whole line, RSSI= and all, above every time)
where both are hexadecimal values and the ff would be the current RSSI value and fa would be the lowest RSSI value that has been encountered.
Is there a way for me to just grab the bold ff portion?
Thanks
RSSI=ff,fa
(the bluesmirf returns the whole line, RSSI= and all, above every time)
where both are hexadecimal values and the ff would be the current RSSI value and fa would be the lowest RSSI value that has been encountered.
Is there a way for me to just grab the bold ff portion?
Thanks

Comments
Pub main | i repeat until io.rx == "R" repeat i from 0 to 2 io.rx if io.rx == "=" A := io.rxThen A will equal the spot where ff is above.RSSI=**,##
where ** is the changing hex value and the value I desire to capture.
I have used the propeller board for a while but haven't had to be to in depth with the coding, can you please elaborate on how your code works line by line?
Thank you!!
Edit: if you want to display the numeric value of A then use the .DEC(), .BIN(), .HEX() methods of your display device.
OBJ io : "FullDuplexSerial.spin" Pub getRSSI : A | i repeat until io.rx == "R" repeat i from 0 to 2 io.rx if io.rx == "=" A := io.rxI assume you have to assign io.rx to a pin, but when I look into FULLSERIALDUPLEX, the rx function isn't setup to have an assigned pin.
Con _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 Var long a Obj io : "fullduplexserial" Pub main io.start(rxpin, txpin, mode, baudrate)See the .start method of the fullduplexserial object for the meanings.
Edit: Also the clock needs to be set up.
I am green at coding this on the prop (this is toddlers play in perl), but if it is a constant length string (is this something that one of the serial IO objects could handle?), I would input it into an array and read back the contents of the two bytes prior the null terminator to get the ascii representation of the hex value. Realize that if you want the actual binary value represented by the two bytes, you will have to add a routine to convert ascii to binary/hex for a true 8 bit single byte value. Bytes are as easy as any other length in spin, a bit more difficult in PASM as it works on 32 bit words.
Yeah, I noted after I hit send that you referenced the fullduplex serial object. I have used that extensively in debugging my ADC capture object. It appears to be able to send a string, but most of the examples and the object look like the receive is limited to bytes as the examples usually build in a string handler for using it as an input.
Frank
@ratronic.
(Not to lazy to try it and code it, just wanted to throw the possibility out there. Finishing wiring up an SOIC op-amp into a .5 wide home-made dip header. My next A/D will be using the TI ADS7229. I expect it will tax the Prop chips speed if I can push it near its rated 1MSPS speed w/ 12 bit serial output. MCP3201 capture object @100ksps already posted.)
OBJ io : "FullDuplexSerial.spin" pst : "Parallax Serial terminal" Pub getRSSI | i, A pst.StartRxTx(0,1,0,9600) pst.str(string("$$$")) repeat 1000000 pst.NewLine pst.Char("C") pst.NewLine repeat 1000000 pst.str(string("$$$")) repeat 1000000 pst.NewLine pst.Char("L") pst.NewLineThough this isn't working
CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 OBJ io : "FullDuplexSerial.spin" pst : "Parallax Serial terminal" Pub getRSSI | i, A pst.StartRxTx(0,1,0,9600) pst.str(string("$$$")) repeat 1000000 pst.NewLine pst.Char("C") pst.NewLine repeat 1000000 pst.str(string("$$$")) repeat 1000000 pst.NewLine pst.Char("L") pst.NewLine repeat repeat until io.rx == "R" repeat i from 0 to 2 io.rx if io.rx == "=" A := io.rx pst.clear pst.str(string("The Signal Strength is: ")) pst.Hex(A,2) waitcnt(clkfreq/10 + cnt)[B]while[/B][B]([/B]Serial[B].[/B][COLOR=#008080]available[/COLOR][B]()[/B] [B]<[/B] [COLOR=#009999]3[/COLOR][B]);[/B] str[B][[/B][COLOR=#009999]0[/COLOR][B]][/B] [B]=[/B] [B]([/B][COLOR=#445588][B]char[/B][/COLOR][B])[/B]Serial[B].[/B][COLOR=#008080]read[/COLOR][B]();[/B] str[B][[/B][COLOR=#009999]1[/COLOR][B]][/B] [B]=[/B] [B]([/B][COLOR=#445588][B]char[/B][/COLOR][B])[/B]Serial[B].[/B][COLOR=#008080]read[/COLOR][B]();[/B] str[B][[/B][COLOR=#009999]2[/COLOR][B]][/B] [B]=[/B] [B]([/B][COLOR=#445588][B]char[/B][/COLOR][B])[/B]Serial[B].[/B][COLOR=#008080]read[/COLOR][B]();[/B] [B]if[/B][B]([/B]str[B][[/B][COLOR=#009999]0[/COLOR][B]][/B] [B]==[/B] [COLOR=#DD1144]'A'[/COLOR] [B]&&[/B] str[B][[/B][COLOR=#009999]1[/COLOR][B]][/B] [B]==[/B] [COLOR=#DD1144]'O'[/COLOR] [B]&&[/B] str[B][[/B][COLOR=#009999]2[/COLOR][B]][/B] [B]==[/B] [COLOR=#DD1144]'K'[/COLOR][B])source: [/B]https://github.com/produceconsumerobot/MindSetArduino/blob/master/CleanProgramBlueSMiRF/CleanProgramBlueSMiRF.pde
P.S. I haven't been to sleep yet
CON _CLKMODE = XTAL1 + PLL16X _XINFREQ = 5_000_000 OBJ io : "FullDuplexSerial.spin" pst : "Parallax Serial terminal" Pub getRSSI | i, A pst.StartRxTx(31,30,0,9600) 'this starts the serial terminal for debug display waitcnt(clkfreq*3 + cnt) 'delay 3 seconds so you can open the parallax serial terminal io.start(0, 1, 0, 9600) 'this starts the serial port for your bluesmirf io.str(string("$$$")) 'this sends string repeat 1000000 'use waitcnt for delay io.tx(13) 'transmit CHR/LF io.tx("C") 'transmit "C" io.tx(13) 'transmit CHR/LF repeat 1000000 'use waitcnt for delay io.str(string("$$$")) 'send string repeat 1000000 'use waitcnt for delay io.tx(13) 'transmit CHR/LF io.tx("L") 'transmit "L" io.tx(13) 'transmit CHR/LF repeat 'repeat continued repeat until io.rx == "R" 'wait here until "R" received repeat i from 0 to 2 'receive 3 more characters "SSI" io.rx ' if io.rx == "=" 'if the fifth character is "=" A := io.rx ' then assign A to sixth character pst.tx(1) 'home the display cursor pst.str(string("The Signal Strength is: ")) 'print string to display pst.Hex(A,2) 'print value of A in 2 digit hex# waitcnt(clkfreq/10 + cnt) 'delay 1/10 of a secondEdit get some sleep!
Can you check what the byte after the first $66 is?
io.tx("L") 'transmit "L" io.tx(13) 'transmit CHR/LF repeat 'repeat continued pst.hex(io.rx, 2) pst.char(32)EDIT: I suppose changing those to a usable integer range($66 = 100 ---> $?? = 0)?
PUB null | value value := convert("4")*16 + convert("A") dira[16..23]~~ outa[16..23] := value waitpne(0, 0, 0) PRI convert(char) case char "0".."9": return char - "0" "a".."f", "A".."F": return (char | $20) - "a" + 10 other: abort DATEDIT: its a space, but why still?
if char = "b"
what would be returned?
Also, is there a good place I can go to learn about this stuff after we figure out this problem?
Using capital "C" ($43) as an example. $43 | $20 = $63, $63 - $61 + 10 = 12. Twelve decimal is "c" hex.