Serial Data Transfer Protocol problem
Posted 13 April 2012 - 08:00 PM
So the console works wonderful and I can load dll's onto the SD card and send messages to the controller to load the dlls depending on what library I have made for each component I want to work with. Each controller library communicates in sync with a dynamic Windows user control to exchange events and values through the protocol and as a developer I no longer have to worry about the communication part and now can just create controls and snap them in on the fly depending on what I want the Netduino to control. So in theory I can control the Netduino from a windows app any way I want or control the windows app from the Netduino any way I want without knowing anything about the message layer.
Here is the problem. I got a bit cocky in that I got tired of compiling a Micro Framework dll and pulling the sd card loading the dll and resetting the netduino. So I decided to add streaming into the serial protocol that will send the dll file through serial and auto save to sd card and then load.
The main problem is since this is a protocol that has many message types once entering into a stream mode, since any byte in the file can represent 0 to 255 I no longer have a message terminator to let me know when I have sent the last byte of the file.
How to I tell my data received event I am done sending any byte 0 - 255? What kind of message End of Transmission can I use if binary data uses all of them?
I tried looking at the way the FTP protocol works to see if that would help but FTP sends a binary stream on a separate port from the one it actually exchanges messages. I do not want to use two different com ports with FTDI connections. There has got to be a better way.
Posted 13 April 2012 - 09:30 PM
LL LL CC CC CC CC TT PL PL PP PP PP PP PP......
LL LL=total packet length(2 bytes)
CC CC CC CC=checksum over TT PL PL PP PP PP..(4 bytes)
TT=packet type(1 byte)
PL PL=payload length(2 bytes)
PP PP PP ...=payload(length equal to the value of PL PL)
This is the protocol implemented by a game I used to play and its pretty simple to implement.
Pardon me if I misunderstood your first question:D
Posted 13 April 2012 - 09:39 PM
But hey I got it working with Base 64. This console app is a time saver when I want to give netduino a full dynamic interface.
Posted 14 April 2012 - 04:58 AM
The Modbus protocol has been designed exactly for purposes like those.
Set this, read that...it's ridicolously simple, yet well standardized.
Have a look here:
Moreover, using such as protocol, there's literally plenty of 3rd party devices of *ANY* kind which can be connected with *no* effort.
Here is a "dummy-like" explanation of the Modbus:
Limitation of the Modbus itself:
- any message has to be no longer than 256 bytes;
- there's no any (standard) packetization for long-streams;
- no encryption;
- many more...
Hope it helps
Posted 14 April 2012 - 05:28 PM
Thanks for the links. I had a chance to glance at the Object diagrams for Modbus. Funny but I've never heard of it before. Though in many cases the command bus is very similar to mine, Just as the Netduino Go can hide much of the low level work done in making things happen with plugin components, my protocol is wrapped by a command/response interface that hides the low level byte communication. Write a windows control inherited by a base control that implements the console interface, write a plugin class that implements the Netduino controller interface and the engine does all the work for you. So, its not necessarily reinventing the wheel.
You be the judge once I finish it. I will post it under the projects forum when I'm done.
Posted 14 April 2012 - 05:35 PM
Posted 29 September 2012 - 05:00 AM
"universal serial protocol" - that must be what they use on Star Trek to set up comms with alien races the Enterprise computers have never encountered before.
I always wondered how they did that. Commander Bendage to the bridge!
Hey Paul. Just wanted to let you know it's done. Take a look and tell me what you think.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users