pyserial

Convert an int value to unicode

夙愿已清 提交于 2019-11-30 11:04:00
I am using pyserial and need to send some values less than 255. If I send the int itself the the ascii value of the int gets sent. So now I am converting the int into a unicode value and sending it through the serial port. unichr(numlessthan255); However it throws this error: 'ascii' codec can't encode character u'\x9a' in position 24: ordinal not in range(128) Whats the best way to convert an int to unicode? Just use chr(somenumber) to get a 1 byte value of an int as long as it is less than 256. pySerial will then send it fine. If you are looking at sending things over pySerial it is a very

Pyserial buffer fills faster than I can read

被刻印的时光 ゝ 提交于 2019-11-30 09:57:29
I am reading data from a microcontroller via serial, at a baudrate of 921600. I'm reading a large amount of ASCII csv data, and since it comes in so fast, the buffer get's filled and all the rest of the data gets lost before I can read it. I know I could manually edit the pyserial source code for serialwin32 to increase the buffer size, but I was wondering if there is another way around it? I can only estimate the amount of data I will receive, but it is somewhere around 200kB of data. There's a "Receive Buffer" slider that's accessible from the com port's Properties Page in Device Manager. It

Cannot get minor grid lines to appear in matplotlib figure

一笑奈何 提交于 2019-11-30 07:54:31
问题 Ok so I have the code below for real-time graphing some data from an embedded device received over serial. It's not meant to be a production tool but rather an internal eng tool, hence it's not terribly user-friendly. The problem is that no matter what I do, I can't get minor grid lines to appear, even though here they are set to True, which=both . I can do anything I want to the major grid lines but the minors won't appear. Any ideas? Here is the code: import numpy as np from matplotlib

Trying to open a serial port with pyserial on WinXP -> “Access denied”

£可爱£侵袭症+ 提交于 2019-11-30 05:39:44
问题 I'm trying to send data to an hplc pump via the serial port using python and pyserial. I tested the cable and the pump under linux (a gentoo derivative), where it worked perfectly, albeit as root. Now i have to use the code on a WinXP machine, where i always get an "Access denied" error when trying to open the port (i adjusted the parameters to COMxx instead of ttySxx, the port is found). I tried the serial port of the computer, as well as a USB2Serial adapter. I heard that WinXP was quite

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

僤鯓⒐⒋嵵緔 提交于 2019-11-29 20:57:00
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.SerialException: pass return available print "Found ports:" for n,s in scan(): print "(%d) %s" % (n,s) And

Using Serial on Python / Win7

无人久伴 提交于 2019-11-29 18:02:06
I am trying to interface with a serial WWAN modem (for diagnostics /signal strength measurement purposes). This is via the onboard COM1 (115200-8-n-1) on my desktop, the connection works via PuTTY. I can script the AT commands using Python, but I am having a tough time getting it to open the serial port . I have installed Python 2.7.1 and PySerial according to instructions. I am the local administrator of my machine and have run Python with and without admin privileges, but I get the following when I try to open the port: Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit

Convert an int value to unicode

倖福魔咒の 提交于 2019-11-29 16:42:39
问题 I am using pyserial and need to send some values less than 255. If I send the int itself the the ascii value of the int gets sent. So now I am converting the int into a unicode value and sending it through the serial port. unichr(numlessthan255); However it throws this error: 'ascii' codec can't encode character u'\x9a' in position 24: ordinal not in range(128) Whats the best way to convert an int to unicode? 回答1: Just use chr(somenumber) to get a 1 byte value of an int as long as it is less

Pyserial buffer fills faster than I can read

给你一囗甜甜゛ 提交于 2019-11-29 14:42:20
问题 I am reading data from a microcontroller via serial, at a baudrate of 921600. I'm reading a large amount of ASCII csv data, and since it comes in so fast, the buffer get's filled and all the rest of the data gets lost before I can read it. I know I could manually edit the pyserial source code for serialwin32 to increase the buffer size, but I was wondering if there is another way around it? I can only estimate the amount of data I will receive, but it is somewhere around 200kB of data. 回答1:

pySerial inWaiting returns incorrect number of bytes

南楼画角 提交于 2019-11-29 12:21:19
I've got a simple program to test serial functionality. My serial device reacts to two inputs. If the user enters 'a', it responds with 'fg'. If the user enters anything other character/byte, it responds with 'z'. If I send 'b' to the serial device, it will return 'z' just fine. When I send 'a', it should return both 'f' and 'g', so two bytes instead of one. See code below. #!/usr/bin/env python import serial ser = serial.Serial( port = '/dev/ttyUSB0', baudrate = 9600, parity = serial.PARITY_NONE, stopbits = serial.STOPBITS_ONE, bytesize = serial.EIGHTBITS ) ser.write('a') byteData = ser.read

pyserial: No module named tools

本秂侑毒 提交于 2019-11-29 10:47:57
问题 I have installed the latest pySerial on my Ubuntu box with python 2.7.2, and it works fine for most things, but whenever I try to import the 'tools' package, it says that it can't find 'tools'. The documentation for pySerial explicitly references this 'tools' package. >>> from serial import tools Traceback (most recent call last): File "<pyshell#30>", line 1, in <module> import serial.tools ImportError: No module named tools and when I: >>> serial.VERSION '2.5' which is the latest version