Link to home
Create AccountLog in
Avatar of javaCaravan0
javaCaravan0

asked on

Remotely accessing Serial Port

I want to remotely connect to a serial port of DIGI device to pull the data. The DIGI device is
installed on an asset. I want to write an application which should establish SSH connection to the serial port and  pull the data. I have this idea but not sure how to implement it and how can I remotely connect to  the serial port. Please explain what do I need to do?
Avatar of gelonida
gelonida
Flag of France image

Could you give a little more info.

Please correct me if I misunderstood:

you have a machine (the asset) let's call it remote_machine, which has a serial port and a device (DIGI devce) connected to it.

you have another machine (let's call it the local machine)

you want to access the deigi device from uour local machine.

- Which OS is on the remote machine?
- which OS on the local machine?
- what is the software on your local machine? Is it an existing one, which can only communicate with serial ports or is it a software which is under your control?



Potential ideas, but I'd need more info:
- write a small application (serial_server, which opens the serial port an a socket t(listening as server) an a port (SERVER_PORT)
 all data read from the uart will be sent to the socket, all data received on the socket will be sent to the uart.

ssh from your local machine to the remote machine and do a port forward from a local port (LOCALPORT)  to the SERVER_PORT

This means, that you now any application running on yopur local machine could connecte to the LOCALPORT , which would be forwarded via ssh and thus connect to the serial_server which would relay the data to the DIGI device.

What's missing and this depends really on your local machine's OS and application is how to make this application work with a localsocket instead of a serial port.

Avatar of javaCaravan0
javaCaravan0

ASKER

gelonida:

Thank you for the idea.

Both local and remote machine are running on LINUX.

I got an idea but to be 100% clear, please exlain in little more detail and also please correc the following, I just don't want to guess what you mean:

- write a small application (serial_server, which opens the serial port an a socket t(listening as server) an a port (SERVER_PORT)

* I culdn't understand "an a port (SERVER_PORT)"

-all data read from the uart will be sent to the socket, all data received on the socket will be sent to the uart.

* I culdn't understand "all data read from the uart"

Please elaborate this statement:

-ssh from your local machine to the remote machine and do a port forward from a local port (LOCALPORT)  to the SERVER_PORT

Thank you very much for thie great input.

Apologies I lost the networtk while writing a comment.
Will come back later :-(
Ler me make some correction:

I want to write a program in JAVA that will connect to a remote assets let's say TRUCKS. Trucks  have a digi device installed which is connected to the main computer (via a serial port) which has all the event logs, status messages etc. I will be provided with an IP and the port information to connect to the main computer via digi device. I will need to send messsage/command to the Digi that will be relayed to the computer, responses from the computer will be sent by Digi to the program which will put them in a queue (Active MQ).

What do I need to do to make this happen? Also, since there are lots of Trucks, how can I achieve scalabity and load balancing?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of gelonida
gelonida
Flag of France image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
gelonida:

sorry for the confusion. I am new and want to lear how real time communication takes place and how can I implement it. Let me explain the objective once again. (I may not need to connect to the serial port)

I want to write a program in JAVA that will connect to a remote assets let's say TRUCKS. (The big trucks that carry cargo) Trucks  have a digi device  installed which is connected to the onboard computer (via a serial port, each truck has a computer).All the event logs, status messages etc. are on the computer. I will need to connect to the Digi device by sending the IP address and the port. For example, I will need to send a command "connect me to  this IP at this port. The commands/messages that I send to the Digi device will be relayed to the computer and responses from the computer will be sent by the  Digi to my Java program which will put them in a queue.

So, perhaps, there is not need to establish connection to the serial port, insteal, I need to talk to the Digi device.

Let's say there are 1,000 truck. I will perhaps need to store 1,000 IP and port #s in the database. My java program will pull the IP and port info from the database and send 1,000 command to 1,000 unique trucks. Let's say, we need to downlaod event logs/status messages from 1,000 truck every 15 minutes. So I will need to send a command to the Digi device everything 15 minutes for all 1,000 trucks.

I hope this is now clear. Please provide your feedback.
Hi javaCaravan0,

Thanks for the clarification. It's much clearer now :-)

It seems your problem is writing an application, that connects over TCP to 1000 devices, sends commands and retrieves data.

I'm not a Java expert. I replied because of the SSH  aspect, so I can' thelp you a lot.

I would suggest to close this question and repost two different questions.
with different titles. ( I think the serial port aspect should be completely hidden from you)

This might yield more answers.

Q1: How to fetch data from a digi device via Java
Ideally you could give more info about:
- the exact type of the device
- the protocol:
Is it a standard protocol (HTTP/ HTTPS) or a custom protocol?
Is any authentification required?
Are there already sample programs (in whatever programming language), which can access a device?

You could even mention, that the long term goal is to access ~1000 devices every 15 minutes.
But the first step is to talk with one device.


Q2:  "Gathering data in Java over TCP from 1000 devices"

With this question you might obtain answers about different strategies:
- multiple threads
- select based loop,
. . .

Apologies, that I can't really help and good luck.
Thanks gelonida:

You have privded good knowledge and great feedback