B4J Question Working with RS-485 to Ethernet converter in B4J

red30

Well-Known Member
Licensed User
Longtime User
I have an RS-485 line on which several devices are present. At the end of this line is an RS-485 to USB converter. When I insert this converter into a PC, it is defined as a COM port and I work with these devices using the "Serial" and "AsyncStreams" libraries
B4X:
sp.Initialize("")
cb1COM.Items.AddAll(sp.ListPorts)           
sp.Open(cb1COM.Value)
sp.SetParams (1200,8,1,0)
astream.Initialize(sp.GetInputStream, sp.GetOutputStream, "astream")
There is also an RS-485 to Ethernet converter. Is it possible to somehow work with him directly? Is there some kind of library for this?
I found that some manufacturers provide software for converting Ethernet to virtual COM port. For example, "USR-VCOM", but this is very inconvenient because you have to run additional software. Is it possible to somehow work directly with the RS-485 to Ethernet converter using only B4J?
 

Num3

Active Member
Licensed User
Longtime User
Unless the manufacturer supplies an API, SDK or driver for direct interface to the converter, no.
You would also need the manual on how use the functions.
 
Upvote 0

red30

Well-Known Member
Licensed User
Longtime User
Unless the manufacturer supplies an API, SDK or driver for direct interface to the converter, no.
You would also need the manual on how use the functions.
Perhaps I do not understand the structure of the converter itself, but the software provided by the manufacturer essentially creates a virtual com port. I only need to select 3 parameters that are known in advance: Net Protocol: TCP Client, Remote IP: the address set on the converter (eg 192.168.31.205), Remote Port: The port set on the converter (eg 20108). Can I do the same with B4J and send / receive data via Ethernet converter? Or is everything much more complicated and in fact it is not done directly but through a certain protocol?
 
Upvote 0

Drago Bratko

Active Member
Licensed User
Longtime User
On some projects, I'm using same thing (serial to ethernet). Serial can be RS232 or RS485 ... in my case it's also 485.
For me installing third party is also something what I would like to avoid. And only way to do that is wrote yourself virtual serial port software inside your application. To be able to do that, you need to know in detail protocol specification of manufacturer of 485/Ethernet which you are using. One which I use, protocol is not documented publicly so I (for now) decided to not do it.
Solution (or way) which I will probably go is to do RS485/ethernet by myself. You can think also of that way.
With B4X set of tools, you can do it with B4R on ESP32 ... then you would have RS485/WiFi with known protocol which you can simply use from your applications on desktop or mobile phones (and good is all programmed and code shared with B4X set of tools).
 
Upvote 0
Top