By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,898 Members | 1,198 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,898 IT Pros & Developers. It's quick & easy.

Sending commands to PIC using Pyserial

P: 1
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)\rreport_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
Mar 20 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.