pyserial

How do I refresh/update QLabel with data from USB serial (from Arduino)?

こ雲淡風輕ζ 提交于 2019-12-13 18:08:54
问题 I know this is a NOOB question; forgive me. I built a Pinewood Derby race timer (small car track) for Cub Scouts using a combination of an Arduino to control timing and RasPi for GUI display of lane place (1st, 2nd, 3rd, etc.) and run time in seconds (e.g. "2.1234"). I have the basic shell GUI setup in QT Creator and have successfully connected the Arduino & RasPi via USB. I am also successfully pulling the Arduino serial data into RasPi (tested with separate small Python code). Problem I am

Python io module's TextIOWrapper or BuffereRWPair functions are not playing nicely with pySerial

只谈情不闲聊 提交于 2019-12-13 16:27:57
问题 I'm writing a serial adapter for some scientific hardware whose command set uses UTF-8 character encodings. All responses from the hardware are terminated with a carriage return (u'\r'). I would like to able to use pySerial's readline() function with an EOL character specified, so I have this setup, ala this thread: import serial import io ser = serial.Serial(port='COM10', baudrate=128000) sio = io.TextIOWrapper(io.BufferedRWPair(ser, ser, 1), encoding='utf-8', newline=u'\r') ser.open() #

print the data on window screen and then clear the window screen before printing other data.in python

跟風遠走 提交于 2019-12-13 08:42:15
问题 I can receive serial data and can print on the window screen(Tkinter top).when i receive serial data again, this newly received serial data should start printing on the window screen by wiping out the previous serial data.This process has to happen for every received serial data. I had a code to receive and print data on window, but it prints all the received data on the screen with out wiping the old data. 回答1: In that case, all you have to do is remove the previous content of the widget

What does XON/XOFF flow control actually do?

好久不见. 提交于 2019-12-13 05:34:48
问题 From what I have been able to discover, XON and XOFF are nothing but special ASCII characters used for handshaking between two serial devices. But it is not clear to me what actually happens when I use this type of flow control for communication. Is there just an XON character at the start of my message, and an XOFF character at the end? I.e., when I write something using PySerial like this: import serial ser = serial.Serial('COMx', 9600, xonxoff = True) ser.write('Hi!\r\n') Does the device

Serial Ports Linux vs Windows

人走茶凉 提交于 2019-12-13 03:59:40
问题 I am having issues with my pyserial program on Ubuntu 16. I am trying to send a break command to a hardware device using pyserial. I wrote a python script that: Sets the port/baud/parity/bytesize/... Opens the port Sends a break command Reads the return message from the device. I run the script on my Ubuntu 16.04 machine and I get zero response, it just hangs or eventually timeouts. I copy the same script to my Windows machine, change the port (from /dev/ttyUSB0 to COM#) and my script works

Sniffing data of serial port without removing data from buffer

↘锁芯ラ 提交于 2019-12-13 02:40:16
问题 I am using the bgapi library to manage bluetooth communication using a USB dongle. The library will take a command from my program and will handle all serial communications through the COM port in its own thread. I want to echo back all data coming out of the COM port, but the library only gives me access to what it chooses to parse out itself. I could go into the bgapi library and change the functionality of the code, setting up a variable or function to return what data is currently being

Specificity in importing python module?

天大地大妈咪最大 提交于 2019-12-13 01:28:01
问题 I've been working with the PySerial library for pythonPyserial API, and I can't seem to understand why I have to specifically import a certain part of the module. This will give me an error: import serial for item in serial.tools.list_ports.comports(): print item The above snippet will return "AttributeError: type object 'Serial' has no attribute 'tools'" If I import that attribute specifically, I get no errors: import serial.tools.list_ports for item in serial.tools.list_ports.comports():

Trouble with PySerial and multiple Python installations

梦想与她 提交于 2019-12-12 19:42:29
问题 I have Python 2.4.4 and 3.1.3 on my Windows 7 machine. I would like to use PySerial. I heard that it was built in, so I tried import serial in both versions. Both caused an Import Error . Then I downloaded the win32 installer from this page. I ran it, and it installed for 2.4.4. (It said it found it from the registry.) I had no option to change to the 3.1.1 version. I then got the following error in 2.4.4: >>> import serial Traceback (most recent call last): File "<pyshell#0>", line 1, in

Python SerialException: Device reports readiness to read but returned no data

情到浓时终转凉″ 提交于 2019-12-12 17:14:13
问题 I'm using an Arduino Nano, previously an UNO, to collect data from sensors and then send the data back over a USB connection through a powered hub to a Raspberry Pi model B running Jessie 4.1.19+ Mar, 15 2016 and Python 2.7. The python code uses pyserial readline to get the data. In general it works fine but occasionally (typically a couple of times a day) it fails with the above message. It seemed the only way to fix it was to unplug the USB connection, reconnect it and restart the program.

Need to do a daily log rotation (0utc) using Python

纵饮孤独 提交于 2019-12-12 09:19:57
问题 I'm an admitted noob to Python. I've written a little logger that takes data from the serial port and writes it to a log file. I've got a small procedure that opens the file for append, writes, then closes. I suspect this might not be the best way to do it, but it's what I've figured out so far. I'd like to be able to have it automagically perform a log-rotate at 00 UTC, but so far, my attempts to do this with RotatingFileHandler have failed. Here's what the code looks like: import time,