7141 questions

8568 answers

13830 comments

10608 members

0 votes
78 views 7 comments
by
Hello

I am trying to make python read from RS232 port on TRB142 and output to MQTT

I am not able to read anything

My test program is very simple

---------------------------------------------------

import serial
print "Ready"
with serial.Serial('/dev/ttyHS0', 9600, timeout=None) as ser:
        while True:
                x = ser.read(1)   
                print x

----------------------------------------------

My test connection is    MyPC => USB-RS232(converter) => RS232-Port(TRB142) the wires I have connected are GND, TX, RX

I am running minicom on the PC and I would expect to write some data on the minicom and be able to read that data on the python program running on the TRB142. The port I am using is /dev/ttyHS0 and the RS232 service on the TRB142 is disabled.

I also installed minicom on the TRB142 and tried communicate with the PC but nothing happens

Any tips on how to debug this connection?
Thanks

1 Answer

0 votes
by

Hello, 

Regarding this issue of yours, I believe you must install the python-pyserial package to the TRB142 in order for your script to work. 
To download the said package execute these commands via CLI of TRB142: 

-> opkg update
-> opkg install python-pyserial  

For reference about python-pyserial you can refer to this link: Short introduction — pySerial 3.4 documentation

Note: Any 3rd party packages and custom packages installed in our Teltonika devices this will be the client responsibility we cannot provide further support for this. 

I hope it helps

Regards,
Mellow

by
Hi Mellow

I did install pyserial, the code works, the problem is the serial port.

I try configured it as rs232 console and I am not able to access the shell

[]s
by
Hello,

It would be best to re-flash the firmware without keeping the settings and check it again there is a chance that the custom package interferes with the said functionality.

Let me know the results

Regards,

Mellow
by
Great, I will try that and let you know

Thanks
by
Hi

I have re-flashed, but same problem. Configured rs232 service as console and connected using minicom, output a few trashed characters and nothing more.
by
Hello,

If console is working meaning you are able to reach the router's CLI this means it is working fine. But for your concern about minicom what are you trying to do? You can try accessing the router CLI via console by Putty program.

Regards,
Mellow
by

Hi Mellow

I was not able to access CLI with the RS232, I think I have a hardware problem. I connected the RS232 pins on a oscilloscope and one pin was -5.7V but the other was always 0V

[]s

by
Hello,

I have sent you a private message for troubleshooting TRB142. Kindly read the private message from me.

Thank you and have a nice day!

Regards,
Mellow