zoukankan      html  css  js  c++  java
  • Bridge Serial-Ports over network

    https://stackoverflow.com/questions/29207980/bridge-serial-ports-over-network

    For an application, which uses SerialPorts for communication (Modbus RTU, to be exactly) I need to bridge the SerialPort over the network for testing purposes.

    So I would like to have the following Setup:

    Device        |     Network      |      PC
    
    SerialPort    |------------------|    SerialPort
    Map Serialport|                  | Map network to Serialport
       to Network |                  |   
    

    I already got the first part working with socat.

    I opened the TCP Port on PC with

    nc -l 8080
    

    On my Device I used

    socat  pty,link=/dev/virtualcom0 tcp:PC-IP:8080
    

    To map everything written on /dev/virtualcom0 to PC-IP on port 8080.

    But now I have problems to map the socket back to a Serialport.

    socat tcp:PC-IP:9123 pty,link=/dev/virtualport0
    

    This got me a Connection Refused, which is obvious because i used TCP and the Port is already used by the Device.
    So I tried the same with

    socat  pty,link=/dev/virtualcom0,raw  udp:PC-IP:8080
    

    and changed everything else to UDP, too.

    But then nothing arrives on my /dev/virtlalcom0/ on my PC.

    One side of the tcp connection needs to be listening on the port (the first one you launch), and the second side connects to it.

    For the first side do:

    socat tcp-listen:8080 pty,link=/dev/virtualport0
    

    And for the second side do:

    socat pty,link=/dev/virtualcom0 tcp:IP-of-other-machine:8080
    

    Forget the netcat, you do not need it.

  • 相关阅读:
    bzoj 1004 burnside 引理+DP
    bzoj 3453 数论
    HDU 2899 三分
    HDU 2199 二分
    bzoj 3450 DP
    bzoj 1197 DP
    bzoj 2121 DP
    bzoj 2258 splay
    bzoj 1296 DP
    Memcached的限制和使用建议
  • 原文地址:https://www.cnblogs.com/arci/p/10510216.html
Copyright © 2011-2022 走看看