Python Forum
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
serial out_waiting
#1
Hi All,

I'm very new to Python and working on a Raspberry Pi project to send data out of the UART.  It all works fine when sending less than 8 characters at a time.  Sending more characters with the serial.write command causes the only the first 8 characters to be sent and the remaining are lost.  I'm assuming the UART output buffer is only 8 bytes long.  The pySerial documentation says the 'serial.out_waiting' property will show the number of characters in the output buffer.  Unfortunately Python 2.7.9 and 3.4.2 does not recognize this property.  Here is my code:

ser=serial.Serial(...)
ser.write('ABC')
num=1
while (num < 1):
    num=ser.out_waiting()           #error occurs here
ser.write('DEF')
The exact error message says "Attribute Error: 'Serial' object has no attribute 'outWaiting'

Does anybody have any ideas?  Thanks!
Kevin
Reply
#2
If the error is correct

Error:
"Attribute Error: 'Serial' object has no attribute 'outWaiting'
it's out_waiting, not outWaiting
Reply
#3
Ops, reading once again the docs, it says

Quote:Changed in version 3.0: changed to property from outWaiting()

try

num=ser.out_waiting # i.e. property, not method
Reply
#4
I tried 'out_waiting' and 'out_Waiting' (not sure if it's case sensitive). Still the same error.

Thanks, Kevin
Reply
#5
(May-05-2017, 04:44 PM)kevinva Wrote: not sure if it's case sensitive
definitely case sensitive

did you try it as property, not method (as it is in your original post)?
Reply
#6
Thanks buran for the replies. I tried num=ser.out_waiting as a property. Still get the exact same error message.

Thanks, Kevin
Reply
#7
It is:
serial.Serial.out_waiting
in pyserial 3.0, which version are you using?

Please post the error code in it's entirety between the "Error" tags
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#8
Thanks for the tip sparks_alot.  So I ran the dpkg -l command to show all running applications.  This showed:

python3-serial    2.6-1.1

So I downloaded the latest version 3.3 and attempted to install it.  Now the dpkg -l command shows:

python-serial    2.6.-1.1  (note it says python rather than python3)

Anyway, the out_waiting property now appears in the drop down list of the serial object properties while it definitely did not appear earlier.  And it solved my problem of retrieving the number of bytes in the output buffer!  

Maybe this is a different thread topic but am I looking at the result of the dpkg -l command correctly?  Maybe the 2.6-1.1 isn't the version number.

Thanks to everybody in helping me resolve this issue.
Kevin
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 3,903 Aug-24-2023, 07:56 AM
Last Post: gowb0w

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020