Python serial inwaiting example4/30/2023 ![]() For either, you'll need to set a timeout like jramirez already suggested: ser = serial.Serial( #!/usr/bin/env pythonīyteData = ser.read(2) # read two expected bytes for the result 'fg' If I do a small change to the code, and manually read the two expected bytes, it works fine. ![]() InWaiting() gives the value of 0, thus it never reads the second byte. When I send 'a', it should return both 'f' and 'g', so two bytes instead of one.īyteData = ser.read(1) # read one, blockingīyteData = byteData + ser.read(moreBytes) If I send 'b' to the serial device, it will return 'z' just fine. If the user enters anything other character/byte, it responds with 'z'. If the user enters 'a', it responds with 'fg'. ![]() I've got a simple program to test serial functionality. ![]()
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |