Feb-01-2018, 01:19 PM
Thank you, I managed to make it send command, but not to make the
out = ser.read() print('Receiving...'+out)work. What I am trying to do is this: I wrote a code to read from Arduino through Serial, and I want to send commands to the Arduino through serial (by typing the commands through the keyboard). The code I am using is this:
import serial,time ser = serial.Serial( port='COM4', baudrate=38400, bytesize=serial.EIGHTBITS, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, xonxoff=False ) line = ser.readline(); while line: line = ser.readline() print(line) ser.reset_input_buffer() cmd = input("Enter command or 'exit':") + '\r\n' if len(cmd)>0: ser.write(cmd.encode()) else: continuebut what I see is that the code blocks, until I print something. I want to read continuously from Serial what Arduino sends and if I type a command from keyboard, to write it to the serial. I am trying changes and I read the pyserial documentation but I cannot figure out something...