I am writing a class that increases the serial.Serial class of pySerial, and I < Trouble using the code> readline () function
I am able to reproduce this problem:
import serial class A (serial. Serial): Def Read (self): Return super (A, Self). Redline () A = A () a.read () When I run this code, I get a traceback:
traceback (most recent Only call in the final): File "& lt; stdin>", line 1, & lt; Module & gt; Type the file "", type 3 in TypeError: Read () takes exactly 1 argument (2 given) I know I can remember something here Has been there. I hope it passes only one argument ( In addition, I tried to use This makes sense, suppose PySerial's self). Where does the second argument come from? inspect.getcallargs (a.read) to understand that second argument, but I found this traceback then: Traceback (most recent call final): File "& lt; stdin>", line 1, & lt; Module & gt; File "/usr/lib/python2.7/inspect.py", line 900, getcallargs in args, varargs, varkw, defaults = getargspec (func) file "/usr/lib/python2.7/inspect.py", line 815, getargspec raise typeError ('{! R} is not a Python function.' Format (func) TypeError: & lt; An underlying method of the object at 0xecf3d0 readline & gt; There is no python function readline () is a basic C function or system call. Do I believe that why this happens?
serial. Read () accepts an optional argument, size , whose default value is 1. It is possible to use the read () method to call this serial. Publication () You have overridden read () , but you have not given your version size argument, so you get an error when readline () Code read () calls.
When you fix the error, you might have a problem with recursion; I read () method to readline () .
No comments:
Post a Comment