By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,050 Members | 1,019 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,050 IT Pros & Developers. It's quick & easy.

Unable to read/do not receive any data from com port using pyserial

P: 1

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:

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
  1. import serial
  3. ser = serial.Serial()
  4. ser.baudrate = 115200
  5. ser.port = 4
  6. ser.timeout=3
  7. ser.isOpen()
  8. settings=ser
  9. print "Serial port settings: ", settings
  10. print ser.portstr
  12. ser.flushInput()
  13. ser.write("*debug\r\n")
  14. x=ser.readline()
  16. print "Read: ", x
  17. ser.write("*stop\r\n")
  18. ser.close()
  19. ser.isOpen()
Nov 13 '08 #1
Share this Question
Share on Google+
1 Reply

Curtis Rutland
Expert 2.5K+
P: 3,256
Please enclose your posted code in [CODE] [/CODE] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [CODE] [/CODE] tags in future.

Nov 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.