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.

  • 相关阅读:
    H 指数 II(leetcode)
    找两个和为目标值且不重叠的子数组(leetcode)
    冗余链接
    那就别担心了 (30分) PTA
    排座位(newcoder)
    倒水(newcoder)
    文献随笔目录03
    基于ASP.NET的高校教学质量监控系统研究随笔
    基于ASP.NET技术的马铃薯专家系统的构建随笔
    高校贫困生评定管理系统设计随笔
  • 原文地址:https://www.cnblogs.com/arci/p/10510216.html
Copyright © 2011-2022 走看看