Browse Source

Adapter for nucleo-f411-logger with w5500

Dmitry Yu Okunev 8 years ago
parent
commit
1c3a107934
2 changed files with 10 additions and 4 deletions
  1. 6 3
      main.go
  2. 4 1
      voltloggerParser/voltloggerParser.go

+ 6 - 3
main.go

@@ -77,20 +77,23 @@ func main() {
 	var printRow_arg	printRow_arg
 	var channelsNumInt	int
 	var channelsNum		uint8
+	var adc8Bit		bool
 
 	getopt.StringVar(&dumpPath,			'i',	"dump-path"		)
 	getopt.StringVar(&printRow_arg.outputPath,	'o',	"output-path"		).SetOptional()
 	getopt.BoolVar  (&noHeaders,			'n',	"no-headers"		).SetOptional()
 	getopt.IntVar   (&channelsNumInt,		'c',	"force-channels-num"	).SetOptional()
-	channelsNum = uint8(channelsNumInt)
 	getopt.BoolVar  (&printRow_arg.binaryOutput,	'b',	"binary-output"		).SetOptional()
 	getopt.BoolVar  (&printRow_arg.insertParseTime,	't',	"insert-parse-time"	).SetOptional()
+	getopt.BoolVar  (&adc8Bit,			'8',	"adc-8-bit"		).SetOptional()
 
 	getopt.Parse()
 	if (getopt.NArgs() > 0 || dumpPath == "") {
 		getopt.Usage()
 		os.Exit(-2)
 	}
+	channelsNum = uint8(channelsNumInt)
+
 	switch (printRow_arg.outputPath) {
 /*		case "":
 			now              := time.Now()
@@ -115,9 +118,9 @@ func main() {
 	//	err = binary.Write(printRow_arg.outputFile, binary.LittleEndian, printRow_arg)
 	//}
 
-	err = voltloggerParser.ParseVoltloggerDump(dumpPath, noHeaders, channelsNum, handleHeader, printRow, &printRow_arg)
+	err = voltloggerParser.ParseVoltloggerDump(dumpPath, noHeaders, channelsNum, adc8Bit, handleHeader, printRow, &printRow_arg)
 	if (err != nil) {
-		fmt.Printf("Cannot parse the dump: %v\n", err.Error())
+		fmt.Printf("Cannot parse the dump: %v (channels == %v)\n", err.Error(), channelsNum)
 		os.Exit(-1)
 	}
 	printRow_arg.outputFile.Close()

+ 4 - 1
voltloggerParser/voltloggerParser.go

@@ -45,7 +45,7 @@ func get8(dumpFile *os.File)  (r uint8, err error) {
 	return r, err
 }
 
-func ParseVoltloggerDump(dumpPath string, noHeaders bool, channelsNum uint8, headerHandler func(VoltloggerDumpHeader, interface{})(error), rowHandler func(int64, []int32, VoltloggerDumpHeader, interface{})(error), arg interface{}) (err error) {
+func ParseVoltloggerDump(dumpPath string, noHeaders bool, channelsNum uint8, adc8Bit bool, headerHandler func(VoltloggerDumpHeader, interface{})(error), rowHandler func(int64, []int32, VoltloggerDumpHeader, interface{})(error), arg interface{}) (err error) {
 	var r VoltloggerDumpHeader
 
 	// Openning the "dumpPath" as a file
@@ -106,6 +106,9 @@ func ParseVoltloggerDump(dumpPath string, noHeaders bool, channelsNum uint8, hea
 	if (channelsNum > 0) {
 		r.ChannelsNum = channelsNum
 	}
+	if (adc8Bit) {
+		r.Bitness8ADC = 1;
+	}
 
 	// Parsing the Data