-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from rogy-AquaLab/impl-communicate
NucleoとのUART実装
- Loading branch information
Showing
7 changed files
with
130 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
device/nucleo_communicate_py/nucleo_communicate_py/mutex_serial.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from contextlib import contextmanager | ||
from threading import Lock | ||
|
||
from serial import Serial | ||
|
||
|
||
class MutexSerial: | ||
def __init__(self, *args, **kwargs) -> None: | ||
self._lock = Lock() | ||
self._ser = Serial(*args, **kwargs) | ||
|
||
@contextmanager | ||
def lock(self): | ||
with self._lock: | ||
yield self._ser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
std_msgs/Header header | ||
|
||
# nucleoから送られてきた値そのまま | ||
# TODO: 値の範囲は 0~0xFFFFFFFF で決まっているが、どちらが曲がっている側か決める | ||
# TODO: 値の範囲は 0~0xFFFF で決まっているが、どちらが曲がっている側か決める | ||
uint16 value |