pyserial

Python/Pyserial: reading incoming information from port

寵の児 提交于 2019-12-06 15:37:07
I've just started using pyserial as I will eventually need to read/save information coming from a particular port. Using the following code I am merely printing the port used and then trying to write and then read in some text ("hello"). The port is printing fine, but the output of my string is coming out as 5. Any idea why this is? import serial import sys from time import sleep try: ser = serial.Serial('\\.\COM8', 9600,timeout=None, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) except: sys.exit("Error connecting device") print ser.portstr x = ser.write(

Pyserial, Getting extra info from OBD Device

淺唱寂寞╮ 提交于 2019-12-06 15:06:01
I am new at programming and am trying to communicate with my vehicle with an OBD II device. Serial to USB. I've done what I want it to do but I get the command I entered to print out. How do I just get the information from the device? Heres my code. I am using Python 3.2.3 import serial import time import string import io import os import sys ser = serial.Serial("/dev/ttyUSB1") ser.baudrate = 38400 s = input('Enter AT command --> ') print ('AT command = ' + s) ser.write(bytes(s + '\r\n', encoding = 'utf-8')) ser.timeout = 1 response = ser.read(999).decode('utf-8') print(response) ser.close()

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

爷,独闯天下 提交于 2019-12-06 05:43:25
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 HERCULES AS THIS LINK SHOWS https://www.youtube.com/watch?v=DItyttmpRtY I was trying to create my own

Identifying serial/usb device python

 ̄綄美尐妖づ 提交于 2019-12-06 02:08:09
问题 The solution to this problem is probably pretty simple, but I am new to interfacing with a device dynamically. What I'm doing is I am making a python executable code, so the user doesn't have to have Idle on their computer or any kind of python interpreter, which means I don't know which USB port the device will be plugged in to. The program needs to be able to open a connection to a device that is connected through a serial to usb converter. How can I determine which connected device is the

Passing serial data to javascript via Flask

混江龙づ霸主 提交于 2019-12-05 21:49:34
I've been poking around with pushing data from Flask to Javascript, mainly by modifying the code found here: https://github.com/clebio/flask-d3 Now I'm trying to read data from a COM Port and pass it through Flask to Javascript. I've done some of this before using PySerial, but am not sure the right way to approach combining it into Flask. I feel comfortable implementing something where, with each request, the port is opened, reads a line, and is closed. That's not very efficient, so ideally I would be able to open the COM port once, run a readline when Flask receives a request from the client

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

十年热恋 提交于 2019-12-05 10:53:41
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 = 115200 ser.bytesize = serial.EIGHTBITS #number of bits per bytes ser.parity = serial.PARITY_NONE #set

Microprocessor to RS-232 realtime plot using PySerial/Matplotlib?

£可爱£侵袭症+ 提交于 2019-12-05 06:14:42
问题 I'm new to the world of Python and my programming skills are fairly poor but I'm trying to figure a way to use Python to display the output from an EEG circuit (using the OpenEEG circuit http://openeeg.sourceforge.net) The analogue output is amplified and processed via an ADC (in an ATmega8 microcontroller) and is converted to RS232 by a MAX232. The RS232 Signal is as follows: Byte 1: sync value 0xa5 Byte 2: sync value 0x5a Byte 3: version Byte 4: Frame number Byte 5: Channel 1 Low Byte Byte

Reconnecting to device with pySerial

帅比萌擦擦* 提交于 2019-12-05 05:07:27
I am currently having a problem with the pySerial module in Python. My problem relates to connecting and disconnecting to a device. I can successfully connect to my device and communicate with it for as long as I want to, and disconnect from it whenever I desire. However, I am unable to reconnect to the device once the connection has been severed. Here is the wrapper class that my program uses to interface with the serial port: import serial, tkMessageBox class Controller: """ Wrapper class for managing the serial connection with the MS-2000. """ def __init__(self, settings): self.ser = None

Using pySerial with Python 3.3

*爱你&永不变心* 提交于 2019-12-05 04:35:46
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 ? Is there any other way to use COM ports with Python3.3 ? P_Rein So the moral of the story is.. the port

How can I use COM and USB ports within Cygwin?

好久不见. 提交于 2019-12-05 01:23:58
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.py Traceback (most recent call last): File "example.py", line 9, in <module> ser.open() File "/usr/lib