Using Automation server to access RPi softplc over a 4g link with a dynamic IP address?

trent
2022-02-08
2022-02-15
  • trent - 2022-02-08

    Hi all,

    I have a raspberry-pi with an ethernet network interface (eth0) and a 4g modem interface (wwan0)

    When I have an ethernet cable connected to eth0, I am able to connect to the codesys soft PLC running on the pi via the Codesys automation server.

    But, when I disconnect the ethernet cable,CAS reports my Pi is no longer connected to the Automation server. (But the pi still has internet access via the wwan0 interface, i can ping external IP's and hit web pages from the terminal...)

    I was wondering, is there a way to force the Linux Edge gateway running on the pi to use a specific network interface? (wwan0 in this case)

    I should also mention that the IP address associated with wwan0 is a dynamic "10.116.xx.xx" address which is not publicly accessible/ routable through the internet.

    Ideally I'd like to be able to install the device somewhere with just a 4G connection.
    The device would maintain a connection with CAS, so I can remotely access the device to modify code/ troubleshoot using Codesys IDE.
    Just wondering if anyone has implemented something similar? Or am I crazy and need to think of another way :)

    Cheers,
    Trent

     
  • eschwellinger

    eschwellinger - 2022-02-09

    Should work, does the Gateway stay green if you disconnect the ethernet cable in the CAS?

     

    Last edit: eschwellinger 2022-02-09
  • trent - 2022-02-09

    Thanks for your reply,

    Yes the Gateway status icon always appears to stay green, regardless of whether the ethernet cable is connected or not, I guess that suggests the edge gateway on the Pi is using the wwan0 interface....

    But, when I look in "list view", the status icon of the device changes to a red exclamation mark within a circle when i disconnect ethernet cable and I can no longer connect to the device via Codesys IDE.

    This icon changes back to the debug icon when i reconnect the ethernet cable....

    Is it possible I need to force the CodesysControl application to use the wwan0 port as well?

    cheers,
    Trent

     
  • eschwellinger

    eschwellinger - 2022-02-09

    Hi Trent,
    this should work,

    • Does a websocket connection work for you via the 4G modem?
      I have found the following project with which you can test it in the console: https://github.com/vi/websocat
      Alternatively, if you have RaspberryPI OS with graphilcal interface on the PI, you could with achromium/browser go to You Automation Server URL.
      If you see there the status of Edges + PLCs then also the Edge should be able to connect.

    • If you uses the PI as edge gateway and PLC, will the 4G modem show both the edge gateway and the PLC as disconnected or only the PLC?

    • If it was just the PLC, I would imagine that he might have a problem with the UDP broadcast.
    • Then you could connect the PLC with the IP address, locally this should be possible even with "localhost".
      -> as an option Increase the log level of the Edge should also provide more information.

    How to do this:
    in /etc/Gateway.cfg

    [CmpLog]
    **CmpEdgeGateway.Filter=0xFFFFFFFF**
    Logger.0.Name=/tmp/codesysedge.log
    Logger.0.Filter=0x0000000F
    Logger.0.Enable=1
    Logger.0.MaxEntries=100000
    Logger.0.MaxFileSize=5000000
    Logger.0.MaxFiles=1
    Logger.0.Backend.0.ClassId=0x00000104 ;writes logger messages in a file
    Logger.0.Type=0x314 ;Set the timestamp to RTC
    

    If you need more information - just use -> my question technical request/bugreport - we could investigate this on the system if needed.

     
  • eschwellinger

    eschwellinger - 2022-02-09

    a ok sorry did not see the answer bevor my post, if it stay green then the problem is:

    "I would imagine that he might have a problem with the UDP broadcast"
    Then you could connect the PLC with the IP address in the Edge Gateway here:
    This should solve it!
    picture follows

     

    Last edit: eschwellinger 2022-02-09
  • trent - 2022-02-15

    Hi @eschwellinger

    Thanks very much for your responses - I ended up changing the IP address to localhost and that has fixed the issue for me :)

    regards,
    Trent

     

Log in to post a comment.