forked from fmueller/esp8266-led-marquee-sign-controller
Add Python server script for reverse engineering
This commit is contained in:
parent
09e8e75edc
commit
55cc608454
42
tools/re-server.py
Normal file
42
tools/re-server.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""
|
||||
Simple socket server used to reverse engineer the messaging protocol the bundled software uses to send data to the
|
||||
LED sign.
|
||||
|
||||
The server just dumps incoming messages in a hexdump-like format as well as an easy to read Python bytestring.
|
||||
"""
|
||||
|
||||
|
||||
import asyncio
|
||||
import string
|
||||
|
||||
|
||||
async def handle_client(reader, writer):
|
||||
message = await reader.read(255)
|
||||
|
||||
hex_chars = [hex(j)[2:].zfill(2) for j in message]
|
||||
|
||||
ascii_chars = []
|
||||
for j in message:
|
||||
char = chr(j)
|
||||
if char in (string.ascii_letters + string.digits + string.punctuation):
|
||||
ascii_chars.append(char)
|
||||
else:
|
||||
ascii_chars.append(".")
|
||||
|
||||
print("Message received: ", end="")
|
||||
print(" ".join(hex_chars), end=" | ")
|
||||
print("".join(ascii_chars), end=" | ")
|
||||
print("".join(repr(message)))
|
||||
|
||||
writer.close()
|
||||
|
||||
|
||||
async def run_server():
|
||||
server = await asyncio.start_server(handle_client, '', 3000)
|
||||
async with server:
|
||||
await server.serve_forever()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(run_server())
|
||||
|
Loading…
Reference in New Issue
Block a user