Skip to content

Add pyserial lib to support serial robots #8

@MGross21

Description

@MGross21

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 request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions