I am using the pyserial module and am trying to read the serial port from an accelerometer (LIS302DL).
It has an option in which you write "*debug\r\n" and then you read the data (three axes output) from the output.
I use hyperterminal with the below settings and it works fine:
baudrate=115200
databits=8
parity=none
stop bit=1
flow control=none
ASCII Setup: "Send line ends with line feeds" and "Echo typed characters locally"
However when I try using the below python code, nothing is read (using win xp).
It may be a case of the "*debug\n" not actually being written (?) - I've tried a multitude of combinations of single quotes versus double quotes etc.
Does anybody have any ideas or what my issue is ?
======================
Expand|Select|Wrap|Line Numbers
- import serial
- ser = serial.Serial()
- ser.baudrate = 115200
- ser.port = 4
- ser.timeout=3
- ser.isOpen()
- settings=ser
- print "Serial port settings: ", settings
- print ser.portstr
- ser.open()
- ser.flushInput()
- ser.write("*debug\r\n")
- x=ser.readline()
- print "Read: ", x
- ser.write("*stop\r\n")
- ser.close()
- ser.isOpen()