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?

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: 
jim

pehaps ser.readline() doesn't return because never gets newline?


raspberrypi



Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62