LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware > Linux - Embedded & Single-board computer
User Name
Password
Linux - Embedded & Single-board computer This forum is for the discussion of Linux on both embedded devices and single-board computers (such as the Raspberry Pi, BeagleBoard and PandaBoard). Discussions involving Arduino, plug computers and other micro-controller like devices are also welcome.

Notices

Reply
 
Search this Thread
Old 07-04-2009, 05:20 PM   #1
searchingfortao
LQ Newbie
 
Registered: May 2009
Location: Vancouver, Canada
Distribution: Gentoo
Posts: 10

Rep: Reputation: 0
Question Solved: Reading ASCII PLC data from a usb/serial connection


Hi there, I've been commissioned to write an embedded Linux component of a larger, more complicated machine and I'm having real trouble reading data from an Automation Direct "Click" PLC.

The PLC was programmed by someone-not-me to send an ASCII string over a serial connection every time a button was pushed. My code would then read said data from the serial connection and do a bunch of interesting stuff.

The PLC is doing its job, because if I connect a Windows laptop to the serial-to-usb cable and connect to it with Putty, I see the aforementioned output.

The trouble comes when I try this with Linux. Using the very same settings are were used on the Windows machine, I only *sometimes* see the output. I'm at the end of my rope here and I'm coming up empty.

I've tried using minicom, which insists that I'm always "Offline", and I've written a simple Python script to use the same settings with the same results. The settings I'm using are:

Code:
ser = serial.Serial(
  "/dev/ttyUSB0",
  baudrate=38400,
  parity=serial.PARITY_ODD,
  stopbits=serial.STOPBITS_ONE,
  bytesize=serial.EIGHTBITS,
  rtscts=0,
  xonxoff=1,
  timeout=None
)
Or in other words 38400 801. I *believe* that I have the rtscts and xonxoff settings right but I really can't be sure.

In terms of modules, I've made sure that there are no modules loaded, and then I run the following:

Code:
modprobe usbserial vendor=0x067b product=0x2303
modprobe pl2303
I got the vendor and product codes from dmesg when the PLC was connected via USB the first time.

So, that's all I have... please tell me that someone out there understands what I'm doing wrong?

Last edited by searchingfortao; 07-05-2009 at 06:06 PM. Reason: Solved :-)
 
Old 07-05-2009, 06:05 PM   #2
searchingfortao
LQ Newbie
 
Registered: May 2009
Location: Vancouver, Canada
Distribution: Gentoo
Posts: 10

Original Poster
Rep: Reputation: 0
Lightbulb Figured it out

Turns out that you don't always need to pass arguments to usbserial as I have above. I thought you did since usbserial was being used by another device on this machine and that one did need the extra arguments. Providing them in this case seems to just have broken it :-(

To make it work, all I had to do was make sure that no related modules were loaded and then run:
Code:
modprobe pl2303
. That loaded usbserial and everything Just Worked.
 
  


Reply

Tags
serial, usb


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Serial driver problem on reading data from device archieval Programming 2 07-22-2008 11:42 PM
Using USB<->Serial and serial gender changer to transmit data between computers JoeyAdams Linux - Hardware 4 04-17-2008 05:15 AM
help reading data from a serial port skydemon Linux - General 1 08-10-2006 08:48 AM
reading data from a serial port mchitrakar Linux - Networking 3 12-04-2004 01:24 PM
Problems with reading back serial binary data esi-eric Linux - Software 14 08-06-2004 01:48 PM


All times are GMT -5. The time now is 10:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration