We are trying to read data from a microcontroller and interface it through serial port. The output is then displayed in Python using Pyserial or the hyperterminal, the former is more important
When you touch the input pins of the microcontroller the value changes real time in hyper terminal. But In the case of the pyserial module, even though you touch the input pins, the value does not change. We have actually noticed that python records and prints the input to the pins of the microcontroller before the code is executed in python. Hence, it does not record and print new inputs once the code was been executed.
What could possibly be wrong with this?
CODE:
import serial,csv,sys
print('Tactile Sensing Feedback for Medical Palpation in MIS\n Pyserial Testing Module\n')
ch= raw_input("Enter a to initialize pyserial module, b to quit:")
if ch == 'a':
print 'Initializing Pyserial module'
ser = serial.Serial(0,baudrate=57600,timeout=0,xonxoff=0)
print ser.portstr
ser.flushInput()
for x in range (0,100):
s = ser.readline()
print repr(s)
ser.close()
elif ch == 'b':
print 'closing port......\n'
quit()
else:
print 'Invalid option please input a or b only'