aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Van Iseghem <[email protected]>2023-09-13 19:07:14 +0200
committerThomas Van Iseghem <[email protected]>2023-09-13 19:07:14 +0200
commit16d990783c9b2367a4854cd539e8efa83668ef69 (patch)
treef614c3100ade4f8cdf0d03bf5aabcf944fc89551
parent3f726f67f29ba78ae32bc726611e068c695962b8 (diff)
downloadOpenCortex-16d990783c9b2367a4854cd539e8efa83668ef69.tar.gz
OpenCortex-16d990783c9b2367a4854cd539e8efa83668ef69.zip
Created basic script for reading stomp data traffic + stomp bytes explained
-rw-r--r--Stomps/README.md34
-rw-r--r--Stomps/read_stomp.py50
2 files changed, 84 insertions, 0 deletions
diff --git a/Stomps/README.md b/Stomps/README.md
new file mode 100644
index 0000000..33e23e1
--- /dev/null
+++ b/Stomps/README.md
@@ -0,0 +1,34 @@
+## Stomp message byte examples:
+
+**Action: button | Value: pressed**
+```
+9a e5 01 65 92 bf 0c 00 01 00 11 01 01 00 00 00 9a e5 01 65 92 bf 0c 00 00 00 00 00 00 00 00 00
+```
+
+**Action: button | Value: released**
+```
+9b e5 01 65 4b 74 0b 00 01 00 11 01 00 00 00 00 9b e5 01 65 4b 74 0b 00 00 00 00 00 00 00 00 00
+```
+
+**Action: rotary | Value: clock wise**
+```
+9d e5 01 65 ac 83 04 00 02 00 08 00 01 00 00 00 9d e5 01 65 ac 83 04 00 00 00 00 00 00 00 00 00
+```
+
+**Action: rotary | Value: counter clock**
+```
+9e e5 01 65 40 e8 05 00 02 00 08 00 ff 00 00 00 9e e5 01 65 40 e8 05 00 00 00 00 00 00 00 00 00
+```
+
+It seems that a 32 bytes message is divided into 2 parts of 16 bytes.
+
+### Part 1 (First 16 bytes)
+| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
+|---|---|---|---|---|---|---|---|---|---|--------|--------|-------|---------|---------|---------|
+| time | time | time | time | time | time | time | padding? | action | action | action | action | value | padding | padding | padding |
+
+### Part 1 (First 16 bytes)
+- 0 -> 6 are duplicates
+- 7 -> 15 are padding
+
+From first sight, this part look quite useless. Not sure why it's even there. \ No newline at end of file
diff --git a/Stomps/read_stomp.py b/Stomps/read_stomp.py
new file mode 100644
index 0000000..516db24
--- /dev/null
+++ b/Stomps/read_stomp.py
@@ -0,0 +1,50 @@
+class StompEvent:
+ def __init__(self, raw_bytes):
+ self.raw_bytes = raw_bytes
+ self.action = "unknown"
+ self.value = "unknown"
+ self.decode_bytes()
+
+ def print_bytes(self):
+ bytes_str = ""
+ for i in range(len(self.raw_bytes)):
+ bytes_str = bytes_str + self.raw_bytes[i].encode('hex') + ' '
+ print bytes_str
+ print '---'*32
+
+ def decode_bytes(self):
+ action_byte_1 = self.raw_bytes[10].encode('hex')
+ action_byte_2 = self.raw_bytes[11].encode('hex')
+ value_byte = self.raw_bytes[12].encode('hex')
+
+ if(action_byte_1 == "11" and action_byte_2 == "01"):
+ self.action = "button"
+ elif(action_byte_1 == "08" and action_byte_2 == "00"):
+ self.action = "rotary"
+
+ if(value_byte == "00"):
+ self.value = "released"
+ elif(value_byte == "01"):
+ if(self.action == "button"):
+ self.value = "pressed"
+ elif(self.action == "rotary"):
+ self.value = "clock wise"
+ elif(value_byte == "ff"):
+ self.value = "counter clock"
+
+ def __str__(self):
+ return "Action: " + self.action + " | Value: " + self.value
+
+with open('/dev/zencoder/knob_stomp2', 'rb') as file:
+ byte_buffer = []
+ while True:
+ byte = file.read(1)
+ if not byte:
+ break
+
+ byte_buffer.append(byte)
+ if len(byte_buffer) is 32:
+ event = StompEvent(byte_buffer)
+ print event
+ event.print_bytes()
+ byte_buffer = [] \ No newline at end of file