Pyserial again
Peter Hansen
peter at engcorp.com
Tue Mar 7 13:15:52 EST 2006
Richie Hindle wrote:
> A piece of that code has been chopped off by someone's newsreader - it's the
> body of a method, and ser.readline() is the last line of that method.
I'm pretty sure that's true. Technically, however, it's still a guess,
though at this point one I'm sure we're all comfortable making.
That's why I asked about code *after* that last line. He replied there
was no code before, but I think we can be generous in interpreting that
(through the language barrier) as "no code after".
Unfortunately, at this point we're getting into application design
issues unless and until Luca can learn enough Python and other
programming stuff to understand why "ser" is "going out of scope"
because it's a "local variable" and is then being "garbage collected".
(Luca, if you're reading, you really either have to just do exactly what
Grant tells you :-), or learn about these issues enough to understand.
If you don't know about object construction and destruction, memory
allocation and garbage collection, the concept of "scope" and the
difference between things like local variables, global variables, and
attributes, we're going to continue to have an exceptionally difficult
and frustrating time helping you. Serial ports aren't trivial, and
combining them with a GUI program written by a rookie is a pretty big
order. You can learn enough to figure this out, but it will be lots of
work and a challenge. If you're up to it, please go read that "how to
ask smart questions" page thoroughly if you haven't already, realizing
that we're not trying to be rude by asking you to read it, and pay
attention when someone asks you to try out different things, such as
posting a small program that reproduces the problem, or post all the
code rather than just snippets. Good luck.)
-Peter
More information about the Python-list
mailing list