pyserial

PySerial [Error 5] Access is Denied

你离开我真会死。 提交于 2019-12-19 03:45:26
问题 I am trying to write a program in Python that will loop to keep checking the serial port (COM4) and print out a message when the character "1" is read from the serial port. I want to send "1" over the serial port from an Arduino gadget upon the push of a button. However, I get the error "[Error 5]: Access is Denied" when I try to create an instance of a serial object. (It automatically tries to open upon instantiation, which is where the error is, from what I can see from the file in the

PySerial [Error 5] Access is Denied

隐身守侯 提交于 2019-12-19 03:45:14
问题 I am trying to write a program in Python that will loop to keep checking the serial port (COM4) and print out a message when the character "1" is read from the serial port. I want to send "1" over the serial port from an Arduino gadget upon the push of a button. However, I get the error "[Error 5]: Access is Denied" when I try to create an instance of a serial object. (It automatically tries to open upon instantiation, which is where the error is, from what I can see from the file in the

pySerial buffer won't flush

风格不统一 提交于 2019-12-18 11:57:00
问题 I'm having a problem with serial IO under both Windows and Linux using pySerial. With this code the device never receives the command and the read times out: import serial ser = serial.Serial('/dev/ttyUSB0',9600,timeout=5) ser.write("get") ser.flush() print ser.read() This code times out the first time through, but subsequent iterations succeed: import serial ser = serial.Serial('/dev/ttyUSB0',9600,timeout=5) while True: ser.write("get") ser.flush() print ser.read() Can anyone tell what's

What is the cross-platform method of enumerating serial ports in Python (including virtual ports)?

一笑奈何 提交于 2019-12-18 10:19:38
问题 Note: I'm using Python 2.7, and pySerial for serial communications. I found this article which lists two ways: http://www.zaber.com/wiki/Software/Python#Displaying_a_list_of_available_serial_ports This method works on Windows and Linux, but sometimes misses virtual ports on Linux: import serial def scan(): # scan for available ports. return a list of tuples (num, name) available = [] for i in range(256): try: s = serial.Serial(i) available.append( (i, s.portstr)) s.close() except serial

Reading serial data in realtime in Python

我是研究僧i 提交于 2019-12-17 15:37:29
问题 I am using a script in Python to collect data from a PIC microcontroller via serial port at 2Mbps. The PIC works with perfect timing at 2Mbps, also the FTDI usb-serial port works great at 2Mbps (both verified with oscilloscope) Im sending messages (size of about 15 chars) about 100-150x times a second and the number there increments (to check if i have messages being lost and so on) On my laptop I have Xubuntu running as virtual machine, I can read the serial port via Putty and via my script

PySerial non-blocking read loop

回眸只為那壹抹淺笑 提交于 2019-12-17 03:09:29
问题 I am reading serial data like this: connected = False port = 'COM4' baud = 9600 ser = serial.Serial(port, baud, timeout=0) while not connected: #serin = ser.read() connected = True while True: print("test") reading = ser.readline().decode() The problem is that it prevents anything else from executing including bottle py web framework. Adding sleep() won't help. Changing "while True"" to "while ser.readline():" doesn't print "test", which is strange since it worked in Python 2.7. Any ideas

How to get PySerial to accept 921600 Baud rate

情到浓时终转凉″ 提交于 2019-12-14 03:00:28
问题 We have a motor controller that implements a USB->Virtual COM port that has a fixed baud rate of 921600 (the manual even states that the baud rate cannot be changed). I found that if I use a terminal program like Terminal, I can pass the custom baud rate of 921600 and communicate with the instrument with no issues. We are using Windows 7 pro, 64-bit version. However, when I tried to do this in PySerial (v.2.7) using Python 2.7.10 (32 bit) like this: import serial ser = serial.Serial("COM3"

Feedparser - KeyError: 'fullcount'

混江龙づ霸主 提交于 2019-12-14 02:43:50
问题 I have tried to follow this guide. It is about making a physical gmail notifier. When I entered the same code it found an error: Traceback (most recent call last): File "C:/Python27/Projects/gmailnotifier.py", line 20, in <module> )["feed"]["fullcount"]) File "C:\Python27\lib\site-packages\feedparser-5.1.3-py2.7.egg\feedparser.py", line 375, in __getitem__ return dict.__getitem__(self, key) KeyError: 'fullcount' I am not sure why and thats why im asking. I am using windows 7, python 2.7.3,

Converting python2 byte/string encoding to python3

巧了我就是萌 提交于 2019-12-14 02:26:16
问题 I'm communicating over a serial port, and currently using python2 code which I want to convert to python3. I want to make sure the bytes I send over the wire are the same, but I'm having trouble verifying that that's the case. In the original code the commands are sent like this: serial.Serial().write("\xaa\xb4" + chr(2)) If I print "\xaa\xb4" in python2 I get this: ��. If I print("\xaa\xb4") in python3 I get this: ª´ Encoding and decoding seem opposite too: Python2: print "\xaa".decode(

Python Pyserial Windows No Port Found

廉价感情. 提交于 2019-12-13 20:05:37
问题 I have just tried to connect to usb mobile to send sms through it using AT commands. But when i use pyserial to connect to it in a windows os, i get error could not open port, the file specified cannot be found. >>> import serial >>> ser = serial.Serial(0) # open first serial port >>> print ser.name # check which port was really used >>> ser.write("hello") # write a string >>> ser.close() even if i replace the 0 with any other value, like 0 -10 or 'com0','com1' etc, i still get error file