-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.go
59 lines (51 loc) · 1.08 KB
/
main.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
package main
import (
"encoding/hex"
"fmt"
"github.com/anoopengineer/edidparser/edid"
"io/ioutil"
"log"
"os"
"strings"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Please pass the input filename as an argument")
os.Exit(1)
}
fileName := os.Args[1]
bs, err := ioutil.ReadFile(fileName)
if err != nil {
fmt.Println("Unable to read file", fileName)
os.Exit(1)
}
str := string(bs)
str = strings.Replace(str, " ", "", -1)
str = strings.Replace(str, "\r\n", "", -1)
str = strings.Replace(str, "\n", "", -1)
str = strings.TrimSpace(str)
//fmt.Printf("%s\n", str)
edidBytes, _ := hex.DecodeString(str)
printEdidBytes(edidBytes)
e, err := edid.NewEdid(edidBytes)
//fmt.Println("Man - " + e.PrintableManufacturerId())
fmt.Println()
if err != nil {
log.Fatal("Unable to parse EDID ", err)
} else {
e.PrettyPrint()
}
}
func printEdidBytes(edid []byte) {
fmt.Println("EDID dump")
columnCounter := 0
for i := 0; i < len(edid); i++ {
fmt.Printf("%02X ", edid[i])
if columnCounter == 15 {
fmt.Println()
columnCounter = 0
} else {
columnCounter++
}
}
}