pyserial

Serial Communication – Why isn't this C program behaving like this Python program?

Serial Communication – Why isn't this C program behaving like this Python program? Question: I have two programs that communicate through a serial USB interface with a CNC machine running grbl. The first program, written in Python using the pyserial library, produces intelligible output: b’okrn’ b’okrn’ The second program, written in C using the libserialport …

Total answers: 1

How to run periodic serial communication in a separate thread in python

How to run periodic serial communication in a separate thread in python Question: I am programming a GUI with tkinter that controls the communication to multiple motor controllers that are connected serially via RS485. I have a function (get_status()) that requests the status (motor running, motor position, position reached, …) of the controllers via pySerial …

Total answers: 1

Python splitting text into two lines instead of printing one

Python splitting text into two lines instead of printing one Question: I’m reading sensor data with a RedBoard QWIIC. The program outputs data which looks like this: 408 10 45.47 98760.30 23.33 413 19.17 400 7 45.45 98758.38 23.33 414 19.17 415 16 45.45 98757.56 23.33 414 19.17 405 3 45.45 98758.38 23.33 414 19.17 …

Total answers: 1

Send 8-bit integers over serial to Arduino

Send 8-bit integers over serial to Arduino Question: I created a music visualizer and I want to send three 8-bit integers (0-255) over serial to an Arduino using Python’s pyserial library. I have a text file called rgb.txt on my computer which has the data: 8,255,255. I am sending the data over serial with this …

Total answers: 5

ImportError: cannot import name 'Serial' from 'serial' (unknown location)

ImportError: cannot import name 'Serial' from 'serial' (unknown location) Question: Whenever i execute the code below it gives me following Error: ImportError: cannot import name ‘Serial’ from ‘serial’ (unknown location) Code: from serial import Serial arduinodata = Serial(‘com4’,9600) print("Enter n to ON LED and f to OFF LED") while 1: input_data = raw_input() print ("You …

Total answers: 6

How to send one gcode command over USB?

How to send one gcode command over USB? Question: I am trying to write a simple python script that sends a gcode command to my wanhao D9 motherboard printer, running Marlin. I am running the python script on a raspberry pi that is connected to the printer via USB. import serial ser = serial.Serial(“/dev/ttyUSB0”, 115200) …

Total answers: 1

Python serial (pySerial) Reading lines with EOL r instead of n

Python serial (pySerial) Reading lines with EOL r instead of n Question: I am communicating with an SR830 lock-in amplifier via an RS232 cable. When reading the data as in the following code: import serial def main(): ser = serial.Serial( port=’COM6′, baudrate=19200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS) ser.timeout=1 ser.write(“OUTP? 1 rn”.encode()) #Asks the Lock-in for x-value ser.write(“++readrn”.encode()) …

Total answers: 3