Unable to receive exact data only garbage data is collected

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pank1985
    New Member
    • Dec 2015
    • 2

    Unable to receive exact data only garbage data is collected

    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)

    Code:
    import serial
    ser=serial
    
    try:
            ser=serial.Serial("COM3",baudrate=9600) 
             
            if ser.isOpen():
    
                    print('open')
                    while 1:
                            while ser.inWaiting > 0:
                                    ser.timeout = 5 
    				out = ser.readline().decode("utf-8",'ignore')
                                    print ("Total Bytes Received => " + str(sys.getsizeof(out)) +out +" bytes")			
            else :
                    print('ERROR:unable to open com1 port')
    
            except serial.serialutil.SerialException:
                  print(serial.serialutil.SerialException.with_traceback)

    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
    Last edited by Rabbit; Dec 21 '15, 06:12 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • pank1985
    New Member
    • Dec 2015
    • 2

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

    Comment

    • dwblas
      Recognized Expert Contributor
      • May 2008
      • 626

      #3
      The "while 1:" loop never exits so it never gets to the ser.readline.

      Comment

      Working...