>>> uart.any()
False
>>> if uart.any==False:
... print("FALSCH")
...
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NotImplementedError: equality for 'bound_method' and 'bool' types not yet implemented
>>>
NotImplementedError uart.any()
-
- Posts: 288
- Joined: Sun May 04, 2014 8:54 am
uart.readline()
I got the following problem:
I can send commands to the modem, and get answers back.
But the answer is in a "binary" format like b´text´
How can I convert it to normal text without the CR and other formating characters?
thank you
>>> uart.write("at\r\r\n")
5
>>> while uart.any()==True:
... uart.readall()
...
b'\r\nOK\r\n'
>>>
I can send commands to the modem, and get answers back.
But the answer is in a "binary" format like b´text´
How can I convert it to normal text without the CR and other formating characters?
thank you
>>> uart.write("at\r\r\n")
5
>>> while uart.any()==True:
... uart.readall()
...
b'\r\nOK\r\n'
>>>
Re: NotImplementedError uart.any()
Yes, looks like you missed the parenthesis! But now the bug comparing bound_method to bool is fixed as well.
Re: uart.readline()
First, note that (if you haven't already) you probably want to init the UART with an inter-char timeout, like:eduardo wrote:I got the following problem:
I can send commands to the modem, and get answers back.
But the answer is in a "binary" format like b´text´
How can I convert it to normal text without the CR and other formating characters?
thank you
>>> uart.write("at\r\r\n")
5
>>> while uart.any()==True:
... uart.readall()
...
b'\r\nOK\r\n'
>>>
Code: Select all
uart = pyb.UART(1, 9600, timeout_char=1)
To get rid of the newlines, use the .strip() method: text.strip()
To convert to a string, do: str(b'123', 'utf8')
These are all normal Python programming techniques.