FullDuplexSerial -- How do you read a string of bytes?
Charlie Johnson
Posts: 147
In FullDuplexSerial there is a public function 'str' for transmitting a string, but no function to receive a string.· I tried to put the 'rx' public function into a repeat loop, but that did not work.· I also tried to use the BS2 function library (SERIN_CHAR, and SERIN_STR) but had no luck there as well.· I am trying to read a string of 12 bytes. (Parallax RFID reader)· Any ideas?
Thanks
Charlie
Thanks
Charlie
Comments
I just worked with someone else off-board on dealing with the RFID reader. BS2_Functions should work, I retested. Be sure to include BS2.Start(31,30) or else the timing will won't be right (it calculates speed in that routine).
Also, they needed a WAIT feature, which I wrote up a new routine for.
Please test again, ensuring you are calling Start. If you need the WAIT also, I can post an update to the library.
Sincerely,
Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Southern Illinois University Carbondale - Electronic Systems Technologies
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
I did not call start when trying the BS2 functions, so when I get home I will try that.
Got the Tag to read...kind of.· All hex digits print as numbers (1 to 6) as shown below.
Actual Tag ID·- 04158FC21B
Displays as····- 0415863212· ... F = 6, C = 3 and B = 2
See attached code
Post Edited (dy8coke) : 6/8/2006 2:46:35 AM GMT
Charlie
I'm not sure what your problems are currently, I didn't see it spelled out.
By trying to manually collect 12 Byte, it may not be fast enough between calls to grab them.
Does the string end with a ASCII 13 (CR)? If so you should be able to use the BS2.SERIN_Str function to grab it all.
BS2.SERIN_Str(@RX_data, RFID_Pin, 2400, BS2#NInv, 8)
-Martin
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Martin Hebel
Southern Illinois University Carbondale - Electronic Systems Technologies
Personal Links with plenty of BASIC Stamp info
StampPlot - Graphical Data Acquisition and Control
The BS2.SERIN_STR function just loops through the BS2.SERIN_CHAR function until it gets a byte = 13, however when I use the BS2.SERIN_STR, all I get is the repeated value of 0, which is the result of clearing the DataIn buffer with 0 ... bytefill(@DataIn,0,49)
My posted code works, but just does not display the hex digits A - F. If the tag does not have any hex digits in it at all it displays perfectly, so I do not believe it is a timing issue. If after reading the tag and before displaying it on the LCD I jam some hex values into the buffer ie. Rx_Data[noparse][[/noparse]6] := $F and Rx_Data[noparse][[/noparse]7] := $C it then displays those hex values correctly on the LCD.
Thanks for all the help ... I bet it turns out to be some silly error on my part.
Charlie
I have had similar problems myself. I worked around it, but I do think there is something going on. I have been waiting for the DIP propellers to come in, so I haven't been Spinning lately, but I could go back and try to find the bug if needed. I was taking data from Hyperterminal at the time.
Jonathan
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
www.madlabs.info - Home of the Hydrogen Fuel Cell Robot
Your code now works.
I took your code and modified it.· When you see the code, you will see the statement that made it work.· You will probably want to change the output back to LCD.· I used Video.·· I also changed your pin numbers to fit my configuration.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··
Post Edited (Dave Scanlan) : 6/9/2006 7:33:17 AM GMT
I ran your code without change, and it also does not display any Hex (A-F) on the video display. I thought that maybe I have bad base object, so went to the Object libray and downloaded and installed those objects.... Same results. Are you seeing the hex digits (A-F) when you run your program? Or are do all of your tags just contain the numerals 0 - 9 ??
Charlie
This is an example of the video output for one of my RFID tags using the modified code:
0F0296AE72
104870485057546569555013
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··
Could you create an Archive, so it bundles up all the objects you are using? This is driving me nuts
Charlie
The RFID code is in the ZIP file attachment.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··
It still does the same thing.
Actual Tag ID : 04158FC192
Displayed Tag ID on LCD : 0415863192
Displayed Tag ID on Video : 04158192
Dec Display on Video : 10 48 52 49 53 56 198 195 49 57 50 13 (Spaces added for readability)
^ ^
As you can see, Bytes 7 & 8 count left to right starting with 1, are 198 and 195
These readings are consistant. I am using the demo board... Hummm I will try it on the PropStick when I get home.
Thank you everyone for helping.. I looks like the problem is on my end, as no one else seems to have this problem.
Charlie
Ok, this is driving me crazy. It appears that the program works as expected for everyone else except me. I ran Dave's version on the video display without any changes and the results are still no Hex digits A - F Displayed. I then hooked it up to my PropStick...Same results. I then paralled the output to a MAX232 and Hyperterm, Hyperterm display all the characters correctly, but still no Hex A - F on the LCD or Video.
Does anyone have any ideas on what to try next for troubleshooting this?
Charlie
I ran into something similar and it turned out that the leads of two of the resistors on my breadboard were touching. So whenever one of the pins was on, they were both on. Your problem is apparently not software, so could it be hardware?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
Double checked all connections, reloaded the Propeller tool afer uninstalling and cleaning up the registry, changed the pins - so they were not consecitive and tried different propeller chips. Still get the same result. This happens on 3 different PC's running 3 different OS's -- Win XP Pro, XP Home, Win 2000.
I tested the RFID reader on a BS2 - works great. Sent the output to Hyperterm -- Works as expected.
Tried ANDing the char with $7F to strip the 8th bit off, still not working on LCD.
I guess I will just move on to something else... and come back to this later.
Charlie
Post Edited (dy8coke) : 6/14/2006 6:21:07 PM GMT
Got the darn thing working. Tried ANDing the char with $7F in the code provided by Dave (uses the Video Display), and this worked. So I went back to the LCD code and changed the display output to use LCD.str as in the video equivilent.. and it now works. Still do not know why I need to strip off the 8th bit, but oh well IT WORKS!
Charlie
SEE:
http://forums.parallax.com/showthread.php?p=590815
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··
I know, but I still have to modify this line
Rx_Data[noparse][[/noparse]index++] := BS2.SERIN_CHAR(RX_Pin, 2400, BS2#NInv, 8)
to
Rx_Data[noparse][[/noparse]index++] := BS2.SERIN_CHAR(RX_Pin, 2400, BS2#NInv, 8) & $7F
Then all is well on my Props.
Charlie
This is really strange.·
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··
Yes, I know you are aware of this code, but I was hoping some others would try it to see if anyone pops up with the same problem you are having.
Dave
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
··