read and write in a serial port with python

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Charlotte1
    New Member
    • Apr 2008
    • 1

    read and write in a serial port with python

    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?
  • gottabogh
    New Member
    • Sep 2009
    • 2

    #2
    Hi Charlotte1,
    I have the same problem! Have you resolved it?

    Comment

    • Glenton
      Recognized Expert Contributor
      • Nov 2008
      • 391

      #3
      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?

      Comment

      • gottabogh
        New Member
        • Sep 2009
        • 2

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

        Comment

        Working...