Python Forum
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I need help with pySerial
#6
I'm using COM32 (it's an Arduino). I found some code on https://petrimaki.com/2013/04/28/reading...windows-7/ which I can't get to work either:

import serial
import time
ser = serial.Serial('COM32', 9600, timeout=0)
 
while 1:
 try:
  print ser.readline()
  time.sleep(1)
 except ser.SerialTimeoutException:
  print('Data could not be read')
  time.sleep(1)
First I get a syntax error in the print statement, because parentheses are lacking, so I add those. Then I get the error "serin = ser.read()
NameError: name 'ser' is not defined"
Reply


Messages In This Thread
I need help with pySerial - by oz1sej - Apr-12-2017, 05:56 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 06:12 AM
RE: I need help with pySerial - by buran - Apr-12-2017, 06:13 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 07:14 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 07:21 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 07:41 AM
RE: I need help with pySerial - by j.crater - Apr-12-2017, 07:45 AM
RE: I need help with pySerial - by oz1sej - Apr-12-2017, 09:53 AM
RE: I need help with pySerial - by j.crater - Apr-13-2017, 05:20 AM
RE: I need help with pySerial - by Larz60+ - Apr-13-2017, 06:12 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020