Sending commands to PIC using Pyserial

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kineta
    New Member
    • Mar 2008
    • 1

    Sending commands to PIC using Pyserial

    Hello all,

    I am attempting to send commands to the firmware on my PIC18F4550 (usb port) microcontroller using Pyserial. If I open Hyperterminal, I can send the following commands and it works beautifully:

    set_dac(0,1500, 0)
    report_smu

    Then I went to Python with Pyserial, and nothing happens. I get no errors, but at the same time the board does not respond to the input, and python prints no output.

    Here is my code:


    import serial

    ser = serial.Serial(7 )
    ser.timeout = 2
    ser.write('set_ dac(0,1500,0)\r report_smu(1)\r ')
    reply = ser.read(7)
    print reply
    ser.close()


    7 = COM8
    The timeout I put in just so that it wouldn't sit there forever. I should be reading something in this time.
    I only included \r because this is all the firmware looks for. But just for trial and error sake, I tried \n , \n\r , and \r\n just to be sure.

    The electronics on the board do not matter -- as I said, it works with Hyperterminal. There seems to be an issue with my code.

    I receive no errors when I execute my code, either.

    I appreciate any insight to this problem whatsoever! :)

    Thanks,
    Kineta
Working...