On Jun 11, 2010, at 8:08 AM, Dan Ackerman wrote:
> Hello,
> I need to be able to send some information through my computer's serial port. 
> I am using python version 2.6, the pyserial 1.21 module, and the pywin 
> module. My code seems to be sending info somewhere, because any print 
> statement I add after the import serial command doesn't show up in my 
> terminal window. However, the device connected to my serial port doesn't seem 
> to be registering any received information. I want to send the string "FREQ 
> 720 MHz."
> 
> If anyone could help me out with this code, it would be greatly appreciated:
> 
> import serial
> ser = serial.Serial(0) #if port has specific name, use: ser = 
> serial.Serial('portName', 19200, timeout=0)
> print ser.portstr #should tell you what specific port was used
> ser.write('FREQ 720 MHz')
> ser.close()

Dan,

In my experience connecting to a serial port does not cause prints to stop 
sending to stdout.  My guess is that ser.portstr is an empty string or None.  
Try printing this instead to test that theory:

print 'portstr: "%s"' % (ser.portstr,)

My bet is you get: portstr: ""

Secondly, what COM port are you connecting to?  If, for example, you're 
connecting to COM1 and the baud rate is 19200, try this:

ser = serial.Serial('COM1', 19200, timeout=0)

Finally, highly dependent on the device you are sending data to, maybe you're 
missing a newline or something at the end of the string you are sending?

ser.write('FREQ 720 MHz\n')

Good luck,
-Roberto.
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to