简体   繁体   English

通过TCP / IP进行RS485通讯

[英]RS485 communication over TCP/IP

I have a device which has a rs485 output and another gsm device connected to this output. 我有一个具有rs485输出的设备,另一个与该输出连接的gsm设备。

I can access gsm device with a special IP and port. 我可以使用特殊的IP和端口访问gsm设备。 Gsm device is working transparently. GSM设备透明地工作。 Sending all data recieved from tcp socket to rs485, and retrieving data on rs485 then write to the opened tcp socket. 将所有从tcp套接字接收的数据发送到rs485,并在rs485上检索数据,然后将其写入打开的tcp套接字。

connection between gsm device and rs485 existing device is wired and fix baudrate on 300. gsm设备与rs485现有设备之间的连接已布线,并将波特率固定为300。

when I tried to read rs485 existing device with my laptop, connect rs485 to my usb, setting serial parameters like; 当我尝试用笔记本电脑读取rs485现有设备时,将rs485连接到我的USB,并设置以下串行参数:

  • parity : even 平价:偶数
  • databit : 7 数据位:7
  • stopbit : 1 停止位:1
  • baudrate : 300 波特率:300

(This configuration is universal and described with a standard documentation) (此配置是通用的,并在标准文档中进行了描述)

With this configuration everything is right and I can transfer data. 使用此配置,一切都正确,我可以传输数据。

When I tried to use gsm device, I have to manipulate the generated byte array to fit the rs485 exsiting device. 当我尝试使用gsm设备时,必须操纵生成的字节数组以适合rs485现有设备。

for instance; 例如;
I want to send /?![CR][LF] as UTF-8. 我想发送/?![CR][LF]作为UTF-8。

When using wired connection to device basically sending "/?!\\r\\n".getBytes("UTF-8") and device answering. 当使用有线连接到设备时,基本上发送"/?!\\r\\n".getBytes("UTF-8")和设备应答。

When using gsm, I monitor over wireshark, device is only answering with byte array : AF-3F-21-8D-A0 使用gsm时,我监视Wireshark,设备仅以字节数组应答: AF-3F-21-8D-A0

AF is signed format of "/" - 2F AF"/" - 2F签名格式"/" - 2F

Also 8D is signed format of [CR] - 0D 同样8D[CR] - 0D符号格式

I thinking that, the difference with bytes is causing from my configuration that used on serial connection. 我认为,字节之间的差异是由我在串行连接上使用的配置引起的。

Is there a way to set this configurations (parity, stop, data bits ) when using tcp/ip sockets ? 使用tcp / ip套接字时,是否可以设置此配置(奇偶校验,停止,数据位)?

Thanks for your reply. 感谢您的回复。

There is a way to set RS232/485 serial COM parameters for these kinds of devices via TCP. 有一种方法可以通过TCP为这些类型的设备设置RS232 / 485串行COM参数。 The standard for it is 它的标准是

RFC 2217 Telnet Com Port Control Option RFC 2217 Telnet Com端口控制选项

but not all manufacturers of "Serial COM via TCP/IP" or similar devices support it. 但并非所有“通过TCP / IP的串行COM”或类似设备的制造商都支持它。

You need to check your GSM device if it supports different operation modes. 您需要检查GSM设备是否支持不同的操作模式。 Eg a "raw mode" (which is probably what is used now), and a "managed mode" like RFC 2217 or something proprietary that allows control on serial line parameters. 例如,“原始模式”(现在可能正在使用)和“托管模式”(例如RFC 2217)或允许控制串行线路参数的专有技术。

For example both the MOXA and Lantronix brands support RFC 2217 based operation mode. 例如, MOXALantronix品牌都支持基于RFC 2217的操作模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM