Enable more than one COM port in raspberry for more modbus channels with USB

francoinf
2019-10-09
2020-02-07
  • francoinf - 2019-10-09

    Hi,
    what I want to do in a project is to communicate with modbus devices through more than one channel, to be connected to the raspberry's USB ports. Some devices will connect them to the first channel, others to the second, others to the third, etc.
    I know the procedure to enable only one channel, writing the following code in the file "/ect/CODESYSControl.cfg":

    [SysCom]Linux.Devicefile = / dev / ttyUSBportnum: = COM.SysCom.SYS_COMPORT1;

    in this way, I enable the COM 1 port, via USB, to communicate with my modbus devices (and everything works correctly).

    If, on the other hand, you want to enable more than one COM port (for example the COM 1 and COM 2 ports simultaneously), what should I write in the CODESYSControl.cfg file?

    Thanks in advance

     
  • eschwellinger

    eschwellinger - 2019-10-09

    Hi,
    since 3.5SP15 it is possible that way:

    set this in /etc/CODESYSControl_User.cfg
    Example
    [SysCom]
    Linux.Devicefile.1=/dev/ttyS0
    Linux.Devicefile.4=/dev/ttyUSB0

    so Com1 is ttyS0 Com4 is ttyUSB0

    in versions <SP15 it was needed to set symlinks / or use UDEV to sort them into the same the device under Linux.

    BR
    Edwin

     
  • francoinf - 2019-10-10

    Hi Edwin,
    thanks for the reply. Only the COM1 port works if in the file /etc/CODESYSControl.cfg (and not in the file /etc/CODESYSControl_User.cfg) I write:

    [SysCom]
    Linux.Devicefile=/dev/ttyUSB
    portnum := COM.SysCom.SYS_COMPORT1;

    What I wrote (which does not work) is, in the file /etc/CODESYSControl_User.cfg the following code:

    [SysCom]
    Linux.Devicefile.1=/dev/ttyUSB0
    Linux.Devicefile.2=/dev/ttyUSB1

    with the aim of enabling the COM1 port in the USB1 port of the raspberry, and the COM2 port in the USB2 port of the raspberry (I suppose USB0 is the first USB port, USB1 the second, USB2 the third and USB3 the fourth of the raspberry).
    I tried to write the same code as above also in the file /etc/CODESYSControl.cfg and nothing.
    What can be the cause of the malfunction?
    Thanks,
    Francesco

     
  • francoinf - 2019-10-10

    NOTE: I use CODESYS v3.5 SP15

     
  • esih - 2020-02-06

    Having the same issue as OP ... Any ideas?

     
  • esih - 2020-02-07

    Nevermind, i found a solution in another topic l viewtopic.php?f=23&t=6247&start=30 l

     

Log in to post a comment.