Page 1 of 1

NotImplementedError uart.any()

Posted: Wed Jan 14, 2015 9:02 pm
by eduardo
>>> 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
>>>

Re: NotImplementedError uart.any()

Posted: Wed Jan 14, 2015 9:11 pm
by Turbinenreiter
You forget the braces after any.

This should work.

Code: Select all

if uart.any()==False:

uart.readline()

Posted: Wed Jan 14, 2015 9:55 pm
by eduardo
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'
>>>

Re: NotImplementedError uart.any()

Posted: Wed Jan 14, 2015 10:15 pm
by Damien
Yes, looks like you missed the parenthesis! But now the bug comparing bound_method to bool is fixed as well.

Re: uart.readline()

Posted: Wed Jan 14, 2015 10:20 pm
by Damien
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'
>>>
First, note that (if you haven't already) you probably want to init the UART with an inter-char timeout, like:

Code: Select all

uart = pyb.UART(1, 9600, timeout_char=1)
This will make sure that when you read it waits a little between chars, giving you a longer string than just 1 character.

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.