pyserial

How to replicate pyserial sending RGB values to Arduino in jUART?

送分小仙女□ 提交于 2019-12-11 04:36:51
问题 I have been using pyserial in a locally running Python application to send RGB values to an Arduino with: import serial import struct ser = serial.Serial('/dev/ttyACM0', 9600) ser.write(struct.pack('>3B', red_value, green_value, blue_value)) # where the rgb values are ints like 77,75, 0 I'd like to now achieve this functionality from a non-local website. jUART seems to be designed for this purpose, ie a: Cross platform browser plugin for serial port communication from JavaScript It requires

Using asyncio to read the output of a serial port

元气小坏坏 提交于 2019-12-11 03:13:18
问题 I have been doing some port-reading for work, and I need to know if I should use asyncIO to read the data that comes in from this port. Here's some details about the way in which the system is constructed. Multiple sensors are being read at the same time and might produce output that goes in at the same time. (all data comes in through a probee ZU10 connected to a usb port) All data must be timestamped as soon as it comes in. The data is supposed to be processed and then sent to a django

pySerial data received from XBee not properly displayed

北慕城南 提交于 2019-12-11 02:53:45
问题 I am trying to get multiple XBees running as sensors and output devices to send their samples to a coordinator XBee hooked up as below and to turn things on and off on these remote XBees when instructed to. This 'received data' problem of mine seems similar to Stack Overflow question pySerial and reading binary data , but I do not consider it answered by that problem and its resolution. So what steps will reproduce the problem? Using python-xbee (ver 2.1.0, or 2.0.0), pySerial latest version

update tkinter label from serial data whenever there's new data from serial port python 3.x

陌路散爱 提交于 2019-12-11 01:25:11
问题 I have encounter this problem where i could not display any value on the label which i wanted to constantly update it whenever there's new data coming in from the serial port. I'm new to python, really need the help. import tkinter import tkinter.messagebox import serial import time ser = serial.Serial( port='COM5',\ baudrate=9600,\ parity=serial.PARITY_NONE,\ stopbits=serial.STOPBITS_ONE,\ bytesize=serial.EIGHTBITS,\ timeout=4) class Menu: def __init__(self): self.main_window = tkinter.Tk()

Send multiple values to Raspberry with Arduino using serial

北战南征 提交于 2019-12-11 00:14:58
问题 I have got a question about serial communication between Arduino and Raspberry Pi. The fact is I want to send 2 variables to Raspberry Pi with Arduino and use them in different ways. Here my sketch for Arduino : int one = 1; int two = 2; void setup() { Serial.begin(9600); } void loop() { Serial.print(one); Serial.print(two); delay(3000); } Here my python script for Raspberry: import serial import time ser = serial.Serial('/dev/ttyACM0', 9600) time.sleep(4) while True: data=ser.read() print

Serial Communication between Arduino and Python, issue of using hexidecimal values

狂风中的少年 提交于 2019-12-10 20:16:54
问题 I am attempting to start a motor from the computer by code in Python 3.4, using pySerial to communicate to an Arduino Uno. I have packed the value I am sending to hexidecimal, so I only have one byte at a time, but am having a problem getting the correct number on the Arduino side as I am sending on the Python side. PYTHON CODE: import serial import struct ser = serial.Serial( port ='COM4', baudrate = 9600, parity = serial.PARITY_ODD, stopbits = serial.STOPBITS_TWO, bytesize = serial

Python 3 non-blocking read with pySerial (Cannot get pySerial's “in_waiting” property to work)

喜欢而已 提交于 2019-12-10 18:15:53
问题 For the life of me, I cannot figure out how to do a non-blocking serial read in Python 3 using my Raspberry Pi. Here's my code: import serial #for pySerial ser = serial.Serial('/dev/ttyUSB0', 9600) #open serial port print ('serial port = ' + ser.name) #print the port used while (True): if (ser.in_waiting>0): ser.read(ser.in_waiting) Result: AttributeError: 'Serial' object has no attribute 'in_waiting' Here's the reference page I'm referencing that told me "in_waiting" exists: http://pyserial

How can I create byte values from integers in Python?

。_饼干妹妹 提交于 2019-12-10 17:48:41
问题 Background: I need to send a numerical value as a byte to an external device, but I have run into a problem. My code is: ser=serial.Serial("COM3",9600, timeout=0) ser.write(value) where "value" is an int that I read have read. The problem is, when I send this, it sends the character value, not the actual value (it sends the byte value 31 for the number 5, since that is the unicode position for it, I believe) In reality, I want to be able to send it the character "\x05" for example. I guess my

Pyserial: could not configure port: (5, 'Input/output error)

旧巷老猫 提交于 2019-12-10 14:49:33
问题 I've been trying to get the following two lines of Python code to run for the past two days, without much success: import serial ser = serial.Serial(0) Each time I run it, I get the following error: Traceback (most recent call last): File "./test.py", line 4, in <module> ser = serial.Serial(0) File "/usr/lib/python2.7/dist-packages/serial/serialutil.py", line 260, in __init__ self.open() File "/usr/lib/python2.7/dist-packages/serial/serialposix.py", line 280, in open self._reconfigurePort()

Python PySerial.How to know if a port is already open?

走远了吗. 提交于 2019-12-09 17:25:44
问题 I'm trying to write an App that uses serial ports in a Linux PC, using python and PySerial. But in this PC there are other Apps using serial ports. How can I know if a port is already open by other App before trying to use it? thanks 回答1: Seems to be badly documented on the PySerial website, this works for me: ser = serial.Serial(DEVICE,BAUD,timeout=1) if(ser.isOpen() == False): ser.open() A bit of a contrived example, but you get the idea. I know this question was asked a long time ago, but