PDA

View Full Version : Serial I/O from SNAPpy?


kbanks
07-07-2008, 02:55 PM
(paraphrasing an email)

Does the core firmware support opening up a serial connection in a Python script? I'm wanting to verify that I can open, read, and write the serial port in Python.

By "Python", I assume in this case you mean SNAPpy. Full "desktop" Python can do anything (the Python motto is "batteries included"). This includes opening, reading, and writing serial ports. Portal is written in Python, and can connect to "bridge" nodes via serial ports (plus USB too).

Back to SNAPpy... Yes, you can use the RF Engine serial ports from SNAPpy. However, the programming model used is not "open, read, write".

To use a RF Engine serial port from SNAPpy, you must first initialize the serial port, using the initUart() and flowControl() built-in functions.

You must then use the built-in crossConnect() function to make the serial port be SNAPpy's "console". By this I mean that the serial port will become SNAPpy's STDIN and STDOUT device.

Once a script does this crossConnect(), any print statements will send data out the serial port (so you print instead of write, but the end result is the same).

Also, any characters that come in that serial port will be passed to the SNAPpy HOOK_STDIN handler. So you do not call a read() function, instead the arrival of data calls a function in your script for you.

Look at the CommandLine.py example script that comes with the EK2500 Evaluation Kit for a concrete example of this.

Once you register on this forum, you can download all the manuals directly from it. That would be one way to get the SN171 manual, and the SNAP Reference manual.

Please post a follow-up question on this thread if I have not answered your question