Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. two way serial communication

two way serial communication

Scheduled Pinned Locked Moved C#
comhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Arpita Patel
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • A 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

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      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.


      P 1 Reply Last reply
      0
      • L Luc Pattyn

        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.


        P Offline
        P Offline
        PIEBALDconsult
        wrote on last edited by
        #3

        Perhaps XML serialization?

        L 1 Reply Last reply
        0
        • P PIEBALDconsult

          Perhaps XML serialization?

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          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.


          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups