Ask Your Question
1

read from serial port

asked 2011-08-01 18:47:22 +0100

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 19:28:59 +0100

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 19:43:30 +0100 )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 19:44:39 +0100 )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 19:45:31 +0100 )edit

>import pyserial No module named serial

Bill gravatar imageBill ( 2011-08-01 19:47:28 +0100 )edit

import pyserial-2.5 SyntaxError: invalid syntax

Bill gravatar imageBill ( 2011-08-01 19:47:52 +0100 )edit
0

answered 2011-08-02 22:17:24 +0100

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 18:47:22 +0100

Seen: 997 times

Last updated: Aug 02 '11