By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,983 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,983 IT Pros & Developers. It's quick & easy.

Unable to receive exact data only garbage data is collected

P: 2
Beginner in python :)
I am trying to connect with equipment using miniterm.py , also tried some pyserial tutorials.
Here is the script:(am able to connect with equipment so excuse the code error)

Expand|Select|Wrap|Line Numbers
  1. import serial
  2. ser=serial
  3.  
  4. try:
  5.         ser=serial.Serial("COM3",baudrate=9600) 
  6.  
  7.         if ser.isOpen():
  8.  
  9.                 print('open')
  10.                 while 1:
  11.                         while ser.inWaiting > 0:
  12.                                 ser.timeout = 5 
  13.                 out = ser.readline().decode("utf-8",'ignore')
  14.                                 print ("Total Bytes Received => " + str(sys.getsizeof(out)) +out +" bytes")            
  15.         else :
  16.                 print('ERROR:unable to open com1 port')
  17.  
  18.         except serial.serialutil.SerialException:
  19.               print(serial.serialutil.SerialException.with_traceback)
  20.  

Solution tried :
1) baudrate - from 1200-19500
2) parity : n,e,o

And important point is , a software that is come with same equipment received data successfully with below :
baudrate :9600
parity : none

Any help is appreciated.

Thanks
pankaj
Dec 21 '15 #1
Share this Question
Share on Google+
2 Replies


P: 2
Fixed , just need to change bytesize , that's it.
Hope this will help someone :)
Dec 24 '15 #2

Expert 100+
P: 619
The "while 1:" loop never exits so it never gets to the ser.readline.
Dec 24 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.