-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck_fr60_standard.py
executable file
·64 lines (45 loc) · 1.56 KB
/
check_fr60_standard.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3.10
'''
This uses a CAN link layer to check response to standard (not extended) frames
Usage:
python3.10 check_fr60_standard.py
The -h option will display a full list of options.
'''
import sys
import logging
from openlcb.nodeid import NodeID
from openlcb.canbus.canframe import CanFrame
from openlcb.canbus.controlframe import ControlFrame
from queue import Empty
import olcbchecker.setup
def check():
# set up the infrastructure
logger = logging.getLogger("FRAME")
ownnodeid = olcbchecker.setup.configure.ownnodeid
targetnodeid = olcbchecker.setup.configure.targetnodeid
timeout = 0.01
olcbchecker.purgeFrames()
localAlias = olcbchecker.setup.canLink.localAlias # just to be shorter
###############################
# checking sequence starts here
###############################
# pull any early received messages
olcbchecker.purgeMessages()
for i in range(0, 2047) :
# send a standard frame in format :S1234N;
frame = ":S{:04X}N;".format(i)
olcbchecker.setup.sendToSocket(frame)
# see if there's been a response - this could be done at the end to save time?
try :
frame = olcbchecker.getFrame(timeout)
logger.warning ("Frame received in response")
return 3
except Empty:
pass # this is normal
logger.info("Passed")
return 0
if __name__ == "__main__":
result = check()
import olcbchecker
olcbchecker.setup.interface.close()
sys.exit(result)