1

I'm trying to establish a serial communication between my Raspberry PI 3 B+ - running on Raspbian 10 Buster - and a testing machine I have. The normal behavior of the machine is to send test related data via serial as soon as a test is finished.

I managed to establish the communication in Windows 10 through PuttY using a USB to Serial adapter and it worked fine. However, with the Raspberry I didn't manage to make the communication work.

The setup is as follows: the USB end of the adapter is connected to one of the Raspberry's USB slots, and the RS232 end is connected to my machine. In the Raspberry's side, the USB was given the /dev/ttyUSB0 device name. Here is the output of dmesg | tail:

[ 2702.802083] usb 1-1.1.3: new full-speed USB device number 6 using dwc_otg
[ 2702.934357] usb 1-1.1.3: New USB device found, idVendor=067b, idProduct=2303, bcdDevice= 4.00
[ 2702.934373] usb 1-1.1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 2702.934383] usb 1-1.1.3: Product: USB-Serial Controller D
[ 2702.934393] usb 1-1.1.3: Manufacturer: Prolific Technology Inc. 
[ 2702.935304] pl2303 1-1.1.3:1.0: pl2303 converter detected
[ 2702.939720] usb 1-1.1.3: pl2303 converter now attached to ttyUSB0

I already tried using screen and minicom, and setting them up with 9600 8N1, but they just hang after establishing the connection. The ttyUSB0 is configured as shown bellow:

pi@raspberrypi:~ $ stty -F /dev/ttyUSB0
speed 9600 baud; line = 0;
min = 100; time = 2;
-icrnl -imaxbel
-opost -onlcr
-isig -icanon -echo

After doing a bit of research, i found that I could try doing cat -v < /dev/ttyUSB0 in one terminal emulator, then opening another one and entering echo "hello\r" > /dev/ttyUSB0; this didn't give me anything in the cat terminal, though. Could it be that - because one end of the cable is connected to the Raspberry and the other to the machine - I cannot communicate with myself locally?

Could anyone help me? I'm really stuck here.

  • To get loop-back communication via ttyUSB0 on the Rpi you probably need to cross-connect the Tx lead to the Rx lead on the RS232 end of the converter and then connect only the USB end to the RPi. – yesno Oct 3 at 12:47
  • @Emanoel Costa, Ah, let me see. You project is interesting. My questions: (1) I have summarized your problem in my draft answer, please let me know if I understand the situation correctly, (2) I see that you use "cat" and "echo", I wonder if you sometimes write short bash scripts for testing, or in fact you are using C++ or python for your project? – tlfong01 Oct 3 at 12:53
  • It should work. A clear photo showing the connections at the testing machine may help. If it works on a PC (using USB) it will work on a Pi (using USB). – joan Oct 3 at 13:14
  • @Emanoel Costa, I have finished my first draft of the answer to your question. Don't bother to spend too much time reading the old post I referred. The most important thing is to read my python serial test program to compare and contrast your serial port set up and loop back. Once you climb over this block, the rest is easy. Happy programming! Cheers! – tlfong01 Oct 3 at 13:53
  • @yesno, I believe you are right. I think that I would really need to connect both Tx and Rx on the RS232 end of the cable to do the local loop-back communication. I didn't think of this at the time, though haha. – Emanoel Costa Oct 3 at 13:58
0

Question

Objective

How to send a machine's test results to Rpi3B+ buster USB to serial port (5V TTY) .

Progress

Machine can send test results to Win10 PuttY, using WinPC USB to serial (5VTTY) (not RS232 +-12V adapter/cable)

Problem

Rpi3B+ buster 5V USB hub USB to serial port (/dev/ttyUSB0 9600 N81) does not seem to get the data from the machine.

Answer

Discussions

The OP's project development methodology is sort of incremental/continuous test/prototyping based, and consists of 2 steps:

(1) Read machine test results by WinPC PuTTY, using USB to serial cable.

(2) Read machine test results by Rpi buster, also using USB to serial cable, with terminal commands "cat", and "echo"

Suggestions

I would suggest the OP to do the following:

(1) Write short python test programs instead of bash commands.

(2) Do loop back test for Rpi USB to serial cable setup, to make sure Rpi internal serial hardware and setup is OK.

(3) Put the test machine aside, do the WinPC to Rpi loop back test, to make sure Rpi serial to external wiring are OK.

References

(1) My IR Transceiver (LIRC) Project

These couple of months I have been doing a couple of home automation projects using sensors (temperature, humidity, pressure etc) and actuators (relays and solenoid, and motor etc). I mainly use I2C, SPI, and UART. My basic project development approach is similar to the OP.

The most recent project is IR transceiver. I am using the same approach as the OP.

(a) Use Win10 RealTerm to do loop back test,

(b) Use Rpi UART (on board TxD, and RxD pins, both 3V3 and stepped up 5V0) and two USB to serial cables. All three serial ports can local echo, and also port to port echo.

(c) Win10 RealTerm send/receive to IR transceiver.

(d) Rpi buster python serial send/receive to IR transceiver.

Appendices

(A) Problem with LIRC on Raspberry Pi 3

(B) How many serial ports are on the Pi 3?

(C) Raspberry Pi to Arduino Serial (UART Using GPIO Pins TxD, RdX ) Communication Not Working

(D) Rpi Serial Testing Functions - tlfong01 2019oct03hkt2147

.END of Answer

  • 1
    For those seeking the solution I've found, look in the comments of the original question. The hint I followed here was putting the machine aside - altough I grabbed another identical one haha - and it led me to the solution of the problem. – Emanoel Costa Oct 3 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.