Skip to content

Commit 40315e7

Browse files
authored
Merge pull request #44 from AgriConnect/feature/platformio
2 parents 9e87a79 + e930766 commit 40315e7

10 files changed

Lines changed: 675 additions & 396 deletions

File tree

.clang-format

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
# Same as VS Code default style, but change BreakBeforeBraces.
3+
BasedOnStyle: LLVM
4+
UseTab: Never
5+
IndentWidth: 4
6+
TabWidth: 4
7+
---
8+
Language: Cpp
9+
BreakBeforeBraces: Linux
10+
AllowShortIfStatementsOnASingleLine: false
11+
IndentCaseLabels: false
12+
ColumnLimit: 0
13+
AccessModifierOffset: -4
14+
NamespaceIndentation: All
15+
FixNamespaceComments: false
16+
---

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,11 @@
44
*.map
55
*.srec
66
*.eep
7-
*.lss
7+
*.lss
8+
.pio
9+
.pioenvs
10+
.piolibdeps
11+
.vscode/
12+
__pycache__
13+
dist
14+
.pdm-python

host/min.py

Lines changed: 318 additions & 130 deletions
Large diffs are not rendered by default.

host/soak.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
from min import MINTransportSerial, min_logger
1010

1111

12-
MIN_PORT = '/dev/tty.usbmodem1421'
12+
MIN_PORT = "/dev/tty.usbmodem1421"
1313

1414

1515
def bytes_to_int32(data: bytes, big_endian=True) -> int:
1616
if len(data) != 4:
1717
raise ValueError("int32 shoud be exactly 4 bytes")
1818
if big_endian:
19-
return unpack('>I', data)[0]
19+
return unpack(">I", data)[0]
2020
else:
21-
return unpack('<I', data)[0]
21+
return unpack("<I", data)[0]
2222

2323

2424
def wait_for_frames(min_handler: MINTransportSerial, timeout=3.0):
@@ -35,7 +35,7 @@ def soak_test():
3535
min_handler = MINTransportSerial(port=MIN_PORT, loglevel=DEBUG)
3636
min_handler.fake_errors = True
3737

38-
min_log_handler = FileHandler('min.log')
38+
min_log_handler = FileHandler("min.log")
3939
min_logger.addHandler(min_log_handler)
4040

4141
# Tell the target that we are resetting to start a session
@@ -56,13 +56,15 @@ def soak_test():
5656
min_ids.append(min_id)
5757
payloads.append(payload)
5858
# Send a frame on the serial line
59-
print(">>>>>>>>>>>>>>>> Sending ID={} payload len={}".format(min_id, payload_size))
59+
print(f">>>>>>>>>>>>>>>> Sending ID={min_id} payload len={payload_size}")
6060
min_handler.queue_frame(min_id=min_id, payload=payload)
6161

6262
while True:
6363
# Wait for the frames to come back
6464
for frame in wait_for_frames(min_handler):
65-
print(">>>>>>>>>>>>>>>> Got frame min_id={}, payload len={}".format(frame.min_id, len(frame.payload)))
65+
print(
66+
f">>>>>>>>>>>>>>>> Got frame min_id={frame.min_id}, payload len={frame.payload}"
67+
)
6668
if frame.min_id != min_ids[0]:
6769
raise AssertionError("Failed: did not get back the MIN ID we sent")
6870
if frame.payload != payloads[0]:
@@ -76,4 +78,4 @@ def soak_test():
7678

7779

7880
if __name__ == "__main__":
79-
soak_test()
81+
soak_test()

library.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "min",
3+
"version": "2.0.0",
4+
"description": "Simple point-to-point frame based protocol designed to connect a microcontroller to a PC (or other microcontroller).",
5+
"keywords": "protocol",
6+
"repository": {
7+
"type": "git",
8+
"url": "https://github.com/min-protocol/min.git"
9+
},
10+
"authors": [
11+
{
12+
"name": "JK Energy Ltd"
13+
}
14+
],
15+
"license": "MIT",
16+
"frameworks": "*",
17+
"platforms": "*",
18+
"build": {
19+
"srcDir": "target",
20+
"srcFilter": [
21+
"+<*.c>",
22+
"+<*.h>"
23+
]
24+
}
25+
}

pdm.lock

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

py.typed

Whitespace-only changes.

pyproject.toml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
[project]
2+
name = "min-proto"
3+
version = "2.0.0"
4+
description = "Microcontroller Interconnect Network protocol"
5+
authors = [
6+
{name = "Ken Tindell"},
7+
]
8+
maintainers = [
9+
{name = "Nguyễn Hồng Quân", email = "ng.hong.quan@gmail.com"},
10+
]
11+
dependencies = [
12+
"pyserial>=3.5"
13+
]
14+
requires-python = ">=3.10"
15+
readme = "README.md"
16+
license = {text = "MIT"}
17+
18+
[build-system]
19+
requires = ["hatchling"]
20+
build-backend = "hatchling.build"
21+
22+
[tool.hatch.build.targets.sdist]
23+
packages = ["host/min.py", "py.typed"]
24+
25+
[tool.hatch.build.targets.wheel]
26+
packages = ["host/min.py", "py.typed"]
27+
28+
[tool.pdm]
29+
distribution = true

0 commit comments

Comments
 (0)