Python serial port
location: ubuntuforums.com - date: August 9, 2009
How can i use usb-serial converter to perform serial operations using python.pySerial does not mention it ,i guess?And how can we view our ports in linux as we do using device manager in Windows?
Python how to send bytes to serial port?
location: ubuntuforums.com - date: January 25, 2012
hello, i trying to send bytes over serial port, but there is some problems,
works fine, but when i try to do it in function, there is no bytes are sended, only ascii codes
import serial, string
#usage write_port("06 10 46 46")
dataB = ""
data = data.split(' ')
for i in range(len(data)):
data[i] = r"\x" + data[i] # raw add "\x" so line is \x06\x10\x46\x46
dataB = "".join(data)
ser.write( dataB )
print "Python 2.7\n\n"
ser = serial.Serial('/dev/usb/tts/2', 115200, timeout=1)
print "write bytes.."
write_port("06 10 46 46")
my function convert "06 10 46 46" to "\x06\x10\x46\x46", so i expect it should works like
ser.write("\x06\x10\x46\x46"), but it does not - it send like a string without transform "\x" symbols
Ubuntu 12.04 using serial port with python 2.7
location: linuxquestions.com - date: August 22, 2014
Using the Serial Terminal Program, with the same port, I can send data to the micro and it works as expected. But, when attempting to use a Python script and pyserial module, no data is
transmitted to the micro. This verified using a scope on the micro's receive data RS-232 line. Using the
Serial Teminal Program, the micro displays the correct information and also is observed at the receive data line as just mentioned.
I can not figure out what else must be done to allow data to be transmitted using the python script.
The script is based on example(s) from different online searches and the pyserial web site.
I am using Ubuntu 12.04 and python 2.73.
ser = serial.Serial('/dev/ttyUSB0',9600, timeout =1)
print ser.portstr # check which port was really used
#### ser.portstr prints /dev/ttyUSB0 ####
#Note: neither ser.write sends data to module.
Linux and Python: autodetect Arduino serial port
location: linuxexchange.com - date: May 7, 2013
I have a problem automagically detecting my Arduino's serial port in Python, using Mac/Linux.
I know a working shell command to find the port; because Arduino serial ports almost always begin with tty.usbmodem, you can find the serial port with ls /dev | grep tty.usbmodem which should return something like tty.usbmodem262141.
However, I'm confused on how to call this shell command from my Python code. I've tried this:
p = "/dev/" + str(subprocess.Popen('ls /dev | grep tty.usbmodem', shell=True).stdout)
Which should make p become /dev/tty.usbmodem262141.
However, at the moment I get /dev/None.
How can I modify my shell script call to return the right string? I've tried to use several commands to call shell scripts, but none have worked.
How to write on serial port in python that ttyUSB0 will be interpreted commands?
location: linuxexchange.com - date: January 1, 1970
I have raspberry PI B+ with connected Telegesis ZigBee module(ETRX3 USB sticks) via USB. Using commands:
debian:~# stty -F /dev/ttyUSB0 -raw ispeed 19200 ospeed 19200
debian:~# cat < /dev/ttyUSB0 &
debian:~# echo "ATI" > /dev/ttyUSB0
the ZigBee module executed ATI command and I can see correct output:
The same thing I want to do with python script. I was written python script with code:
# based on tutorials:
import serial, time
SERIALPORT = "/dev/ttyUSB0"
BAUDRATE = 19200
ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.bytesize = serial.EIGHTBITS #number of bits per bytes
ser.parity = serial.PARITY_NONE #set parity check: no parity
ser.stopbits = serial.STOPBITS_ONE #number of stop bits
#ser.timeout = No
Serial Port Access Denied using open("/dev/ttyS0", ORDWR | ONOCTTY | ONDELAY);
location: linuxquestions.com - date: February 10, 2009
I am creating a program that opens a serial port for communication but it gets denied when I open it
I have installed a board that has two ports and have verified they are working by using the terminal:
dmesg | grep tty
[SOLVED] Serial terminal connected to USB Serial Port on Ubuntu 12.04
- date: July 14, 2013
I am trying to get a serial terminal to work with my Ubuntu 12.04 computer. I was able to get text displayed and log in, but it isn't displaying correctly. Here is how I have it set up:
exec /sbin/agetty -L 9600 ttyUSB0 vt100
I have a Wyse 60 on the other end, configured to emulate a vt100.
When I type a command that gives a lot of output, instead of scrolling up, it continues from the top, for example:
----- output here
If the output is particularly long, the prompt might reappear in the middle of the screen.
Serial port I/O with Bash?
location: linuxquestions.com - date: June 3, 2009
I am attempting to write a script to communicate with a photovoltaic inverter via a serial port on a Damn Small Linux PC. The inverter reads/writes binary data, and I've figured out how to handle that via od and awk, but I can't seem to actually communicate with the inverter. I know it works 'cause if I reboot my DSL PC to WinXP, I have a VBScript that works just fine... so communication and hardware is not the issue. Please take a look at the following and let me know if you have any suggestions. Right now, whenever I try to read from /dev/ttyS0, the script just hangs. The lines below that start with ####### are all my attempts so far, and they all hang. The last ###### is what I expect to get back from the inverter.
Thanks in advance,
stty -F /dev/ttyS0 raw ispeed 2400 ospeed 2400 cs8 -ignpar -cstopb -echo
#Get total watt-hours generated
echo $'\x80\x80\x80\x01\x01\x01\x11\x14' > /dev/ttyS0
######read -n 1 InStr < /dev/
Python; One port, multiple services
location: ubuntuforums.com - date: June 9, 2010
Is it possible to have a python socket, listening on a port, which receives a connection (e.g HTTP or SSH) , scans the data, and decides which protocol its on, then redirects it to another socket connected to localhost with the correct port.
For example: i SSH into the listening socket on (e.g) port 2280, it realises that it's SSH traffic and then sends it to a socket connected to localhost port 22; I then browse to the same port, it sees it as HTTP traffic, then redirects it to localhost port 80
I am basically asking if this is possible, then i could use it to get into my LAN through only one port, but with lots of services
Writing to serial port
location: ubuntuforums.com - date: July 18, 2011
I'm new to linux, running ubuntu 11.04 64bit, and I have an external hardware device* I'd like to communicate with through a serial port connection (through a usb/serial converter) using c code. However, it seems like I'm having trouble writing to it. The code I'm using was downloaded from here (./optec/setifw.c and ./optec/getifw.c) and is written specifically for what I want it to do.
The first time I tried the code (without modifying anything), the code seemed to hang. By adding in some printf statements I found that the problem was in opening the connection. I changed the port from /dev/ttyUSB0 to /dev/ttyS0 and fixed that problem, but had problems writing (which is what this post is asking about).
I tried again a few days later, and after some fiddling I got the programs to work pretty much as intended, but oddly enough the fresh download (the one I talk about above which would hang) would also work.
I tried again the next day, and I was back to my original problem (I alwa
Page: 1 2 3 4 5 6 7 8 9 10