two way serial communication
-
i need to make communication between computer to another machine. and this communication like two communication. first i need data from another machine(make sure it is not computer. i have to connect it with usb com port) and then also send acknowledge from computer to another machine. i did with it serial communciation.but it was text. i need to receive float data and also sending same data. also i need to identyfying where the next string started and when it will finished. help reply for this as early as
Arpita Patel
-
i need to make communication between computer to another machine. and this communication like two communication. first i need data from another machine(make sure it is not computer. i have to connect it with usb com port) and then also send acknowledge from computer to another machine. i did with it serial communciation.but it was text. i need to receive float data and also sending same data. also i need to identyfying where the next string started and when it will finished. help reply for this as early as
Arpita Patel
Hi, The problem of mixing floats and text needs some kind of protocol. One can come up with several schemes, it depends on the kind of [ero[heral device (speed, memory, language), and the relative amount of floats versus text. For your float data there basically are two ways to approach this: 1. use binary data, i.e. send bytes, not characters. 2. use strings to represent your float data; either apply ToString() when sending, and float.TryParse() when receiving (=more bytes, and some loss of precision); or get the bytes of a float, and turn them into a readable string, e.g. using base64 conversion (=4 ASCII char for 3 bytes of data) or hex (=2 ASCII char for 1 byte of data). :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
-
Hi, The problem of mixing floats and text needs some kind of protocol. One can come up with several schemes, it depends on the kind of [ero[heral device (speed, memory, language), and the relative amount of floats versus text. For your float data there basically are two ways to approach this: 1. use binary data, i.e. send bytes, not characters. 2. use strings to represent your float data; either apply ToString() when sending, and float.TryParse() when receiving (=more bytes, and some loss of precision); or get the bytes of a float, and turn them into a readable string, e.g. using base64 conversion (=4 ASCII char for 3 bytes of data) or hex (=2 ASCII char for 1 byte of data). :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.
Perhaps XML serialization?
-
Perhaps XML serialization?
as the other device is "not a computer" I doubt XML is the way to go. Chances are the device has limited capabilities (limited CoreMark, few KBs of RAM, hardly an OS, C only, ...) and will dictate the way to go. we'll have to wait and see. FWIW: Most of the time I avoided exchanging float data with small embedded systems; choosing an appropriate scale maps most physical stuff easily onto 16-bit integers. :)
Luc Pattyn [Forum Guidelines] [My Articles]
DISCLAIMER: this message may have been modified by others; it may no longer reflect what I intended, and may contain bad advice; use at your own risk and with extreme care.