Issue with Serial0.write(0)

Discussion in 'UDOO NEO' started by knick, Nov 4, 2016.

  1. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    I'm having issues with the Serial0.write() function when trying to write 0x00 to the serial port.

    Example - the following code produces NOTHING on the serial port.

    uint8_t val;
    while (1)
    {
    val = 0;
    Serial0.write(val);
    val = 1;
    Serial0.write(val);
    val = 2;
    Serial0.write(val);
    }

    But if you change val = 0 to val = 3 then it works as expected.

    I came across this issue while trying to use the ModbusMaster library. I'm missing bytes from the Modbus packets because any 0x00 bytes are getting dropped.

    Does anyone have a fix for this?
     
    iz0abd likes this.
  2. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,312
    Likes Received:
    580
  3. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    Thanks waltervl.

    Udoo team: Is there an estimated timeframe for when this will be fixed? I need a working serial port for the product I am working on. I have to decide whether I can wait for the fix, or try a different platform.
     
  4. knick

    knick New Member

    Joined:
    Nov 1, 2016
    Messages:
    29
    Likes Received:
    8
    Is this something I can potentially fix myself?

    On my windows development machine I have a folder AppData\Local\Arduino15\packages\UDOO\hardware\solox\1.6.7\variants\udooneo. Inside this folder are a bunch of source files - some of which look like they are related to the UART. If I spend time digging through this am I likely to find the source code that is getting called when I invoke Serial0.write() ?
     
  5. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,312
    Likes Received:
    580
    Yes you could try to fix it yourself in the sources in that folder. That would be highly appreciated!

    Be aware that there is also a MQX part in it that is proprietary software of NXP. So only compiled versions of that part.
     
    Andrea Rovai likes this.
  6. wertiti

    wertiti New Member

    Joined:
    Mar 28, 2017
    Messages:
    2
    Likes Received:
    0
    Knick,

    Did you succeed to fix it?
     
  7. iz0abd

    iz0abd New Member

    Joined:
    Jun 17, 2017
    Messages:
    2
    Likes Received:
    0
    This is exactly the same problem I have using Modbus RTU. Unfortunately I designed a board to host a Udoo NEO and now I discovered this incredible issue.
     
    Last edited: Jun 19, 2017
  8. preechaim

    preechaim New Member

    Joined:
    Oct 6, 2017
    Messages:
    5
    Likes Received:
    2
    I have the same problem.
    Any fix or update?
     
  9. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,312
    Likes Received:
    580
    Not that I know of.
     
  10. preechaim

    preechaim New Member

    Joined:
    Oct 6, 2017
    Messages:
    5
    Likes Received:
    2
    Got to workaround by putting Serial0.flush() after writing a byte.

    while (true){
    Serial0.write(0);
    Serial0.flush();
    }
     
    waltervl likes this.
  11. waltervl

    waltervl UDOOer

    Joined:
    Dec 12, 2015
    Messages:
    2,312
    Likes Received:
    580
    Nice work! At least a work around found. Do you have to flush after every write() ?
     
  12. preechaim

    preechaim New Member

    Joined:
    Oct 6, 2017
    Messages:
    5
    Likes Received:
    2
    No, you will need to flush just when sending a zero.
    I think the problem can be from somewhere in the serial buffer which assume that data is always a string.
     
  13. Gorgo

    Gorgo UDOOer

    Joined:
    Nov 9, 2016
    Messages:
    158
    Likes Received:
    17
    It would be better if you cast to byte too.
    Serial0.write((byte)0x00)
    even if it doesn't solve the problem but flushing does.
     

Share This Page