This repository was archived by the owner on Dec 3, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbinboard.py
More file actions
executable file
·38 lines (34 loc) · 1.44 KB
/
binboard.py
File metadata and controls
executable file
·38 lines (34 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#! /usr/bin/python3
"""Print the binary data from the Arduino as it comes in."""
# LiBoard
# Copyright (C) 2021 Philipp Leclercq
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as published by
# the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
import argparse
from bitstring import Bits
from serial import Serial
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-p', '--port', default='/dev/ttyACM0',
help='The serial port which the board is connected to (Default /dev/ttyACM0)')
parser.add_argument('-b', '--baud-rate', default=9600, type=int, help='The board\'s baud rate (Default 9600)')
args = parser.parse_args()
try:
with Serial(args.port, args.baud_rate) as arduino:
while True:
if arduino.in_waiting >= 8:
data = Bits(arduino.read(8))
print(data.bin)
print()
except KeyboardInterrupt:
pass