forked from Sevenstax/FreeV2G
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFramingAPIDef.py
33 lines (29 loc) · 865 Bytes
/
FramingAPIDef.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import random
import string
class Frame (object):
def __init__(self):
self.mod_id = 0
self.mod_name = ""
self.sub_id = 0
self.sub_name = 0
self.req_id = 0
self.payload_len = 0
self.payload = b""
crc = 0
# add dict access for backwards compatibility
def __getitem__(self, key):
if key == "payload":
return self.payload
elif key == "subroutine":
return {"id": self.sub_id, "interpretation": self.sub_name}
elif key == "module":
return {"id": self.mod_id, "interpretation": self.mod_name}
elif key == "crc":
return self.crc
elif key == "req_id":
return self.req_id
MODULE_IDS = {}
START_OF_FRAME = 0xc0
END_OF_FRAME = 0xc1
START_OF_ENCR_FRAME = 0xfe
END_OF_ENCR_FRAME = 0xff