?? - = - easy way to compare a byte array with a text string - = - ??
i have a 17 character string stored in a· byte array. i need a way to easily compare it to a list of character strings. to my knowledge, there is'nt an easy way to do this. i thought maybe serout it on one pin and then serin it back into an array and do a for next loop to match all the characters, but then i started wondering about timing and the fact it would take 2 i/o's to do. as you can see in the code below, it's not very accurate. i only check one character out of 12 to see who it is. I would like to make the unit self contained and not have to have a pc to check the id's.
anyone got any ideas?
i need to find out if bBuffer() is equal to a list of·id's formatted·like so, xx[noparse]:xx:[/noparse]xx[noparse]:xx:[/noparse]xx:xx, then if it is, make a pin go high for a moment.
anyone got any ideas?
i need to find out if bBuffer() is equal to a list of·id's formatted·like so, xx[noparse]:xx:[/noparse]xx[noparse]:xx:[/noparse]xx:xx, then if it is, make a pin go high for a moment.
GetVisible: 'get visable id's and send them to the serialport SEROUT 1,84,[noparse][[/noparse]"lst visible 10",CR] SEROUT serialport,baud,[noparse][[/noparse]"List Visible...",CR] SERIN 0,84,[noparse][[/noparse]WAIT("ACK",CR)] 'SEROUT serialport,baud,[noparse][[/noparse]"ACK",CR] GetList: 'Buffer eb500 response SERIN 0,84,[noparse][[/noparse]STR bBuffer\16\">"] SEROUT serialport,baud,[noparse][[/noparse]"Start data buffer...",CR] SEROUT SerialPort,Baud,[noparse][[/noparse]STR bBuffer] 'SERIN SerialPort,Baud,[noparse][[/noparse]ControlCode] 'Watch for controlcode from pc. OPEN 'SEROUT SerialPort,Baud,[noparse][[/noparse]STR ControlCode,CR] IF bBuffer(0) = "E" THEN ErrorCode 'Watch for Error codes IF bBuffer(0) = 0 THEN GetVisible 'Watch for end of list VIA blank buffer ' ***************************** ' FOR TESTING ONLY, NOT SECURE! ' ***************************** IF bBuffer(15) = "2" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - CLARK!",CR]: HIGH 7 IF bBuffer(15) = "A" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - BEN!",CR]: HIGH 7 IF bBuffer(15) = "3" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - CHRIS!",CR]: HIGH 7 IF bBuffer(15) = "C" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - OLD POCKET PC!",CR]: HIGH 7 IF bBuffer(15) = "8" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - SCOTT!",CR]: HIGH 7 IF bBuffer(15) = "F" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - BRYAN!",CR]: HIGH 7 IF bBuffer(15) = "C" THEN SEROUT serialport,baud,[noparse][[/noparse]"OPEN DOOR FOR - JOHNATHAN THE NEW GUY!",CR]: HIGH 7 ' ***************************** LOW 7 GOTO GetList
Comments
You cannot SEROUT one pin and SERIN another. The BASIC Stamp doesn’t have a UART/FIFO and so while the data was being sent it would not be picked up at the receiving pin. What you’re trying to do is actually quite easy and an example can be found in our RFID.BS2 sample code. Typically on a BS2 the tag is read into an array and compared with a list of known tags. You can find this code on the following web page. Take care.
http://www.parallax.com/detail.asp?product_id=28140
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
just one thing though. i'm not sure i follow how to store the code list into the eeprom. can you shed a little more light on that?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support