using 2 serials - Raspberry Pi Forums
i have program send data arduino. getting no response on console. have jumpered tx pin rx pin, still getting nothing on console. program seems run no errors. possible, , how?
jim
code: select all
#!/usr/bin/python import serial, time ser = serial.serial('/dev/ttyama0', 115200, timeout = 0.1) #if want send data arduino (i.e. signal move servo) def send( theinput ): ser.write( theinput ) while true: try: time.sleep(0.01) break except: pass time.sleep(0.1) #if tell arduino receive data arduino def send_and_receive( theinput ): ser.write( theinput ) while true: try: time.sleep(0.01) state = ser.readline() print state return state except: pass time.sleep(0.1) f = open('datafile.txt','a') while 1 : try: arduino_sensor = send_and_receive('i') f.write(arduino_sensor) f.close() f = open('datafile.txt','a') except (keyboardinterrupt, systemexit): raise except:
pehaps ser.readline() doesn't return because never gets newline?
raspberrypi
Comments
Post a Comment