Uncategorized

RS serial connector problem

Asked 
Active today
Viewed 26 times
2

I know there are similar posts on this topic, but I’ve scoured them all and haven’t been able to figure this out. I’m trying to control my projector via a R232 port. I have a USB to R232 cable, specifically this one.

That’s using the PL2303 chipset for RS232. I can’t seem to get it to register anything on my Pi.

pi@raspberrypi:~ $ dmesg | grep tty
[    0.000000] Kernel command line: coherent_pool=1M 8250.nr_uarts=1 bcm2708_fb.fbwidth=656 bcm2708_fb.fbheight=416 bcm2708_fb.fbswap=1 smsc95xx.macaddr=B8:27:EB:25:6C:54 vc_mem.mem_base=0x1ec00000 vc_mem.mem_size=0x20000000  dwc_otg.lpm_enable=0 console=tty1 root=PARTUUID=f991b5bc-02 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
[    0.001276] console [tty1] enabled
[    1.062493] 20201000.serial: ttyAMA0 at MMIO 0x20201000 (irq = 81, base_baud = 0) is a PL011 rev2
[    1.070613] 20215040.serial: ttyS0 at MMIO 0x0 (irq = 53, base_baud = 31250000) is a 16550
[   16.242115] usb 1-1: pl2303 converter now attached to ttyUSB0

I’ve copied some python scripts to write to ttyS0 and read from ttyUSB0. I’m apparently able to write to ttyS0 but cannot read anything from ttyUSB0.

Even if I do

echo "hi" > /dev/ttyUSB0
cat /dev/ttyUSB0

I get nothing.

I have serial login disabled.

Is there a way I can determine if, for example, this device is defective?

 New contributor
  • lsusb will show devices connected to USB. lsusb -v will show detail.check /dev/tty* before and after inserting the device, although not all devices identify as tty. Forget /dev/ttyS0 and /dev/ttyAMA0 which are Pi GPIO ports. – Milliways 7 hours ago
  • Hi @ledhed2222. I found PL2303 based adapter good, detected by Rpi’s built in drivers. You might like to read my answer to the following question for more details: raspberrypi.stackexchange.com/questions/96697/…. – tlfong01 6 hours ago   
  • For python programs, I just “import serial”. You might might to read the “import serial” statements in my debugged serial loopback python program. “penzu.com/public/557ab275. – tlfong01 5 hours ago   
  • Actually you don’t need any python program to do loopback tests You can use Rpi miniCom, miniTerm, puTTY, cuteCom etc. I recommend Rpi cuteCom. For Win10, I recommend RealTerm. You might like to see my Rpi USB Serial 0 cuteCom loopback test results: imgur.com/gallery/CiMpie3. – tlfong01 5 hours ago   
  • Question: (1) Is you projector +-12VDC real RS232, or fake RS232, ie Serial TTL +5V 0V? (2) Have you checked your project connector that it uses more pins than the usual Gnd, TxD, and RxD? (2) Your USB RS232 cable seem using industrial standard DB9 connector. You might like to look at the web link ad spec and see their pinouts not that compatible to us hobbyists. (3) Have you tried just using Win10 RealTerm? I think a quick and dirty way to start checking out the cable just (a) Win10 RealTerm Loop back, (b) Win10RealTerm direct connect to projector and check the “AT”, “OK” commands. – tlfong01 3 hours ago   
  • One possible reason that you get nothing echoing back is that your projector driver is using not the simple 3 pin direct, but 5 or 9 pins. In this case, then you need to do the handshake shorts or flow control shorts, as described in the following user guides: (1) electricalfundablog.com/rs-232-signals, (2) ethernut.de/en/documents/rs232primer.html. – tlfong01 20 mins ago   

1

if you want to send the data from usb to rs232 in pi. Go for programming language. and it is easy to do it in python. 
import pyserial
ser = serial.Serial('/dev/ttyUSB0', baudrate=19200, parity=serial.PARITY_NONE, stopbits=1, timeout=5)
ser.write(b'enter your command') #for write
ser.read(b'enter your command') #for read

 New contributor
  • 1
    I’ve written a python script to test this as well. It writes to /dev/ttyS0 and then reads from it after a second. The result is the same, because the issue is more fundamental. If I can’t echo and cat from this port I don’t see how this would work. – ledhed2222 7 hours ago
  • 1
    First check which usb port occupied by using this command cd /dev/ after insert usb and check whether it is occupied usb0 or usb1. After that install pyserial package. later i will send the code – Tejesh Teju 7 hours ago
  • 1
    It’s /dev/ttyUSB0 (as you can see above from the output of dmesg). The script I’m using uses pyserial. Feel free to send your code but I don’t see how it will result in anything different 🙂 – ledhed2222 6 hours ago

Categories: Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: