serial question
Hi-
I want to send an array of longs from a host computer to the propellar without knowing how long the array is(the array size will almoste always overflow the serial buffer). How can I store the data in an array on the propellar while data is still coming in from the host computer without missing any data? what would be a good way to confrim that all the data was recieved? anyone have any example code of somthing like this?
Thanks,
Owen
I want to send an array of longs from a host computer to the propellar without knowing how long the array is(the array size will almoste always overflow the serial buffer). How can I store the data in an array on the propellar while data is still coming in from the host computer without missing any data? what would be a good way to confrim that all the data was recieved? anyone have any example code of somthing like this?
Thanks,
Owen
Comments
The Propeller is fast enough to receive information from the host computer probably up to 230KBaud, but certainly 115KBaud and can store it as fast as it arrives using one cog for the serial I/O driver and one for the main program.
The best way to verify the received data is to include some kind of checksum or cyclic redundancy check (CRC) along with the data. Do a websearch on "wiki crc". You'll get en.wikipedia.org/wiki/Cyclic_redundancy_check which should lead you to more information than you probably want.
1) Declare the array to be the size of the largest possible array and use only as much of it as you need
2) Since the Propeller loads programs and creates stack space from the "bottom" of memory upwards, you can do your own allocating of memory from the end of memory ($7FFF) downwards. The first long would be put at location $7FF4 and the next at $7FF0 and so on. You'd initialize a variable to $7FF4 and decrement it by 4 each time something is stored (by: long[noparse][[/noparse] location ] := value). The only problem is that this will eventually run into the space being used for the stack. There are ways to detect this, but it's much better to account for a maximum amount of data.
You've got the right general idea. It's your task to try your hand at writing the program. I don't think you'll find a ready made example. If it helps, write a first version in a descriptive sort of language somewhat like what you did in the previous post, but a bit more detailed, then flesh out each statement in turn and see what you get.
How were you going to do the host computer side? Start with that language if you're comfortable with it, then slowly translate in stages into Spin.
Download a copy of BoeBotBasic from the Propeller Object Exchange and look at the BB_FullDuplexSerial.spin object. It's a slightly modified version of the FullDuplexSerial driver. In particular, look at "rxpeek". This would do what you want and you can cut and paste it from BB_FullDuplexSerial.spin to the copy of FullDuplexSerial.spin that you're using for your program.
for room to be available before putting another character into the buffer (take a look at it).
What seems to be happening?
http://forums.parallax.com/showthread.php?p=644816
What I ended up doing was using a "buffersize" constant at the beginning of my fullduplexserial, would that help any? I wish I could make it variable on the fly, but no luck there yet.