472,102 Members | 1,975 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,102 software developers and data experts.

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


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
  11. ser.open()
  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
1 4065
Curtis Rutland
3,256 Expert 2GB
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.

Similar topics

6 posts views Thread by Casey Bralla | last post: by
5 posts views Thread by George T. | last post: by
17 posts views Thread by luca72 | last post: by
7 posts views Thread by alexandre_irrthum | last post: by
4 posts views Thread by rowan | last post: by
reply views Thread by [david] | last post: by
3 posts views Thread by naveen.sabapathy | last post: by
2 posts views Thread by mmrasheed | last post: by
6 posts views Thread by brianrpsgt1 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.