Questions tagged [pyserial]

pySerial is a Python module that encapsulates the access for the serial port. It provides backends for different platforms and Python implementations.

pySerial encapsulates the access for the serial port. It provides backends for Python running on Windows, Linux, BSD (possibly any POSIX compliant system), Jython and IronPython (.NET and Mono). The module named serial automatically selects the appropriate backend.

This is an example extracted from the introduction of the documentation:

>>> import serial
>>> ser = serial.Serial(0)  # open first serial port
>>> print(ser.portstr)      # check which port was really used
>>> ser.write("hello")      # write a string
>>> ser.close()             # close port

References:

1951 questions
0
votes
0 answers

Python Serial() not etablishing on start up

I've made a python script to read information from Serial port. I want this script to run at the boot of my ubuntu. I've made my python file executable, and added a lign to the crontab : @reboot sleep 10s; python /home/MyUser/Documents/MyScript.py…
Ezhno
  • 415
  • 5
  • 17
0
votes
1 answer

How to separate values received from a serial port and store it as separate variables in python?

I am new to python, to sensors and Stackoverflow. I am working on a project at my uni to read 4 sensor data on COM4 of my pc through pyserial. I wrote the below code to accomplish this: import serial ser = serial.Serial('COM4', 9600,…
Wild Ace
  • 65
  • 6
0
votes
1 answer

How to resolve pypi/ pyserial installation warning for setup.py 'unknown distribution option: 'use_2to3'"

I am installing pyserial2.7 using python install setup.py and get the warning "unknown distribution option: 'use_2to3'" after this warning, it gives a set of running.... install, build and so on. However, import.serial inside python, gives…
AAI
  • 280
  • 3
  • 18
0
votes
0 answers

Python code: Device on ttyUSB0 reconnects to ttyUSB1 - how to detect?

I have a FTDI device which connects to ttyUSB0. After unplugging and re-inserting the device always connects to ttyUSB1. I have to detect the change and act accordingly to keep my send and recv functions running. I tried to detect it within the send…
0
votes
1 answer

Working with serial without data loss

I'm listening serial port using pySerial. Data processed only when I got chunk of data, that I can process. Simple event dispatcher listen for events from readet, then event data handled. Handling may involve IO, Networking and another type of…
Neka
  • 1,474
  • 2
  • 19
  • 35
0
votes
2 answers

pyserial time based repeated data request

I am writing an application in python to acquire data using a serial communication. I use the pyserial library for establishing the communication. What is the best approach to request data in an interval (eg every 2 seconds). I always have to the…
Molitoris
  • 626
  • 3
  • 21
0
votes
0 answers

Pyserial how to send ascii character

I use sliders on my project. These change and i send my stm32 side and drive motors. My stm32 sides take angle type ascii, but pyserial side send integer, i want send 54 degres on my slider value and pyserial send 90's ascii type 6 how can i do that…
NetworkStudent
  • 281
  • 2
  • 12
0
votes
1 answer

pySerial writes to Arduino Uno get buffered

I have a Python script that writes short messages to the serial port on my Arduino Uno board using pySerial. There is a loop and depending on some conditions, multiple writes can happen within a loop, something like this: while True: #Conditions…
Bhakta Nall
  • 184
  • 1
  • 9
0
votes
1 answer

Serial port doesn't work properly after reboot, unless I execute minicom

My program begins like this: #!/usr/bin/env python import sys from serial import Serial, EIGHTBITS, PARITY_NONE, STOPBITS_ONE SERIAL_DEVICE = '/dev/ttyUSB0' ser = Serial(SERIAL_DEVICE, timeout=2, baudrate=9600, bytesize=EIGHTBITS, …
Antonis Christofides
  • 5,658
  • 31
  • 45
0
votes
1 answer

C send struct over UART to Python

I'm trying to send a struct over UART (from an ESP32) to be processed by Python by using this guide. // we send this to the host, to be processed by python script struct package { uint8_t modifier; uint8_t keyboard_keys[6]; }; // instantiate…
Constantino
  • 1,855
  • 17
  • 37
0
votes
1 answer

Pyserial failed to read full line after sending data

I'm developping a script with Pyserial to send data to a microcontroller, the microcontroller then read the data, process them, and send back some debug information to my python script. My python script was working without any issue when i was just…
Asmature
  • 15
  • 4
0
votes
0 answers

import serial check if device is connected permanently

I would like to check connection vie COM-Port permanently, I have found here how to check connection, but when I implement it to my application in order to check if device is connected I do not achieve wanted result, perhaps because I am checking it…
John
  • 422
  • 6
  • 19
0
votes
1 answer

PySerial, check if Serial is Connected

So I am working on a project that has a Raspberry Pi connected to a Serial Device via a USB to Serial Connector. I am trying to use PySerial to track the data being sent over the connected Serial device, however there is a problem. Currently, I…
Skitzafreak
  • 1,387
  • 4
  • 22
  • 39
0
votes
1 answer

Triggering data acquisition in Arduino with Python

I would like to trigger data acquisition on my Arduino UNO with connected accelerometer (MPU 6050) by using Python. The idea is that when the command is given in Python, the Arduino would start saving data on its SRAM and when a certain number of…
mcluka
  • 255
  • 4
  • 15
0
votes
1 answer

Converting PySerial Code from Python 3 to 2.7

I'm trying to port a program written in Python 3.5 to 2.7, but it seems the addition of bytes objects in Python 3 changes how PySerial is implemented. Unfortunately, I cannot find any documentation for PySerial 2.x, so I would greatly appreciate…
abeta201
  • 148
  • 9