Re: [Eu 3.1]How to send many files to Arduino via USB?
- Posted by DanM_anew Mar 30, 2014
- 2018 views
I don't know if this helps, but I designed a packet format for serial communication with the Propeller IC:
┌───────┐ │01(SOH)│ ├───────┤ │DataLen│ ├───────┤ │02(STX)│ ├───────┤ │MsgType│ ├───────┤ │MsgDat0│ │ : │ │ : │ │ : │ │MsgDatX│ ├───────┤ │03(ETX)│ ├───────┤ │CRC16b0│ ├───────┤ │CRC16b1│ ├───────┤ │04(EOT)│ └───────┘
By setting up logic to look for the byte values in the right places, you can receive variable size packets and extract the data out of them. I haven't had the need to implement the CRC check yet, so it's just a place-holder.
Thanks ryanj, that does help! I had a vague idea like that in mind, but your's is much cleaner! :) I'll definitely have to put DataLength in, that's already my first task, to do it properly in relation to data types and the correct reception & interpretation by the Uno sketch/program; and the file name a block is going to will be necessary too.
I see that SOH is Start Of Heading, STX is Start Of Text, and ETX is end of text. I presume EOT is just end of block? And do you use any special characters sent to define the different parts of the format, or is that just taken care of by the defined position in the block? The BlockLength should work for me, the only variation in block length will be the last block from a file, or a file that's shorter than the defined block size I'll send.
I'm not sure if the Uno has enough memory to support CRC, but I presume I could just use, at least for now, one of the suggestions Fernando made for checksum in their place.
Thanks again!
Dan