Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow serial baudrate and show usage in example #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ alphasign is a Python library for
[Betabrite](http://www.betabrite.com/). It implements the
[Alpha Communications Protocol](http://www.alpha-american.com/p-alpha-communications-protocol.html).

[Read the Docs](http://readthedocs.org/docs/alphasign)
[Read the Docs](https://alphasign.readthedocs.io/en/latest/)

![Betabrite Prisom displaying the time and temperature updated by a program using the alphasign library.](http://farm9.staticflickr.com/8010/7151560649_2d5f04955b.jpg)
1 change: 1 addition & 0 deletions alphasign/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

def main():
sign = alphasign.USB(alphasign.devices.USB_BETABRITE_PRISM)
# sign = alphasign.interfaces.local.Serial(device='/dev/ttyUSB0', baudrate=38400) # serial version
sign.connect()
sign.clear_memory()

Expand Down
7 changes: 5 additions & 2 deletions alphasign/interfaces/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,15 @@ class Serial(base.BaseInterface):

This class uses `pySerial <http://pyserial.sourceforge.net/>`_.
"""
def __init__(self, device="/dev/ttyS0"):
def __init__(self, device="/dev/ttyS0", baudrate=4800):
"""
:param device: character device (default: /dev/ttyS0)
:type device: string
:param baudrate: baudrate (default: 4800)
:type baudrate: integer
"""
self.device = device
self.baudrate = baudrate
self.debug = True
self._conn = None

Expand All @@ -25,7 +28,7 @@ def connect(self):
# TODO(ms): these settings can probably be tweaked and still support most of
# the devices.
self._conn = serial.Serial(port=self.device,
baudrate=4800,
baudrate=self.baudrate,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.SEVENBITS,
Expand Down