PicoCoreMX8MP with PicoCoreBBDSI RS485 full duplex self test / loopback

  • We are having trouble with RS485 in full duplex mode. Our setup is as follows:


    PicoCoreMX8MP

    PicoCoreBBDSI Rev1.40

    SW1 is ON and SW2 is ON.

    J10 Pin 3 is connected to J10 Pin 4 with a jumper wire

    J10 Pin 5 is connected to J10 Pin 6 with a jumper wire

    We then run the following from a shell in Linux:

    Code
    1. $ (stty raw; cat > received.txt) < /dev/ttymxc3
    2. $ echo test > /dev/ttymxc3

    expecting to see something has been written to received.txt, but the file remains empty.


    What might we have missed?

  • Hi nicv ,



    Could you please tell me what board revision your PicoCoreMX8MP has and what software version you are using?


    I need this information to reproduce your problem.


    In general I can tell you that for RS485 under Linux you need to do some configuration. If you have set the HW jumpers for RS485, the transceiver will use the RS485 prodocol. For Linux, further adjustments are required because the RTS and CTS behavior is different between RS232 and RS485.


    This is usually done by setting the RS458_ENABLE and RTS_ON_SEND flags with an IOCTRL. This can be done with a C program.


    Alternatively, the following property can be added to the UART device via the device tree of the Linux system:

    linux,rs485-enabled-at-boot-time;


    I will reproduce the RS485 problem and tell you exactly what to do in your case.

  • Good news,


    RS422 loop back works perfectly.

    Unfortunately, flags must be set via a C program using IOCTL.


    Please have a look at the Linux documentation on how to set IOCTL for RS485/RS422.


    See link.


    You can see the flags I have set here:


    Code
    1. /* Set the port in rs485 mode */
    2. ctrl485.flags = SER_RS485_ENABLED | SER_RS485_RTS_ON_SEND | SER_RS485_RX_DURING_TX;
    3. err = ioctl(fd, TIOCSRS485, &ctrl485);
    4. if (err) {
    5. printf("%s: Unable to configure port in 485 mode, status (%i)\n", argv[1], err);
    6. return -1;
    7. }


    After executing the program you can send messages via the bash.

    I have executed the following commands for this:


    Code
    1. root@fsimx8mp:~# stty -F /dev/ttymxc3 115200
    2. root@fsimx8mp:~# stty -F /dev/ttymxc3 sane -echo
    3. root@fsimx8mp:~# cat /dev/ttymxc3 &
    4. root@fsimx8mp:~# echo "Hello world" > /dev/ttymxc3
    5. root@fsimx8mp:~# Hello world

    I hope that works for you too.


    Best regards