forked from SoC-Arch-polito/cnt21
-
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.
- Loading branch information
1 parent
f6cd688
commit 040d633
Showing
6 changed files
with
40 additions
and
24 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,35 @@ | ||
#!/usr/bin/python3.9 | ||
|
||
from os import times | ||
import serial | ||
from sys import argv | ||
from datetime import datetime | ||
import time | ||
import socket | ||
|
||
|
||
if __name__ == "__main__": | ||
ser = serial.Serial(port= argv[1], baudrate=argv[2]) | ||
print(ser.name) | ||
|
||
ser.write(bytearray("get\r".encode())) | ||
entry = ser.read(5) | ||
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||
s.connect(("127.0.0.1", 1234)) | ||
s.settimeout(1) | ||
|
||
s.send("\r".encode('utf-8')) | ||
time.sleep(1) | ||
s.recv(1024) | ||
|
||
s.send("get\r".encode('utf-8')) | ||
time.sleep(1) | ||
s.recv(5) | ||
|
||
totb = 0 | ||
time.sleep(1) | ||
while ser.inWaiting() > 5: | ||
entry = ser.read(6) | ||
totb += 6 | ||
# print(entry.hex()) | ||
while True: | ||
try: | ||
entry = s.recv(6) | ||
except: | ||
exit(0) | ||
|
||
timestamp = int.from_bytes(entry[0:4], "little") | ||
cnt = int.from_bytes(entry[4:6], "little") | ||
|
||
print(f"{datetime.utcfromtimestamp(timestamp).strftime('%d/%m/%Y %H/%M/%S')} -- {cnt} -- tot: {totb}") | ||
print(f"{datetime.utcfromtimestamp(timestamp).strftime('%d/%m/%Y %H/%M/%S')} -- {cnt}") | ||
|
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