Connecting Tech Pros Worldwide Help | Site Map

read and write in a serial port with python

Newbie
 
Join Date: Apr 2008
Location: Paris
Posts: 1
#1: Apr 10 '08
How can I read and write a radio connected to the computer with a serial port with python, the same way a hyperterminal does ?
I wrote this:

from Tkinter import *
import serial
se = serial.Serial()
se.baudrate = 9600
se.bytesize = 8
se.parities = 0
se.stopbits = 1
se.xonxoff = 0
se.rtscts = 0
se.timeout = 1
se.port = 0
print se.portstr
print se
se.close()

It seems to work, but when I try to communicate using
se.write('at')
se.readl([20])

I don't receive the expected answer, and it just reads what I wrote.

Someone can help me?
Newbie
 
Join Date: Sep 2009
Posts: 2
#2: Sep 25 '09

re: read and write in a serial port with python


Hi Charlotte1,
I have the same problem! Have you resolved it?
Member
 
Join Date: Nov 2008
Posts: 49
#3: Sep 29 '09

re: read and write in a serial port with python


Hi

I've used pySerial successfully in the past, though not with a radio. I found it to work pretty well in general, or at least the python part! Can you give us some more details? For example, what was the print out from the first bit of code you gave? Is there a particular reason for the parameters you choose there? Can you give us the exact print out for the second piece of code, and what you were expecting?
Newbie
 
Join Date: Sep 2009
Posts: 2
#4: Sep 30 '09

re: read and write in a serial port with python


Hi!
I have resolved the problem. there was an error into the schematic of my board.
thanks.
Reply