Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Pierre NARVOR
seatrac_driver
Commits
03adaace
Commit
03adaace
authored
Jul 13, 2021
by
Pierre NARVOR
Browse files
[driver/python] Added base of serial driver in python
parent
78dbafe4
Changes
6
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
03adaace
.*.sw*
build
docs
.*.sw*
__pycache__
*.egg-info
*.pick
*.tif
*.ply
*.pyc
output
python/seatrac_usbl/SeatracSerial.py
0 → 100644
View file @
03adaace
import
serial
import
asyncio
import
time
import
threading
class
SeatracSerial
:
def
__init__
(
self
,
device
,
baudrate
=
115200
):
self
.
serial
=
serial
.
Serial
(
device
,
baudrate
)
self
.
serial
.
bytesize
=
serial
.
EIGHTBITS
self
.
serial
.
parity
=
serial
.
PARITY_NONE
self
.
serial
.
stopbits
=
serial
.
STOPBITS_TWO
self
.
serial
.
rtscts
=
False
self
.
serial
.
dsrdtr
=
False
self
.
serial
.
timeout
=
1e-3
self
.
running
=
False
self
.
thread
=
None
async
def
run
(
self
):
self
.
running
=
True
while
self
.
running
:
part
=
self
.
serial
.
read
(
1024
)
while
len
(
part
)
>
0
:
print
(
part
)
part
=
self
.
serial
.
read
(
1024
)
await
asyncio
.
sleep
(
0.05
)
def
start
(
self
,
background
=
False
):
self
.
serial
.
flush
()
if
background
:
self
.
thread
=
threading
.
Thread
(
target
=
lambda
:
asyncio
.
run
(
self
.
run
()))
self
.
thread
.
start
()
else
:
asyncio
.
run
(
self
.
run
())
def
stop
(
self
):
self
.
running
=
False
if
self
.
thread
is
not
None
:
self
.
thread
.
join
()
python/seatrac_usbl/__init__.py
0 → 100644
View file @
03adaace
from
.SeatracSerial
import
SeatracSerial
python/setup.py
0 → 100644
View file @
03adaace
from
setuptools
import
setup
,
find_packages
setup
(
name
=
'seatrac_usbl'
,
version
=
'0.1'
,
description
=
'Interface for the Blueprint Seatrac USBL'
,
author
=
'Pierre Narvor'
,
author_email
=
'pierre.narvor@ensta-bretagne.fr'
,
licence
=
'confidential'
,
packages
=
find_packages
(
include
=
[
'seatrac_usbl'
]),
install_requires
=
[
'numpy'
,
'matplotlib'
,
'pyserial'
,
],
zip_safe
=
False
)
python/tests/async_serial.py
0 → 100644
View file @
03adaace
#! /usr/bin/python3
import
asyncio
import
serial
s
=
serial
.
Serial
(
'/dev/narval_usbl'
,
115200
)
s
.
bytesize
=
serial
.
EIGHTBITS
s
.
parity
=
serial
.
PARITY_NONE
s
.
stopbits
=
serial
.
STOPBITS_TWO
s
.
rtscts
=
False
s
.
dsrdtr
=
False
s
.
timeout
=
1e-1
s
.
flush
()
readSize
=
1024
async
def
read_until
():
part
=
s
.
read
(
256
)
while
len
(
part
)
>
0
:
print
(
part
)
part
=
s
.
read
(
256
)
await
asyncio
.
sleep
(
0.01
)
async
def
start
():
await
asyncio
.
gather
(
read_until
())
asyncio
.
run
(
start
())
python/tests/seatrac_serial.py
0 → 100644
View file @
03adaace
#! /usr/bin/python3
from
seatrac_usbl
import
SeatracSerial
serial
=
SeatracSerial
(
'/dev/narval_usbl'
)
serial
.
start
(
background
=
True
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment