pyserial

How to Fix TypeError: an integer is required in python 3.4, pyserial 2.7 virtual serial port

这一生的挚爱 提交于 2019-12-07 23:05:36
问题 EDITED Hello programmers Community, I have some problems dealing with pyserial in Python 3.4 first I do not have serial ports so I have used "Virtual Serial Port Driver 7.2 by Eltima Software" to create virtual serial ports in pairs, which means that I can try to send and receive data from these ports, in my case I just create COM1 connected to COM2, then I installed Hercules SETUP utility by HW group to monitor these serial ports, so IN THEORY IF I SEND(write) DATA IN PYTHON I CAN SEE IT IN

pySerial very strange behaviour … Code works when executed in shell but not in a script

喜夏-厌秋 提交于 2019-12-07 22:38:15
问题 I'm struggling with pySerial. To be brief ... The code below works great when executed in the Python Shell ... >>> import serial >>> s=serial.Serial("COM5", 9600) >>> while(1): s.write("#") s.readline() Produces the output below in the shell: 1L '56.73\r\n' 1L '56.73\r\n' When the same code is written in a script say "readSerial.py" the script will either not transmit the hashtag that triggers the serial device to transmit the data, or will not receive the replied data. I'm using pySerial 3,

PySerial and readline() return binary string - convert to regular alphanumeric string?

試著忘記壹切 提交于 2019-12-07 16:18:48
问题 I'm having an issue with PySerial and Python (3.3): The code I'm running (for now, this is just a simple test case) is as follows: ser = serial.Serial('/dev/ttyACM0', 115200) result = ser.readline() parsed = result.split(",") which gives the following error: TypeError: type str doesn't support the buffer API What's my stupid mistake? I think I've traced this to the fact that PySerial's readline is returning a binary string (new in python 3?) and that the string operation "split" is failing

Reading USB-GPS info with Python

不羁的心 提交于 2019-12-07 13:04:25
问题 I've written a small python script that uses information from a usb gps dongle. This far I've been working in linux where I could just identify the device in /dev/ and read NMEA data from it using pySerial. This isn't a perfect solution though and it's not platform independent in any way so I started looking at pyUSB to try to communicate with the device. The device: Product name: ND-100S baud rate: 4800 USB class: 0xEF subclass: 2 My problem is that I know very little about usb so I don't

pySerial write() works fine in Python interpreter, but not Python script

你。 提交于 2019-12-07 06:30:22
问题 Recently, I am trying to make sort of "light control" on Arduino. I use Raspberry Pi to send the control message via serial port (USB cable).Here is the Arduino code : int redled = 12; int whiteled = 48; void setup() { Serial.begin(9600); pinMode(redled,OUTPUT); pinMode(whiteled,OUTPUT); } void loop() { if(Serial.available()) { char cmd = Serial.read(); switch(cmd) { case'r': digitalWrite(redled,HIGH); delay(2000); digitalWrite(redled,LOW); break; case'w': digitalWrite(whiteled,HIGH); delay

Python serial - Attempting to use a port that is not open

非 Y 不嫁゛ 提交于 2019-12-07 06:25:50
问题 I'm still new in python so please bear with me, so I'm trying to write a script with python2-pyserial but I keep getting error Attempting to use a port that is not open Here's the script: #!/usr/bin/python import serial, time #initialization and open the port #possible timeout values: # 1. None: wait forever, block call # 2. 0: non-blocking mode, return immediately # 3. x, x is bigger than 0, float allowed, timeout block call ser = serial.Serial() ser.port = "/dev/ttyUSB2" ser.baudrate =

pySerial and reading binary data

ⅰ亾dé卋堺 提交于 2019-12-07 06:17:15
问题 When the device I am communicating with sends binary data, I can recover most of it. However, there always seem to be some bytes missing, replaced by non-standard characters. For instance, one individual output looks like this: \xc4\xa5\x06\x00.\xb3\x01\x01\x02\x00\x00\x00=\xa9 The period and equals sign should be traditional bytes in hexadecimal format (I confirmed this in another application). Other times I get other weird characters such as ')' or 's'. These characters usually occur in the

Using pySerial with Python 3.3

て烟熏妆下的殇ゞ 提交于 2019-12-06 23:43:02
问题 I've seen many code samples using the serial port and people say they are working codes too. The thing is, when I try the code it doesn't work. import serial ser = serial.Serial( port=0, baudrate=9600 # parity=serial.PARITY_ODD, # stopbits=serial.STOPBITS_TWO, # bytesize=serial.SEVENBITS ) ser.open() ser.isOpen() print(ser.write(0xAA)) The error it gives me is : "SerialException: Port is already opened". Is it me using python3.3 the problem or is there something additional I need to instal ?

How can I use COM and USB ports within Cygwin?

若如初见. 提交于 2019-12-06 19:52:04
问题 I want to send/receive data from my Arduino board with a Python script. I would like to do it using Python and its pySerial module which seems to fit my needs. So I installed Python and pySerial within cygwin (windows XP behind). The Python script is rather straightforward: $ cat example.py #print "testing my COM26 port using python" import serial ser = serial.Serial() ser.baudrate = 9600 ser.port = 26 ser ser.open() ser.isOpen() However at runtime I get the following error. $ python example

python serial模块使用,是pyserial而非serial

半城伤御伤魂 提交于 2019-12-06 16:23:50
1 import serial 2 from serial.tools.list_ports import comports 运行这两句时分别遇到错误 第一个先提示 no module name of serial 由于是用python3.7 从python3开始不再自带serial模块 所以就提示它不存在 了,这样就直接pip install serial 运行时又报 serial.tools不存在,显然tools这个是一个文件夹,到C:\Program Files\Python37\Lib\site-packages\serial确实没发现有文件夹,那有可能是这个serial包不对 网上搜索了一下还有个叫pyserial的,那就先卸载 pip uninstall serial,然后 pip install pyserial,安装完成到再到该目录下查看,确实有了tools目录 再运行代码,正常。 来源: https://www.cnblogs.com/aziji/p/11993974.html