UART Parity Check not working

  • Hi,


    we need to use the parit check in our software but we are having trouble to get the information form the termios. We have no parity issues when we are sending data from our software to another PC, where we have an hyper terminal running. We also enabled in our code the PARMRK option but we don't reseive the \377 \000 before the transmitted byte comes. When we are sending a 0xFF to our software we get 2 Bytes from the read function. We inititlize our uart in the following way:



    We are pooling the read function in an extra thread. Our read looks like this:



    We already did a lot of testing by sending wrong or correct data but we never see the marked parity. My question now is, what are we doing wrong? Did we miss a setup or something?


    Kind regards,

    Gregor Liebscher

  • GrLi

    Changed the title of the thread from “UART Parity Check not wroking” to “UART Parity Check not working”.
  • Hello Mr. Liebscher,


    The relevant constants for input parity checking are INPCK, IGNPAR, PARMRK and ISTRIP. Generally you will check/select INPCK and ISTRIP to enable checking and stripping of the parity bit, i.e.


    serialConfig.c_iflag |= ( INPCK | ISTRIP );


    ISTRIP is disabled in the above mentioned program. So, the next step would be enabling this constant and implementing the changed program.


    serialConfig.c_iflag &= ~(IGNBRK | BRKINT | IGNPAR | ICRNL | INLCR | ISTRIP | IGNCR | IUCLC);


    Best regards,

    Ravindra Chand



  • Hi,


    I finally could try the above mentioned setting change and it did not help. The wronge Bytes are still note marked from the read function. When I enable the ISTRIP Flag than I also see that when I send a 0xFF, I get a 0x7F from the read function instead of the 0xFF 0xFF.


    Kind regards,

    Gregor

  • The kernel version is 4.1.15-F+S.


    When I Set the IGNPAR Flag I don't see any changes at all.


    We have another issue now with the serieal port. When we send a lot of data it seems that an internal buffer (maybe the tty_buffer) buffers all the received data. Even when we call the read function we don't get any data. Only when the buffer is full or there are no incoming data, we get our data from the read function. This causes a lot of timing issues as we need to process the data right when it arrives.

  • Hello,


    your problems seem to be related to the Direct Memory Access (DMA) implementation of the i.MX-UART driver.


    The i.MX -ART driver automatically enables DMA for all non-console UARTS.

    This adds a 4 KB buffer, which delays the transmission of the received data to the userspace.

    Also, parity detection is not implemented for UART with DMA.


    We will add a possibility to disable DMA for specific UART devices via the devicetree in the next i.MX6 related release.


    For all who need this feature earlier, please post your Linux-Kernel version here and we will send you a patch.


    Your F&S Support Team