Ask Your Question
1

read from serial port

asked 2011-08-01 11:47:22 -0500

Bill gravatar image

I'm trying to get sagemath to read from my USB port which has an arduino attached to it. The arduino is throwing a bunch of text to the serial port with address /dev/ttyUSB0

A preliminary Google search reveals that there is a python library pySerial which is designed to do just this. Can I make sagemath recognize this library somehow?

Thanks!

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2011-08-01 12:28:59 -0500

benjaminfjones gravatar image

You should install the python library using sage -python. See the answer to this related question: http://ask.sagemath.org/question/537/...

edit flag offensive delete link more

Comments

I executed this commange from the pySerial folder: sage -python setup.py install

Bill gravatar imageBill ( 2011-08-01 12:43:30 -0500 )edit

now in a sage notebook, my commands "import serial" "import pySerial" "import pyserial-2.5, etc all give errors.

Bill gravatar imageBill ( 2011-08-01 12:44:39 -0500 )edit

It would be helpful if you post the actual code that produces the error and the error itself.

benjaminfjones gravatar imagebenjaminfjones ( 2011-08-01 12:45:31 -0500 )edit

>import pyserial No module named serial

Bill gravatar imageBill ( 2011-08-01 12:47:28 -0500 )edit

import pyserial-2.5 SyntaxError: invalid syntax

Bill gravatar imageBill ( 2011-08-01 12:47:52 -0500 )edit
0

answered 2011-08-02 15:17:24 -0500

Bill gravatar image

This ended up working for me, both in command line, and notebook:

cmd_folder = os.path.dirname(os.path.abspath('/home/william/pyserial-2.5/serial'))
if cmd_folder not in sys.path:
    sys.path.insert(0, cmd_folder)
import serial

I found the solution here.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2011-08-01 11:47:22 -0500

Seen: 465 times

Last updated: Aug 02 '11