Linux上のイーサネット経由のシリアルデータ

Linux上のイーサネット経由のシリアルデータ

イーサネット(Serial to Ethernet)を介してウィジェット(192.168.1.214:20108)をLinuxボックスに接続しようとしています。

Windowsで仮想デバイスドライバマッピングを使用すると、シリアルデータが表示され、シリアル - イーサネットウィジェットが動作していることがわかります。

Linuxシステムを指すと、tcpdumpを使用したときの接続試行のみが表示されます。

21:00:07.322019 IP 192.168.1.214.20108 >development.local.8234: フラグ[R], seq 4096, win 0, 長さ 0

したがって、イーサネットパケットは通過しますが、シリアルデータ(ポート8234イーサネット経由)をデバイスにマッピングする方法が見つかりません。多くのバリエーションはsocat画面にデータを生成しません。たとえば、次のようになります。

$ sudo socat readline TCP-LISTEN:8234,bind=127.0.0.1

または開発者にバインドしてみてください。

$ socat -d -d -d tcp-l:127.0.0.1:8234,reuseaddr,fork file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock

出力は次のとおりです

2013/11/11 21:19:41 socat[23757] I setting option "so-reuseaddr" to 1
2013/11/11 21:19:41 socat[23757] I setting option "fork" to 1
2013/11/11 21:19:41 socat[23757] I socket(2, 1, 6) -> 3
2013/11/11 21:19:41 socat[23757] I starting accept loop
2013/11/11 21:19:41 socat[23757] N listening on AF=2 0.0.0.0:8234

Linuxシステムでは、イーサネット経由でシリアルデータを読み取る方法がわかりません。

ベストアンサー1

Stackoverflowを探索しながら、次のタイトルのQ&Aを見つけました。Linux環境でシリアルポートデータをTCP / IPに変換する。特に、この質問に対する答えの1つは、あなたが探しているものと似た2つのツールを強調しました。

  • ser2net - シリアルネットワークプロキシ(ser2net)

    ser2net は、ユーザーにネットワーク接続からシリアルポートに接続する方法を提供します。私が見つけることができる他の方法はすべて試してみましたが、欠けていると思われ、自分で書いていました。すべてのシリアルポート設定、ポート設定用の設定ファイル、ポートパラメータを変更するための制御ログイン、監視ポート、および制御ポートを提供します。

  • remtty - リモートtty

    remtty(「remote tty」の略)を使用すると、TCP接続が疑似ttyとして機能する可能性があります。これにより、ダイレクトモデムアクセス(Cisco NASなど)を持つアクセスサーバーを通常のダイヤルアウトモデムとして使用して、ファックスを送信したり、テキストメッセージを送信したり、BBSにアクセスしたりできます。 CiscoのDialout Utilityと同様の機能を提供しますが、Windowsの代わりにGNU / Linuxで実行されます。

また、使用方法を説明するこの記事を確認したい場合があります。必要な操作が正確に実行されることをsocat願っています。

このページから抜粋

- You have a host with some serial device like a modem or a bluetooth interface
(modem server)
- You want to make use of this device on a different host. (client)

1) on the modem server start a process that accepts network connections and
links them with the serial device /dev/tty0:

$ socat tcp-l:54321,reuseaddr,fork \
     file:/dev/tty0,nonblock,waitlock=/var/run/tty0.lock

2) on the client start a process that creates a pseudo tty and links it with a
tcp connection to the modem server:

$ socat pty,link=$HOME/dev/vmodem0,waitslave tcp:modem-server:54321

NETWORK CONNECTION

There a some choices if a simple TCPv4 connection does not meet your
requirements:
TCPv6: simply replace the "tcp-l" and "tcp" keywords with "tcp6-l" and "tcp6"
Socks: if a socks server protects the connection, you can replace the
"tcp:modem-server:54321" clause with something like
"socks:socks-server:modem-server:54321" or 
"socks:socks-server:modem-server:54321,socksport=1081,socksuser=nobody"

SECURITY

SSL
If you want to protect your server from misuse or your data from sniffing and
manipulation, use a SSL connection with client and server authentication
(currently only over TCPv4 without socks or proxy). 
See <a href="socat-openssl.txt">socat-openssl.txt</a> for instructions.

IP Addresses
!!! bind=...
!!! range=...
!!! lowport (for root)
!!! sourceport
!!! tcpwrap=

FULL FEATURES
$ socat -d -d ssl-l:54321,reuseaddr,cert=server.pem,cafile=client.crt,fork \
     file:/dev/tty0,nonblock,echo=0,raw,waitlock=/var/run/tty0.lock

TROUBLESHOOTING
-v -x

おすすめ記事