Open a listening TCP Port & route packets to RS232

HI all,

I am new to coding for the C++ & the Legato environment. I have an FX30S-LTE that I need to open a TCP/IP port to listen for incoming connections & then route the data packets to the RS232 port. I am currently opening a PPP session with the attached device (a data logger) but as expected, this is not particularly reliable. Any help in how to code for this to run automatically on start up would be very much appreciated. Thanx

Is that you must use PPP session in RS232?

Here has an example to forward the TCP data received in TCP server to UART directly:

Thanx for your response. I don’t have to have PPP running, it was just a method to open a listening port & establish communication from a computer to the data logger over a private APN. Avoiding the PPP session is ideal.
I’ll give your suggestion a try

When I try to compile & run the code I get the following error: The path ‘/dev/ttyHSL0’ cannot be resolved
Any suggestions?
I have the code as follows:
version: 1.0.0
maxFileSystemBytes: 512K
sandboxed: true
start: manual
executables:
{
iptables -I INPUT -j ACCEPT
app runProc UART_TCP_Server UART_TCP_Server --exe=uart – 6785 /dev/ttyHSL0 115200
uart = ( UART_TCP_ServerComponent )
}
processes:
{
envVars:
{
LE_LOG_LEVEL = DEBUG
}
run:
{
//( uart )
}
maxCoreDumpFileBytes: 512K
maxFileBytes: 512K
}

Feel free to call me an idiot if this is a complete steaming pile of not correct :slight_smile:

you need to set AT!MAPUART=17,1 and then reset the module.
UART1 will be using as /dev/ttyHSL0

I did wonder about that & have tried it. I now get the code compiling & can load it into the modem, but I do not have any coms through to the logger. The logger is set to 115200 baud rate. Do I need to change IP Address or Port number anywhere else in one of the included files? Ideally it would work with any IP address issued by the cell network

I can also ping the modem from the remote PC

you can start with USB ECM interface first and see if the app can receive the TCP data.
i.e.
Establish a TCP client connection from PC to 192.168.2.2 on port 5044

My PC gets an IP address from the modems DHCP server, but it will not talk to the logger (I am assuming that TCP packets over the USB connection will also be ported to the UART)

you can try with the nc tool first instead of legato app:

  1. Disable firewall by
    iptables -I INPUT -j ACCEPT

  2. transfer this nc file to module 's /tmp folder:

nc (756.4 KB)

  1. module side:
    chmod 777 /tmp/nc
    /tmp/nc -l -p 1234

  2. PC side:
    owner@owner-ThinkPad-X220:~$ netcat 192.168.2.2 1234

This can ensure the TCP server is working fine via USB ECM interface.

Hi there,

Ihave finally got back to this, my time was taken away by other work. I’m not sure how to run the commands you are talking about. I am running a Windows 7 PC, I suspect you are running a Linux environment of some variation?
It is also worth noting that I have changed the port number to 6785 for our purposes.
Do I need to set this anywhere else? in any of the other code files for example?

This is the change I have made:
app runProc UART_TCP_Server UART_TCP_Server --exe=uart – 6785 /dev/ttyHSL0 115200

Can you communicate with the nc tool?

no, this what I’m not sure about

maybe you can try with a linux pc first

I don’t have access to one otherwise I would be using it. I am using WinSCP to load files to the modem

how about using VMWARE to use linux PC?
You can then route the USB to the linux VM

I’ll try to sort out a linux machine. I might be able to run it from a USB drive. As I am not familiar with linux, how would I go about running the commands? I assume there is a terminal of some kind?

I believe there is usb0 created for USB ECM interface.
You can set the IP address of this usb0 to be 192.168.2.3
i.e.
sudo ifconfig usb0 192.168.2.3

OK. I have found a spare HDD & installed Arcolinux(L) on it. What do I need to do to test the modem? I am completely new to using linux