Created
December 21, 2023 06:05
-
-
Save hareendranmg/3df860bb3e7d729c3245348a3b7cd1eb to your computer and use it in GitHub Desktop.
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
# 22495555,0000,0000,0000,00007333,0000093D,0000,7334,08E3,00032665,000024F7,142B,0000,FFA0,FFC9,22495555,0010C90C,\n | |
import serial | |
import time | |
import os | |
port_name = "/dev/ttyUSB0" | |
baud_rate = 2000000 | |
serial_port = serial.Serial(port_name, baud_rate, | |
parity=serial.PARITY_ODD, | |
stopbits=serial.STOPBITS_ONE, | |
bytesize=serial.EIGHTBITS) | |
data_to_write = "22495555,0000,0000,0000,00007333,0000093D,0000,7334,08E3,00032665,000024F7,142B,0000,FFA0,FFC9,22495555,0010C90C,\n" | |
# data_to_write = "safsafasfsaf" | |
if serial_port: | |
try: | |
while True: | |
write_data = serial_port.write(data_to_write.encode()) | |
print(f"Wrote: {write_data}") | |
time.sleep(0.090) | |
except KeyboardInterrupt: | |
pass | |
finally: | |
serial_port.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment