pyserial

Unable to get arduino serial communication working in wxpython GUI

房东的猫 提交于 2020-01-03 05:37:06
问题 This is the definition which is used to update the labels in the GUI: def updateV(self, event): """""" global v ser = serial.Serial( port='COM3', baudrate=9600) x = ser.read() # read one byte ser.close() print x if v>3: self.labelOne.SetBackgroundColour('red') self.labelOne.SetLabel('Battery Voltage : ' + x) else: self.labelOne.SetBackgroundColour('white') self.labelOne.SetLabel('Battery Voltage : ' + str(v)) self.Refresh() This is the simple arduino code i have been using: int a; void setup(

How can I communicate with a 3G modem via pySerial while it is connected?

半世苍凉 提交于 2020-01-01 14:25:34
问题 I'm running Ubuntu 11.04 and a ZTE 3G modem. The modem is dialed with WvDial When the modem is not in use by WvDial I can send AT commands to the modem, and get information like signal strength: AT+ZCSQ +ZCSQ: 1, -87 OK But when WvDial is using the modem, /dev/ttyUSB0 is locked and I can't query it. Am I missing something obvious? Is there any way I can configure the modem, WvDial , or pyserial so I can send AT commands to the modem while it's connected? 回答1: Ah. Apparently this modem exposes

How can I communicate with a 3G modem via pySerial while it is connected?

房东的猫 提交于 2020-01-01 14:25:02
问题 I'm running Ubuntu 11.04 and a ZTE 3G modem. The modem is dialed with WvDial When the modem is not in use by WvDial I can send AT commands to the modem, and get information like signal strength: AT+ZCSQ +ZCSQ: 1, -87 OK But when WvDial is using the modem, /dev/ttyUSB0 is locked and I can't query it. Am I missing something obvious? Is there any way I can configure the modem, WvDial , or pyserial so I can send AT commands to the modem while it's connected? 回答1: Ah. Apparently this modem exposes

How can I improve PySerial read speed

£可爱£侵袭症+ 提交于 2020-01-01 03:17:27
问题 I'm currently building a machine that uses an Arduino Mega2560 as its main controller. The Arduino is connected to over serial, gets a command, executes it and spits out a bunch of measurement data every 1ms. I have a Raspberry Pi running Python to give the user a nice GUI to send the command, and to present the data in a readable form. The problem I face: the Arduino is able to spit out 15 byte of data each millisecond (so that's only 15kbyte/s), but the code I'm running can only cope with

How can I improve PySerial read speed

烂漫一生 提交于 2020-01-01 03:17:12
问题 I'm currently building a machine that uses an Arduino Mega2560 as its main controller. The Arduino is connected to over serial, gets a command, executes it and spits out a bunch of measurement data every 1ms. I have a Raspberry Pi running Python to give the user a nice GUI to send the command, and to present the data in a readable form. The problem I face: the Arduino is able to spit out 15 byte of data each millisecond (so that's only 15kbyte/s), but the code I'm running can only cope with

Pyserial does not play well with virtual port

放肆的年华 提交于 2019-12-31 22:48:11
问题 Motivation I want to start leraning how to use the python library Pyserial. It seems like a really nice library that works for a lot of people. I want to use it for an upcoming project in which I have to automate serial communications. Environment I'm running Ubuntu 15.04. I'm using Python 2.7. Setting up virtual ports I don't currently have a device that I can communicate with over a serial port. I'm using the socat application to create two virtual ports that are connected to each other

Losing data in received serial string

不打扰是莪最后的温柔 提交于 2019-12-30 10:26:15
问题 So part of a larger project needs to receive a long hex character string from a serial port using a raspberry pi. I thought I had it all working but then discovered it was losing a chunk of data in the middle of the string. def BUTTON_Clicked(self, widget, data= None): ser = serial.Serial("/dev/ex_device", 115200, timeout=3) RECEIVEDfile = open("RECIEVED.txt", "r+", 0) #unbuffered #Commands sent out ser.write("*n\r") time.sleep(1) ser.flush() ser.write("*E") ser.write("\r") #Read back string

Losing data in received serial string

可紊 提交于 2019-12-30 10:26:06
问题 So part of a larger project needs to receive a long hex character string from a serial port using a raspberry pi. I thought I had it all working but then discovered it was losing a chunk of data in the middle of the string. def BUTTON_Clicked(self, widget, data= None): ser = serial.Serial("/dev/ex_device", 115200, timeout=3) RECEIVEDfile = open("RECIEVED.txt", "r+", 0) #unbuffered #Commands sent out ser.write("*n\r") time.sleep(1) ser.flush() ser.write("*E") ser.write("\r") #Read back string

How do I ensure that a Python while-loop takes a particular amount of time to run?

流过昼夜 提交于 2019-12-30 03:28:24
问题 I'm reading serial data with a while loop. However, I have no control over the sample rate. The code itself seems to take 0.2s to run, so I know I won't be able to go any faster than that. But I would like to be able to control precisely how much slower I sample. I feel like I could do it using 'sleep', but the problem is that there is potential that at different points the loop itself will take longer to read(depending on precisely what is being transmitted over serial data), so the code

How do I ensure that a Python while-loop takes a particular amount of time to run?

♀尐吖头ヾ 提交于 2019-12-30 03:28:03
问题 I'm reading serial data with a while loop. However, I have no control over the sample rate. The code itself seems to take 0.2s to run, so I know I won't be able to go any faster than that. But I would like to be able to control precisely how much slower I sample. I feel like I could do it using 'sleep', but the problem is that there is potential that at different points the loop itself will take longer to read(depending on precisely what is being transmitted over serial data), so the code