-
Notifications
You must be signed in to change notification settings - Fork 0
/
diag.go
128 lines (99 loc) · 2.98 KB
/
diag.go
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
package main
import (
"bytes"
"fmt"
"io/ioutil"
"github.com/chinenual/synergize/data"
"github.com/chinenual/synergize/logger"
"github.com/chinenual/synergize/synio"
)
func diagCOMTST() {
if err := synio.DiagCOMTST(); err != nil {
logger.Errorf("%s\n", err)
logger.Errorf("Note:\n\tThe Synergy must be running in COMTST mode before executing this test.\n\tPress RESTORE + PROGRAM 4 on the Synergy then rerun this program.\n")
} else {
logger.Infof("SUCCESS!\n")
}
}
func diagLOOPTST() {
fmt.Printf("\nEntering LOOPBACK mode - any byte received from the Synergy is echo'd back\n")
fmt.Printf("Start the test by pressing RESTORE + RESTORE + PROGRAM 1 on the Synergy\n")
if err := synio.DiagLOOPTST(); err != nil {
logger.Errorf("%s\n", err)
}
}
func diagLINKTST() {
fmt.Printf("\nEntering LINK TEST mode - any byte you type is sent to the Synergy and is \n")
fmt.Printf("echo'd back. LED's on the Synergy show the bytes received and various status\n")
fmt.Printf("registers of the Synergy's serial connection.\n")
fmt.Printf("\nStart the test by pressing RESTORE + PROGRAM 4 on the Synergy\n")
if err := synio.DiagLINKTST(); err != nil {
logger.Errorf("%s\n", err)
}
}
func diagInitAndPrintFirmwareID() (err error) {
var version [2]byte
if version, err = synio.GetID(); err != nil {
logger.Errorf("%s\n", err)
return
}
logger.Infof("Synergy is running firmware version %d.%d\n", version[0], version[1])
return
}
var slotnum byte = 1
func diagLoadVCE(path string) (err error) {
var vce_bytes []byte
if vce_bytes, err = ioutil.ReadFile(path); err != nil {
return
}
logger.Infof("VCE %s -- %d bytes into slotnum %d\n", path, len(vce_bytes), slotnum)
if err = synio.LoadVCE(slotnum, vce_bytes); err != nil {
return
}
// load the next one in the next slot
slotnum++
return
}
func diagLoadCRT(path string) (err error) {
var crt_bytes []byte
if crt_bytes, err = ioutil.ReadFile(path); err != nil {
return
}
logger.Infof("CRT %s -- %d bytes \n", path, len(crt_bytes))
err = synio.LoadCRTBytes(crt_bytes)
return
}
func diagSaveSYN(path string) (err error) {
var syn_bytes []byte
if syn_bytes, err = synio.SaveSYN(); err != nil {
return
}
logger.Infof("SYN %s -- %d bytes \n", path, len(syn_bytes))
err = ioutil.WriteFile(path, syn_bytes, 0644)
return
}
func diagSaveVCE(path string) (err error) {
var dumpedBytes []byte
if dumpedBytes, err = synio.DumpVRAM(); err != nil {
return
}
var readbuf = bytes.NewReader(dumpedBytes)
var dumpedCrt data.CRT
var dumpedVce data.VCE
if dumpedCrt, err = data.ReadCrt(readbuf); err != nil {
logger.Errorf("error parsing dumpedVRAM %v", err)
return
}
dumpedVce = *dumpedCrt.Voices[0]
logger.Infof("VCE %s -- %d bytes: %s\n", path, len(dumpedBytes), data.VceToJson(dumpedVce))
err = data.WriteVceFile(path, dumpedVce, false)
return
}
func diagLoadSYN(path string) (err error) {
var syn_bytes []byte
if syn_bytes, err = ioutil.ReadFile(path); err != nil {
return
}
err = synio.LoadSYN(syn_bytes)
return
}