First time here? Check out the FAQ!

Ask Your Question
1

read from serial port

asked 13 years ago

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!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 13 years ago

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/...

Preview: (hide)
link

Comments

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

Bill gravatar imageBill ( 13 years ago )

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

Bill gravatar imageBill ( 13 years ago )

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

benjaminfjones gravatar imagebenjaminfjones ( 13 years ago )

>import pyserial No module named serial

Bill gravatar imageBill ( 13 years ago )

import pyserial-2.5 SyntaxError: invalid syntax

Bill gravatar imageBill ( 13 years ago )
0

answered 13 years ago

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.

Preview: (hide)
link

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: 13 years ago

Seen: 1,025 times

Last updated: Aug 02 '11