B4J Question Raspberry - How to realize a serial server Uart / Ethernet ?

amorosik

Expert
Licensed User


The Raspberry4 board has 6 native uart
Having to control devices via uart (for example gps receivers, electronic scales, etc.) it would be useful to create a device that, communicating with the control computer via ethernet, would allow the computer to 'see' the virtual com ports, corresponding to the uart of the card Raspberry
So it will be necessary to program the Raspberry so that it has a tcp / ip server inside, which will pass the information to the uart ports
On the computer side it will be necessary to install programs to 'virtualize' the com port and connect it to the tcp / ip server on the Raspberry
Any idea how to proceed?
 

derez

Expert
Licensed User
Longtime User
To communicate with the RPI from outside of the router you have to set a fixed ip , there are sites which do it for free if you use it not for business (like duckdns, noip).
In the router set a fixed ip for the pi (using its mac address), then make a port for your application in the pi and set the port forwarding in the router.
Now you can call your server program in the pi like this from every browser or app outside: http://[your fix ip name]:[the pi port].
Example: "http://*******.duckdns.org:54025"
The application in the pi to control the devices - this depends on the devices requirements.
 
Upvote 0

amorosik

Expert
Licensed User

Of course, the two routers are connected to the internet and have a static and public IP, so there is no problem for the 'recognition' of one site or the other.
What exactly does "this depends on the devices requirements" mean?
The request is to be able to write on the four virtual com ports on the pc side, and this information must pass on the raspberry uart as they were written on the pc side
Same thing for reading, what appears on the raspberry uartX must be sent to the corresponding virtual comX port of the pc
 
Upvote 0

derez

Expert
Licensed User
Longtime User
The pi's application should be a server app using handlers to act on requests.
Define a handler for each device and control it by the parameters that you pass in the http call.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…