Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #45041
| References | <1368113753.5157.YahooMailClassic@web190506.mail.sg3.yahoo.com> |
|---|---|
| Date | 2013-05-10 01:49 +1000 |
| Subject | Re: Urgent:Serial Port Read/Write |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1495.1368114548.3114.python-list@python.org> (permalink) |
On Fri, May 10, 2013 at 1:35 AM, chandan kumar <chandan_psr@yahoo.co.in> wrote: > > Hi all, > I'm new to python and facing issue using serial in python.I'm facing the below error > > ser.write(port,command) > NameError: global name 'ser' is not defined > > Please find the attached script and let me know whats wrong in my script and also how can i read data from serial port for the same script. You're assigning to 'ser' inside OpenPort(), but then trying to use it in WriteSerialData(). You'll need to declare 'global ser' in OpenPort to make this work. Alternatively, you may want to cut down on the number of functions you have, since they're called in only one place anyway and have to share state. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Urgent:Serial Port Read/Write Chris Angelico <rosuav@gmail.com> - 2013-05-10 01:49 +1000
csiph-web