简体   繁体   中英

RS485 communication over TCP/IP

I have a device which has a rs485 output and another gsm device connected to this output.

I can access gsm device with a special IP and port. Gsm device is working transparently. Sending all data recieved from tcp socket to rs485, and retrieving data on rs485 then write to the opened tcp socket.

connection between gsm device and rs485 existing device is wired and fix baudrate on 300.

when I tried to read rs485 existing device with my laptop, connect rs485 to my usb, setting serial parameters like;

  • parity : even
  • databit : 7
  • stopbit : 1
  • baudrate : 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.

for instance;
I want to send /?![CR][LF] as UTF-8.

When using wired connection to device basically sending "/?!\\r\\n".getBytes("UTF-8") and device answering.

When using gsm, I monitor over wireshark, device is only answering with byte array : AF-3F-21-8D-A0

AF is signed format of "/" - 2F

Also 8D is signed format of [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 ?

Thanks for your reply.

There is a way to set RS232/485 serial COM parameters for these kinds of devices via TCP. The standard for it is

RFC 2217 Telnet Com Port Control Option

but not all manufacturers of "Serial COM via TCP/IP" or similar devices support it.

You need to check your GSM device if it supports different operation modes. 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.

For example both the MOXA and Lantronix brands support RFC 2217 based operation mode.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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