-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Notes
Add pyserial library
Random Sample Code
import serial
import time
try:
# Open the serial port
ser = serial.Serial('/dev/ttyUSB0', 9600, timeout=1) # Replace '/dev/ttyUSB0' with your port name
print(f"Serial port {ser.name} opened successfully")
# Write data
ser.write(b'Hello from Python!')
print("Data sent: Hello from Python!")
# Read data (if device sends a response)
received_data = ser.readline()
if received_data:
print(f"Data received: {received_data.decode('ascii')}") # Decode bytes to string
# Close the port
ser.close()
print("Serial port closed")
except serial.SerialException as e:
print(f"Error opening serial port: {e}")Breaking Change
This eliminates the pure Python standard library implementation
However, pyserial does seem to support 2.X and 3.X. Outdated documentation only shows to 3.8 so this will need to be tested.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request