pyserial

Cannot get minor grid lines to appear in matplotlib figure

℡╲_俬逩灬. 提交于 2019-11-29 09:12:35
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 import pyplot as plt from matplotlib import animation import serial SERIAL_PORT_NUM=9 ...a bunch of

Python Serial: How to use the read or readline function to read more than 1 character at a time

情到浓时终转凉″ 提交于 2019-11-29 06:13:54
问题 I'm having trouble to read more than one character using my program, I can't seem to figure out what went wrong with my program. import serial ser = serial.Serial( port='COM5',\ baudrate=9600,\ parity=serial.PARITY_NONE,\ stopbits=serial.STOPBITS_ONE,\ bytesize=serial.EIGHTBITS,\ timeout=0) print("connected to: " + ser.portstr) count=1 while True: for line in ser.read(): print(str(count) + str(': ') + chr(line) ) count = count+1 ser.close() here are the results I get connected to: COM5 1: 1 2

pySerial works fine in Python interpreter, but not standalone

笑着哭i 提交于 2019-11-29 01:52:02
Good morning! Recently I bought an Arduino board to make sort of "light control" in my room. Here is the code of the firmware I wrote: int control = 0; int pin = 0; void setup() { Serial.begin(9600); for(pin = 0; pin <= 13; pin++) pinMode(pin, OUTPUT); } void loop() { control = Serial.read(); if (control > 0 && control <= 13) digitalWrite(control, HIGH); if (control < 256 && control >= (256-13)) digitalWrite((256-control), LOW); } After that, I used pySerial from Python interpreter to control the pins, and everything was working fine. Here is a piece of interpreter output: Python 2.6.5 (r265

python3 pySerial TypeError: unicode strings are not supported, please encode to bytes:

泪湿孤枕 提交于 2019-11-28 23:16:53
In Python 3 I imported the pySerial library so I could communicate with my Arduino Uno by serial commands. It worked very well in Python 2.7 but in Python 3 I keep running into a error it says this TypeError: unicode strings are not supported, please encode to bytes: 'allon' In Python 2.7 the only thing I did differently is use raw_input but I don't know what is happening in Python 3. Here is my code import serial, time import tkinter import os def serialcmdw(): os.system('clear') serialcmd = input("serial command: ") ser.write (serialcmd) serialcmdw() ser = serial.Serial() os.system('clear')

Virtual Serial Device in Python?

北慕城南 提交于 2019-11-28 16:12:32
I know that I can use e.g. pySerial to talk to serial devices, but what if I don't have a device right now but still need to write a client for it? How can I write a "virtual serial device" in Python and have pySerial talk to it, like I would, say, run a local web server? Maybe I'm just not searching well, but I've been unable to find any information on this topic. this is something I did and worked out for me so far: import os, pty, serial master, slave = pty.openpty() s_name = os.ttyname(slave) ser = serial.Serial(s_name) # To Write to the device ser.write('Your text') # To read from the

PyQt5 - Automate Serial module

て烟熏妆下的殇ゞ 提交于 2019-11-28 13:01:41
I am trying to automate serial connection without clicking on button. When the gui load, serial should be read immediately and refreshed at interval without using the mouse to trigger any button (that is auto read in and updated). How possible is this? See script and GUI below.. import schedule import serial import sys from PyQt5 import uic, QtWidgets qtCreatorFile = "gui.ui" Ui_MainWindow, QtBaseClass = uic.loadUiType(qtCreatorFile) estudiantes = [' ',' ',' ',' '] ser = serial.Serial('COM9', baudrate=9600, timeout=1) class MyApp(QtWidgets.QMainWindow, Ui_MainWindow): def __init__(self):

Using Serial on Python / Win7

折月煮酒 提交于 2019-11-28 12:10:05
问题 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

pySerial write() won't take my string

时光总嘲笑我的痴心妄想 提交于 2019-11-28 11:54:41
Using Python 3.3 and pySerial for serial communications. I'm trying to write a command to my COM PORT but the write method won't take my string. (Most of the code is from here Full examples of using pySerial package What's going on? import time import serial ser = serial.Serial( port='\\\\.\\COM4', baudrate=115200, parity=serial.PARITY_ODD, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS ) if ser.isOpen(): ser.close() ser.open() ser.isOpen() ser.write("%01#RDD0010000107**\r") out = '' # let's wait one second before reading output (let's give device time to answer) time.sleep(1) while

Maximizing serial communication speed for live plotting data from Teensy 3.2 using Python

佐手、 提交于 2019-11-28 09:42:01
问题 I'm trying to plot data as quickly as possible with Python (PyQtGraph) received from a Teensy 3.2 which is sending analog data over a serial communication. The code can sufficiently plot a test waveform of higher frequencies (sine wave of about 5kHz), but it takes nearly 30 seconds for the plot to show a change in frequency. For example, if the test waveform is turned off, it continues to plot the sine wave for an additional half minute. I've tried performing a "serial flush" to clear out the

Using PySerial is it possible to wait for data?

白昼怎懂夜的黑 提交于 2019-11-28 06:24:57
I've got a Python program which is reading data from a serial port via the PySerial module. The two conditions I need to keep in mind are: I don't know how much data will arrive, and I don't know when to expect data. Based on this I have came up with the follow code snippets: #Code from main loop, spawning thread and waiting for data s = serial.Serial(5, timeout=5) # Open COM5, 5 second timeout s.baudrate = 19200 #Code from thread reading serial data while 1: tdata = s.read(500) # Read 500 characters or 5 seconds if(tdata.__len__() > 0): #If we got data if(self.flag_got_data is 0): #If it's