Shop OBEX P1 Docs P2 Docs Learn Events
Linux Serial port — Parallax Forums

Linux Serial port

ZetsuZetsu Posts: 186
edited 2013-01-06 00:45 in General Discussion
Having a little bit of an issue trying to use stty to set up a serial port to communicate to a prop.

I issued stty -F /dev/ttyS0 9600
I have a cable between the serial port on this computer and my laptop ( via usb to serial adapter on laptop side )
On the Linux machine I can then echo "1" > /dev/ttyS0
except on the laptop I get nothing in the Terminal ;x
Plugging my prop in doesn't work as expected too.
Is there something else I am forgetting to do ??

Comments

  • FranklinFranklin Posts: 4,747
    edited 2013-01-04 07:58
    On the Linux machine I can then echo "1" > /dev/ttyS0
    except on the laptop I get nothing in the Terminal ;x
    What port are you listening to on the laptop?
  • Coder96Coder96 Posts: 42
    edited 2013-01-04 08:18
    On the various Linux distros Ive used the USB to serial usually show up as /dev/ttyUSB#

    If thats not the problem. Do you have a known working different device to test with?
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 08:21
    Com6 it shows prolific USB Serial Controler...

    I used an Rs-232 breakout box in between and I can see the server is sending the info, but at the laptop with PST I cant send or receive according to the breakout box ??


    Expanded background:

    I am going to have a linux server with about 30 serial ports ( via a USB to Serial header called 'rocket port')
    each serial port will connect to a different propeller which will preform specific functions depending on what it receives from its respective serial port.

    Currently I am just testing this is going to work so, I have a single serial port on my linux box connected to a breakout box ( just lights up leds showing that signals are happening ). Which then is connected to my USB to Serial converter ( this works no problems via windows to propeller via a serial port)....
    which plugs into the laptop.
    Now I can't seem to communicate from the laptop to the server ( send or receive ).
    What I tried next was, I then connected via serial port on Linux box1 to my rs232-breakout box, to a serial port on another linux box...
    Same situation, one can send the other cant send or receive ;x

    Frustration ;x
  • SRLMSRLM Posts: 5,045
    edited 2013-01-04 09:14
    You mention PST in post 4, but PST won't run on Linux. I assume you mean that you're using something like cutecom, minicom, or picocom?

    If you're on Ubuntu, then you might need to run the following command after you plug in the USB to serial adapter:
    sudo chmod 666 /dev/ttyUSB*
    

    I'd recommend starting with a USB to Serial device that has the RX line connected directly to the TX line via a resistor in order to form a loopback. Then open up cutecom and try sending a character. You should see it appear.

    After you plug in your USB to serial device, what is the output of the following command:
    lsusb; ls /dev/
    
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 09:16
    No I am running PST on the laptop... Just to see if anything comes down the serial port... ( I.E I expect to see a '1' after i run the command on the next line)
    The linux box I am just doing stty -F /dev/ttyS0 9600 ; echo "1" > /dev/ttyS0

    On the laptop I get nothing ;x

    Linux server ====> Rs-232 breakoutbox ( this is just for testing) =====> Laptop running windows and PST


    Would it help if I uploaded some pictures ??
  • SRLMSRLM Posts: 5,045
    edited 2013-01-04 10:18
    I think you should do the loopback on the Linux box.

    1) Are you using an FTDI chip (USB), or connecting directly to the RS232 port?
    2) Why are you using the stty and echo commands instead of a com program?
    3) What flavor of Linux are you using?
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 10:28
    In reverse order ;x
    3.) SLES linux ( its the enterprise version of open suse)
    2) because I want a shell script to do this ( shell script will be called from a Informix application, it will pass some values, the shell script will then preform the serial communications, in the Genero/Informix language ( i dont get a choice) there is no native rs232 support, or anything that would let me get there.
    1.) Currently its Just from db9 connecter on linux server to a trend-net usb to serial converter.

    Ill take pictures in about 30 minutes and upload them, I am not very good at explaining myself I guess ;x
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 10:50
    IMAG0878.jpg

    This is the server rack /shrug

    IMAG0874.jpg

    These are a bunch of serial ports coming of the back of the server, the one I am pointing at is the one I am currently using.

    IMAG0875.jpg

    The serial cable I was pointing at in the last image, plugs into this... The other end ( thats currently unplugged), goes into this
    IMAG0876.jpg

    This then is plugging into my laptop ( running PST )
    IMAG0877.jpg


    The laptop, and the Rs-232 to USB converter will be replaced by this ( but on a pcb this is just for testing right now)

    IMAG0879.jpg




    Ok now for the best explanation I can give:

    We have a programming language that we lease its called Genero ( it use to be IBMS Informix ), This language is more like cobal then anything. It is very business application logic tailored, thus no hardware communications support. My Seniors want me to keep this project in that native language, and a shell script ( they dont want to have to maintain a C script or anything if I were to leave the company...)

    So, What happens is I have created/written a time clock it runs on a thin client as can be seen here...
    IMAG0880.jpg

    (time clock processes actualy takes place on server but thats getting kinda out of the scope)
    When ever someone sounds a firealarm from this terminal, or the time gets to a select point and a break alarm is needed,
    the server then will send a Numerical value out a serial port where my prop will be to capture said value and sound the correct alarm...


    Picture 3 is just a test device to prove there was data actually being sent from the server.
    1024 x 613 - 80K
    1024 x 613 - 58K
    1024 x 613 - 64K
    1024 x 1710 - 95K
    1024 x 613 - 54K
    1024 x 613 - 70K
    1024 x 613 - 44K
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-01-04 11:23
    http://forums.opensuse.org/archives/novell-archives/306423-how-use-serial-port-suse.html

    From what you say, these RS-232 ports will be generic -- without USB conversion. But your laptop is currently using a RS232 to USB for benchwork. Can you loopback that portion to confirm correct opereation and loopback the other portion to confirm correct operation. Just one loop-back is verifying only that one side might be good.

    Above is a SUSE forum for serial port problems. I use Ubuntu, so I am not 100% that an Ubuntu solution would help. The main thing is that the serial port in Linux must be mounted properly to work.

    I suspect that the 'echo' is not a true loopback. It just echos your keyboard on your video screen. Use hardwire loopbacks for testing the ports.

    It also could be that you want ttyS00, not ttyS0. Take a good look at how the serial ports are listed in the /dev directory. Mine in Ubuntu are listed as ttyS0, ttyS1, and so on. So this may be a 'non-issue'
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 11:39
    Yeah, its actualy using /dev/ttyUSB14 going from the picture I sent, I tried to use the native ttyS0 serial port thats on the box first and had no luck, then I moved over to trying to do it from our Serial block as shown in the pictures.

    The thing is, this all works fine if its done under windows... and just typing in the control number into PST, my prop lights up appropriately ;x
    prop plugged into linux no lights ;x
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-01-04 12:01
    The primary problem is that Linux is completely different in how it attaches a serial port. You probably want it to be rahter user friendly and mindless as that is what Windows does for you.


    Linux requires learning a different point of view.

    EVERYTHING in Linux is mounted as a file. And there are basically only two modes of transport - block devices and character devices. A hard disk does block tranfers, a serial port does character transfers.

    Stty certainly seems to be the right tool to establish a Linux serial port, but if you are using a ttyUSB## serial port, there is an added level of complexity due to the USB port.

    http://unixhelp.ed.ac.uk/CGI/man-cgi?stty

    If you can uses something higher level in the Linux environment to reach your laptop first, this might be simpler. Try using Minicom or PuTTY in Linux. Both will allow you to select a serial port such at ttyS0 or ttyUSB0. Once you are sure that works, it may be easier to resolve the stty problems.
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 12:09
    minicom and putty dont work correctly with this.. as soon as i grab the line, I cant do anything else except exit the client, they dont allow me to type anything...
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-01-04 12:16
  • Coder96Coder96 Posts: 42
    edited 2013-01-04 12:57
    When you did your Windows to Linux testing. Did you have a null modem setup or did just go with a strait cable?

    Have you tried useing in the prop plug on the Linux box yet? I use opensuse at home and have had no problem. I used bst and putty with out a problem.
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 13:00
    If you look at picture 3 in my post you will see a device with a bunch of leds...
    when I do my echo command those leds light up showing that Yes Serial comms is infact happening, although the prop doesnt do anything ....
  • Coder96Coder96 Posts: 42
    edited 2013-01-04 13:14
    Ok on the prop are you using any interface chip for the rs232 communications?
  • ZetsuZetsu Posts: 186
    edited 2013-01-04 14:26
    Well I figured it out ;x

    Hooked up o scope All my signals are going logic lows instead of logic highs. Very strange, my windows computer worked fine, but I had to reverse the ground and Rx pin when I went to linux ;x
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-01-05 05:52
    Happy to hear you resolved the problem. You might need to check your Propeller i/o pins for damage from reversed polarity of device that the Rx line was connected to. If you are lucky, your RS232 to USB is not outputing below gnd - but you never know for sure without testing.
  • ZetsuZetsu Posts: 186
    edited 2013-01-05 13:54
    Happy to hear you resolved the problem. You might need to check your Propeller i/o pins for damage from reversed polarity of device that the Rx line was connected to. If you are lucky, your RS232 to USB is not outputing below gnd - but you never know for sure without testing.

    Can you expand on that a little more ? I am not quite sure how it would generate enough current or voltage to harm the prop io pin ? ( I do have a voltage divider in the circuit for the Rx line )
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2013-01-06 00:45
    Sorry to take so long to respond.

    Very simply, the Propeller i/o is designed for a range from 0 volts to 3.3 volts. Your RS233 to USB device may have as much as a -12 volt output, but may be something like -3.3 volts. If you are lucky, it doesn't even go negative.

    The Propeller i/o was never designed to go safely go below 0 volts. For RS-232, either some transistors or a level shifter chip is suppose to be between the Propeller and the real world.
Sign In or Register to comment.