Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Serial connection does not work properly #1

Open
J4nn1K opened this issue May 21, 2024 · 2 comments
Open

Serial connection does not work properly #1

J4nn1K opened this issue May 21, 2024 · 2 comments

Comments

@J4nn1K
Copy link
Owner

J4nn1K commented May 21, 2024

Sometimes the byte sequence from the serial port can't be decoded:

Traceback (most recent call last):
  File "scripts/test_trigger.py", line 20, in <module>
    main()
  File "scripts/test_trigger.py", line 8, in main
    trigger.calibrate()
  File "/home/jannik/Repos/demonstration-interface/src/components/trigger.py", line 43, in calibrate
    value = self.get_adc_value()
  File "/home/jannik/Repos/demonstration-interface/src/components/trigger.py", line 53, in get_adc_value
    line = self.read_serial()
  File "/home/jannik/Repos/demonstration-interface/src/components/trigger.py", line 87, in read_serial
    line = self.ser.readline().decode().rstrip()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf8 in position 8: invalid start byte
@J4nn1K J4nn1K changed the title UnicodeDecodeError when reading serial data Serial connection does not work properly May 24, 2024
@J4nn1K
Copy link
Owner Author

J4nn1K commented May 24, 2024

When the node is terminated this method is executed:

def close_serial(self):
    self.ser.reset_input_buffer()
    self.ser.reset_output_buffer()
    self.ser.close()
    log.info(f'Connection closed')

The next time the node is started it receives no bytes via the serial port.
When the connection is not closed using ser.close and the node is started, it works.

@J4nn1K
Copy link
Owner Author

J4nn1K commented Jun 6, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant