-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathmicon_startup.py
More file actions
executable file
·85 lines (63 loc) · 1.96 KB
/
micon_startup.py
File metadata and controls
executable file
·85 lines (63 loc) · 1.96 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/python3
import libmicon
import platform
###make miconv2 and v3 start up tasks functions.
def startupV2(port):
test = libmicon.micon_api(port)
micon_version = test.send_read_cmd(0x83)
micon_version=micon_version.decode('utf-8')
##disable boot watchdog
test.send_write_cmd(0,0x03)
file = open("/etc/debian_version", "r")
version= "Debian " + file.readline().strip()
version = version.center(16)
title = "Terastation " + platform.machine()[:3].upper()
### need to understand variations of this
##turn of red drive leds
test.cmd_set_led(libmicon.LED_OFF,[0x00,0x0F])
test.set_lcd_buffer(0x90,title,version)
test.cmd_force_lcd_disp(libmicon.lcd_disp_buffer0)
test.send_write_cmd(1,libmicon.lcd_set_dispitem,0x20)
test.set_lcd_brightness(libmicon.LCD_BRIGHT_FULL)
if (micon_version.find("HTGL") == -1):
test.set_lcd_color(libmicon.LCD_COLOR_GREEN)
test.cmd_set_led(libmicon.LED_ON,libmicon.POWER_LED)
test.port.close()
def startupV3(port):
test = libmicon.micon_api_v3(port)
##disable watchdog
test.send_miconv3("BOOT_END")
file = open("/etc/debian_version", "r")
version= "Debian " + file.readline().strip()
version = version.center(16,u"\u00A0")
title = "Terastation " + platform.machine()[:3].upper()
print(test.set_lcd(0,title))
print(test.set_lcd(1,version))
##solid power LED
test.set_led(0,"on")
test.port.close()
# check for some sort of config file to avoid messing with ports each time?
##try reading micon version from each port to determine the right one
for port in ["/dev/ttyS1","/dev/ttyS3"]:
try:
test = libmicon.micon_api(port)
except:
continue
micon_version = test.send_read_cmd(0x83)
if micon_version:
test.port.close()
startupV2(port)
quit()
test.port.close()
for port in ["/dev/ttyUSB0","/dev/ttyS1","/dev/ttyS0"]:
try:
test = libmicon.micon_api_v3(port)
except:
continue
micon_version = test.send_miconv3("VER_GET")
if micon_version:
test.port.close()
startupV3(port)
quit()
test.port.close()
quit()