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?

tlfong01
  • 4,665
  • 3
  • 10
  • 24
ledhed2222
  • 141
  • 4
  • 1
    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 Nov 12 '19 at 05:48
  • 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: https://raspberrypi.stackexchange.com/questions/96697/how-many-serial-ports-are-on-the-pi-3. – tlfong01 Nov 12 '19 at 06:54
  • For python programs, I just "import serial". You might might to read the "import serial" statements in my debugged serial loopback python program. "https://penzu.com/public/557ab275. – tlfong01 Nov 12 '19 at 07:05
  • 1
    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: https://imgur.com/gallery/CiMpie3. – tlfong01 Nov 12 '19 at 07:31
  • 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 Nov 12 '19 at 09:01
  • 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) https://electricalfundablog.com/rs-232-signals/, (2) http://www.ethernut.de/en/documents/rs232primer.html. – tlfong01 Nov 12 '19 at 12:40
  • Or you can give me a link to your projector controller and I can check out how many pins are used in the RS232 connector and if you need to short RTS/CTS pins when testing using an terminal emulator of python: https://fr.aliexpress.com/item/33018615483.html?spm=a2g0w.search0306.3.55.31e93877mV3EtT&ws_ab_test=searchweb0_0,searchweb201602_0,searchweb201603_0,ppcSwitch_0&algo_pvid=263bfdc4-8c6d-4cbd-8555-868c647ebbda&algo_expid=263bfdc4-8c6d-4cbd-8555-868c647ebbda-9. – tlfong01 Nov 13 '19 at 00:29
  • And in case your project controller RS232 connector indeed have RTS/CTS pins, you might need to use more flexible terminal emulators other than Rpi CuteCom, eg, Win10 RealTerm which has RTS/CTS settings. You might like to read my cuteCom realTerm picture for more detials: https://imgur.com/gallery/naolpGP. – tlfong01 Nov 13 '19 at 00:48
  • 1
    @tlfong01 lol the most info I can get about the RS232 port on this projector seems to be: "RS-232 serial control9 pin x 1" and that "RS232 DB-9pin" from various data sheets. I can't find a pinout of it anywhere. – ledhed2222 Nov 13 '19 at 03:19
  • @ledhed2222, well, then open the connector case of the serial side of the USB/RS232 DB9 cable and see how many pins are connected. I guess all 9 pins of your high class, expensive, gold plated, connector are connected, (2) Then open the projector controller case and see how many pins are connected. (3) If more than 3 pins are connected, then you need to do some DIY handshake/control flow shorts. :) – tlfong01 Nov 13 '19 at 03:35
  • 1
    but FWIW this is a benq W1070 projector. how would I perform a loopback test directly in linux terminal? I tried screen /dev/ttyUSB0 115200 but I receive no output – ledhed2222 Nov 13 '19 at 03:37
  • But have you read the friendly user guide for the projector? Panasonic Projectors RS-232C Control Specifications PT-D7700/PT-DW7000 PT-D3500 https://eww.pavc.panasonic.co.jp/projector/extranet/main/rs232c/D7KD3K_RS232C.pdf – tlfong01 Nov 13 '19 at 06:03
  • Your RS232 cable is expensive, therefore 90% it (1) is factory tested, (2) has at least 5 pins (including CTS, RTS). You can take the risk and directly connect it to the BenQ projector and your Win10 RealTerm. From RealTerm, send by hand the commands "PON", "POF" and hopefully get replies "PON", POF". After you have tested the projector with manual RealTerm commands, then you can use python to do auto control (Do you really need that?) WARNING, no guarantee nothing won't explode. But I know RS232 hardware is fool proof, ie, expect TxD shorted to RxD etc with no explosion! :) – tlfong01 Nov 13 '19 at 06:16
  • 1
    See answer below :) I was being a dummy. – ledhed2222 Nov 13 '19 at 06:17

2 Answers2

2

OK I've realized what the issue is: mostly that I wasn't familiar enough with the strangeness of RS-232

Thanks @tlfong01 for linking me out to some sites that helped me understand a bit more.

First off, here is a generic description of all BenQ RS232 requirements. Comparing that generic pinout to the one shown in the Amazon product description it did seem like the cable is correctly wired for this port (with a crossover, if I understand this correctly). I figured I would just try and send some commands to the port and see what happened and...yes it works. Turns out that just sending plain strings to the serial port obviously wasn't doing anything, but if I sent a valid command that worked just fine.

So why didn't I just try my original application of this? Turns out on deeper investigation the system user I had configured to access /dev/ttyUSB0 for me did not have permissions to read from that port, which is why it didn't work all along.

Doh!

Thank you all for your help

ledhed2222
  • 141
  • 4
  • Ah, I read your answer after I gave my last comments. About /dev/ttyUSB0 etc, usually you can begin with your terminal command with "sudo", then you should get permission to serial things. For python programming, you can read my long program to just to pay attention to the following: (1) try or etc to end a command. (2) flush buffer before sending/receiving byte strings. Good luck and cheers. :) – tlfong01 Nov 13 '19 at 06:23
  • I read BenQ user guide and found that the power on command is different from Panasonic. It is like this: "*pow=on#". Bye. – tlfong01 Nov 13 '19 at 06:26
  • Please accept your answer with a click on the tick on its left side. This will finish the question and it will not pop up again after months. – Ingo Nov 22 '19 at 10:56
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

  • 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 Nov 12 '19 at 05:45
  • 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 Nov 12 '19 at 05:54
  • 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 Nov 12 '19 at 06:14
  • yes...this is what i've tried prior to this. it doesn't do anything. – ledhed2222 Nov 12 '19 at 19:12
  • commands may be different use proper commands then it works – Tejesh Teju Nov 13 '19 at 05:14