Hi
I am trying to comminucate to my Xbee with the FTDI cable on COM4. I have been trying to use the pyserial.py code to no avail. The code includes the line "import serial" however i cannot find this bit of code. Running pyserial does cause the system to lock up too. Any ideas on how we can read the data packets off the serial port is appreciated.
Thanks!
serial communications question
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: serial communications question
i dont understand what you meanThe code includes the line "import serial" however i cannot find this bit of code
please spend some time crafting a post that is more understandable
-
- Posts: 4
- Joined: Wed Jun 24, 2009 11:48 am
Re: serial communications question
okay, i will try my best by referencing the instructions from the tweet-a-watt page http://www.ladyada.net/make/tweetawatt/parser.html
We are not able to get past the first step on this page.... specifically our difficulty is in getting the python code to read the com port, in our case COM4. We have put the pyserial module on our computer but it does not include the serial.py statement needed to get us to the serial port. We are using the FTDI cable with the proper drivers and we can get packets of data into the terminal window as per the instructions on the previous steps.
however we cannot run this code:
from xbee import xbee
import serial
SERIALPORT = "COM4" # the com/serial port the XBee is connected to
BAUDRATE = 9600 # the baud rate we talk to the xbee
# open up the FTDI serial port to get data transmitted to xbee
ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.open()
while True:
# grab one packet from the xbee, or timeout
packet = xbee.find_packet(ser)
if packet:
xb = xbee(packet)
print xb
We are not able to get past the first step on this page.... specifically our difficulty is in getting the python code to read the com port, in our case COM4. We have put the pyserial module on our computer but it does not include the serial.py statement needed to get us to the serial port. We are using the FTDI cable with the proper drivers and we can get packets of data into the terminal window as per the instructions on the previous steps.
however we cannot run this code:
from xbee import xbee
import serial
SERIALPORT = "COM4" # the com/serial port the XBee is connected to
BAUDRATE = 9600 # the baud rate we talk to the xbee
# open up the FTDI serial port to get data transmitted to xbee
ser = serial.Serial(SERIALPORT, BAUDRATE)
ser.open()
while True:
# grab one packet from the xbee, or timeout
packet = xbee.find_packet(ser)
if packet:
xb = xbee(packet)
print xb
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: serial communications question
did you install pyserial?
-
- Posts: 4
- Joined: Wed Jun 24, 2009 11:48 am
Re: serial communications question
yes indeed, we installed the pyserial module.
We have been able to get it to print one packet of xbee data at a time. This is only possible if we type each line of code manually into the python shell. Otherwise we cannot run the actual code with the "while" and "if" statements we get an error message:
Serial Exception cannot open port COM4
We have been able to get it to print one packet of xbee data at a time. This is only possible if we type each line of code manually into the python shell. Otherwise we cannot run the actual code with the "while" and "if" statements we get an error message:
Serial Exception cannot open port COM4
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: serial communications question
it would have been handy if you said what the error was 4 messages ago.
make sure nothing else is using that port. only one program can access a COM port at time
make sure nothing else is using that port. only one program can access a COM port at time
-
- Posts: 4
- Joined: Wed Jun 24, 2009 11:48 am
Re: serial communications question
Thanks we realized it too. Now we are having problems installing a simplejson module so that we can get wattcher.py to work.
So far we are having some bad luck getting simplejson to add itself as a module in python. Any good links to how we can do this?
Thanks,
Dimos
So far we are having some bad luck getting simplejson to add itself as a module in python. Any good links to how we can do this?
Thanks,
Dimos
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: serial communications question
hmm i think you can just stick it in the same folder as the tweetawatt code. its not a happy installing module like the others. you're almost done!
Please be positive and constructive with your questions and comments.