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 / C++ / MFC
  4. Help With Serial

Help With Serial

Scheduled Pinned Locked Moved C / C++ / MFC
helphardwareperformancequestion
4 Posts 2 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.
  • S Offline
    S Offline
    simoncoul
    wrote on last edited by
    #1

    Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon

    S J 2 Replies Last reply
    0
    • S simoncoul

      Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon

      S Offline
      S Offline
      simoncoul
      wrote on last edited by
      #2

      I'm also using a baudrate of 115200, thought that might help a bit cause I have heard and read people have problems with higher baudrates.

      1 Reply Last reply
      0
      • S simoncoul

        Hello, I'm trying to stream data from a microcontroller and I think I have found problem. The data does not stream consistently so it will sometimes send a bunch of packets(5 byte packet) at once and then sometimes send them individual. When the speed at which they come in changes the data seems to become corrupted as only a couple of packets are wrong and then the data continues streaming properly again. I have no idea of what is going wrong here. I'm using the CSerial library and using the CSerialMFC for the notifications, and just a simply read on event received. Any idea of what could be going wrong here would be great. Thanks Simon

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        Well yes and no. Serial anything, especially low level serial port, can be problematic, but data corruption is highly unusual. I can only tell you what I would do. I would write a small test program (or use the current program - easier) that creates/opens a file during start up and then add code that writes to it every time you receive any data at the lowest level. If there is corruption at that level then you have a major problem, which only the current programmer (you) can solve, usually by writing your own version of that unknown piece of code. If there is no corruption at that level (normal), then you need to start working you way up, adding new code to write to the file, until you see corruption. At that point you can limit the file writing code to what shows good data and bad data. Keep adding file writing code until you have the offending code in sight and then add file writing code to each line of the offending function (if you do not see the problem). I suspect that you know all that already, but it is the best I can do without the code. P.S. Remember to delete the temporary file after you have found the problem and post the results (to the author of CSerial or what ever).

        INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

        S 1 Reply Last reply
        0
        • J John R Shaw

          Well yes and no. Serial anything, especially low level serial port, can be problematic, but data corruption is highly unusual. I can only tell you what I would do. I would write a small test program (or use the current program - easier) that creates/opens a file during start up and then add code that writes to it every time you receive any data at the lowest level. If there is corruption at that level then you have a major problem, which only the current programmer (you) can solve, usually by writing your own version of that unknown piece of code. If there is no corruption at that level (normal), then you need to start working you way up, adding new code to write to the file, until you see corruption. At that point you can limit the file writing code to what shows good data and bad data. Keep adding file writing code until you have the offending code in sight and then add file writing code to each line of the offending function (if you do not see the problem). I suspect that you know all that already, but it is the best I can do without the code. P.S. Remember to delete the temporary file after you have found the problem and post the results (to the author of CSerial or what ever).

          INTP "Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

          S Offline
          S Offline
          simoncoul
          wrote on last edited by
          #4

          do{
          SerialLib.Read(recvbuf, 5, &BytesRead);
          if(BytesRead == 0)
          return 0;
          for(i=0; i 0);

          This is the code that I'm using to read the data, and the problem is being caused in here as we have another program written in TCL that recieves that date from the controller just fine so we know it's not a hardware issue. Any help would be great thanks.

          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