How to create a link between a USB port and a TCP or UDP port

jspri

New Member
Joined
Jul 9, 2018
Messages
2
Reaction score
3
Credits
0
Hi,

I am trying to create an interface between some industrial sensors and a remote (cellular) operating station. The industrial sensors communicate through USB only, but I would like to forward all information from the sensors over the internet to another computer, so that the information can be seen while the operator is not in the field. I would also like to forward all information from the other computer to the sensor's USB port.

In short, I want to connect two ports of different types via the command line.

Is there a reasonably simple way to do this via the command line? If not, is there a reasonably simple way to program this in C/C++ or Java?
 


I think your issue here is that you are trying to forward non-networked data over a network. You will definitely need some application to translate the data from the sensors on the USB port to a format that can be used over a network.

I would suggest writing an application which reads from the USB port, stores the data in a buffer of some type (depending on the amount of data, you may want to consider a file-based buffer) and then this application should make the data available via the required TCP or UDP. But then that still raises the question of network information, packetization, etc of the data.

Another approach ( I think this is easier) would be to write one application which reads the data from the sensors and writes them to files which are in a directory hosted by an existing web server such as Apache or Nginx.

But, if you need this to be in-real-time then the only real option is to write your own application that translates the data into a format which can be transferred over a network without any type of buffering (I don't know of anything that goes from USB to Network for generic data). It should be possible to set this up using Java Streams as a data pipeline that reaches Java's built in Socket library.

*EDIT: I just thought about it a bit more, and using SOCAT should allow you to transfer the data from the USB port as a raw byte stream (that is its purpose). https://linux.die.net/man/1/socat
 
Last edited:
I think your issue here is that you are trying to forward non-networked data over a network. You will definitely need some application to translate the data from the sensors on the USB port to a format that can be used over a network.

I would suggest writing an application which reads from the USB port, stores the data in a buffer of some type (depending on the amount of data, you may want to consider a file-based buffer) and then this application should make the data available via the required TCP or UDP. But then that still raises the question of network information, packetization, etc of the data.

Another approach ( I think this is easier) would be to write one application which reads the data from the sensors and writes them to files which are in a directory hosted by an existing web server such as Apache or Nginx.

But, if you need this to be in-real-time then the only real option is to write your own application that translates the data into a format which can be transferred over a network without any type of buffering (I don't know of anything that goes from USB to Network for generic data). It should be possible to set this up using Java Streams as a data pipeline that reaches Java's built in Socket library.

*EDIT: I just thought about it a bit more, and using SOCAT should allow you to transfer the data from the USB port as a raw byte stream (that is its purpose). https://linux.die.net/man/1/socat


socat allowed me to do exactly what I need to do, and really quickly!!!! Thank you so much.
 
socat allowed me to do exactly what I need to do, and really quickly!!!! Thank you so much.
You didn't describe for us the application for these "industrial sensors." But just because you can create this data circuit, it does not mean that you should do it. Low level industrial process control systems probably should not have Internet-facing access for security reasons. Consider this: What are the consequences if your data circuit is hacked and bogus data is sent to your remote computer? And since you want a two-way circuit, what are the consequences if a hacker sends undesired commands to your sensors?

Maybe your application is trivial and you have no worries here. But if such a hack might stop your process, or shut down a machine, or bypass or disable a safety mechanism... there could, in some cases, be dire consequences. What is the possibility, if your data circuit is hacked, that an intruder might gain deeper access to your company's network through the remote computer?

Welcome @jspri to the forum! Sorry to be so full of doom-and-gloom today! :eek::eek::D:D

Cheers
 

Staff online

Members online


Top