More COM port in Linux Codesys

damian177
2022-03-15
2022-03-28
  • damian177 - 2022-03-15

    Hi,

    I am using linux panel PC CPi-A102WR with Codesys. I using two embeded serial ports by Edit the CODESYS configuration file

    sudo nano /etc/CODESYSControl.cfg

    [SysCom]
    Linux.Devicefile=/dev/serial

    And I have
    COM1 - COM0(physical)
    COM2 - COM1(physical)

    Now I need more COM port, so I use USB to RS232 nad in the linux I have device : dev/ttyUSB0.

    What I should modify in /etc/CODESYSControl.cfg file to using my device ttyUSBO like COM3 in codesys ?

     
  • eschwellinger

    eschwellinger - 2022-03-15

    /etc/CODESYSControl_Users.cfg

    [SysCom]
    Linux.Devicefile.1=/dev/serial1
    Linux.Devicefile.2=/dev/serial2
    Linux.Devicefile.3=/dev/ttyUSB0
    Linux.Devicefile.4=/dev/ttyUSB1

     
  • somlioy - 2022-03-16

    You could also do symbolic link from /dev/ttyUSB0/1 to /dev/serial

    sudo ln -s /dev/ttyUSB0 /dev/serial2
    sudo ln -s /dev/ttyUSB1 /dev/serial3

    Presuming you keep original .cfg file with Linux.Devicefile=/dev/serial, ttyUSB0/1 will then be available as COM3 and COM4.

     
  • damian177 - 2022-03-19

    @eschwellinger I should remove this lines :

    [SysCom]
    Linux.Devicefile=/dev/serial
    

    from /etc/CODESYSControl.cfg file ?

    I do this and add

    [SysCom]
    Linux.Devicefile.1=/dev/serial0
    Linux.Devicefile.2=/dev/serial1
    Linux.Devicefile.3=/dev/ttyUSB0
    

    in empty /etc/CODESYSControl_Users.cfg file , but it doesn't work.

     
    • damian177 - 2022-03-28

      @somlioy do you have any solution to symbolic link after reboot system ?
      I have finished my application with dev/ttyUSB0 i dev/ttyUSB1, but I still creating symbolic link - manually after reboot system.

       
  • damian177 - 2022-03-19

    Solution with symbolic link works,until I restart my system.

     
  • damian177 - 2022-03-28

    What do we think about this solution.

    I should create file :

    /etc/udev/rules.d/70-persistent-serial.rules 
    

    and put in it:

    ACTION=="add|change", SUBSYSTEM=="tty", KERNEL=="ttyUSB0", \
      ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="AK08GAMY", \
      SYMLINK+="serial2"
    
    
    
    ACTION=="add|change", SUBSYSTEM=="tty", KERNEL=="ttyUSB1", \
      ATTRS{manufacturer}=="FTDI", ATTRS{serial}=="AK08G985", \
      SYMLINK+="serial3"
    

    ?

     
  • somlioy - 2022-03-28

    yes udev is the way to go. wether config rule works you must test on the device.

     
  • damian177 - 2022-03-28

    The above solution works great. I test it now

     

Log in to post a comment.