|
|
@ -94,6 +94,8 @@ func verifyStream(data []byte, minSize int, maxSize int, tagOption *opt.Options) |
|
|
|
//extract command
|
|
|
|
//extract command
|
|
|
|
cmd = data[10] |
|
|
|
cmd = data[10] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Printf("cmd %v\n",cmd) |
|
|
|
|
|
|
|
|
|
|
|
return imei, cmd, rec, nil |
|
|
|
return imei, cmd, rec, nil |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -127,6 +129,7 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco |
|
|
|
deviceRecords := make([]DeviceRecord, 0) |
|
|
|
deviceRecords := make([]DeviceRecord, 0) |
|
|
|
for j := 0; j < int(numRec); j++ { |
|
|
|
for j := 0; j < int(numRec); j++ { |
|
|
|
var deviceRecord DeviceRecord |
|
|
|
var deviceRecord DeviceRecord |
|
|
|
|
|
|
|
tags_ := tags |
|
|
|
|
|
|
|
|
|
|
|
//imei
|
|
|
|
//imei
|
|
|
|
deviceRecord.Imei = imei |
|
|
|
deviceRecord.Imei = imei |
|
|
@ -216,11 +219,13 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco |
|
|
|
ioVal := convBinaryToUint16(addOneByteInTwoByte(data[currByte:plusByte]),2,"io1Val") |
|
|
|
ioVal := convBinaryToUint16(addOneByteInTwoByte(data[currByte:plusByte]),2,"io1Val") |
|
|
|
//fmt.Printf("io1Val %d\n",ioVal)
|
|
|
|
//fmt.Printf("io1Val %d\n",ioVal)
|
|
|
|
|
|
|
|
|
|
|
|
tagDevice_ := tags[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_ := tags_[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_.TagId = strconv.Itoa(int(ioID)) |
|
|
|
tagDevice_.TagId = strconv.Itoa(int(ioID)) |
|
|
|
tagDevice_.TagVal = strconv.Itoa(int(ioVal)) |
|
|
|
tagDevice_.TagVal = strconv.Itoa(int(ioVal)) |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
tags[strconv.Itoa(int(ioID))] = tagDevice_ |
|
|
|
//tags_[strconv.Itoa(int(ioID))] = tagDevice_
|
|
|
|
|
|
|
|
tags_[tagDevice_.TagName] = tagDevice_ |
|
|
|
|
|
|
|
delete(tags_, strconv.Itoa(int(ioID))) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -245,11 +250,10 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco |
|
|
|
ioVal := convBinaryToUint16(data[currByte:plusByte],2,"io2Val") |
|
|
|
ioVal := convBinaryToUint16(data[currByte:plusByte],2,"io2Val") |
|
|
|
//fmt.Printf("io2Val %d\n",ioVal)
|
|
|
|
//fmt.Printf("io2Val %d\n",ioVal)
|
|
|
|
|
|
|
|
|
|
|
|
tagDevice_ := tags[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_ := tags_[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_.TagId = strconv.Itoa(int(ioID)) |
|
|
|
|
|
|
|
tagDevice_.TagVal = strconv.Itoa(int(ioVal)) |
|
|
|
tagDevice_.TagVal = strconv.Itoa(int(ioVal)) |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
tags[strconv.Itoa(int(ioID))] = tagDevice_ |
|
|
|
tags_[tagDevice_.TagName] = tagDevice_ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -273,11 +277,10 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco |
|
|
|
ioVal := convBinaryToInt32(data[currByte:plusByte],4,"io4Val") |
|
|
|
ioVal := convBinaryToInt32(data[currByte:plusByte],4,"io4Val") |
|
|
|
//fmt.Printf("io4Val %d\n",ioVal)
|
|
|
|
//fmt.Printf("io4Val %d\n",ioVal)
|
|
|
|
|
|
|
|
|
|
|
|
tagDevice_ := tags[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_ := tags_[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_.TagId = strconv.Itoa(int(ioID)) |
|
|
|
|
|
|
|
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10) |
|
|
|
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10) |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
tags[strconv.Itoa(int(ioID))] = tagDevice_ |
|
|
|
tags_[tagDevice_.TagName] = tagDevice_ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -301,15 +304,22 @@ func parseData(data []byte, imei uint64, tagOption *opt.Options) (rec DeviceReco |
|
|
|
ioVal := convBinaryToInt64(data[currByte:plusByte],8,"io8Val") |
|
|
|
ioVal := convBinaryToInt64(data[currByte:plusByte],8,"io8Val") |
|
|
|
//fmt.Printf("io8Val %d\n",ioVal)
|
|
|
|
//fmt.Printf("io8Val %d\n",ioVal)
|
|
|
|
|
|
|
|
|
|
|
|
tagDevice_ := tags[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_ := tags_[strconv.Itoa(int(ioID))] |
|
|
|
tagDevice_.TagId = strconv.Itoa(int(ioID)) |
|
|
|
|
|
|
|
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10) |
|
|
|
tagDevice_.TagVal = strconv.FormatInt(int64(ioVal), 10) |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
if tagDevice_.TagName != ""{ |
|
|
|
tags[strconv.Itoa(int(ioID))] = tagDevice_ |
|
|
|
tags_[tagDevice_.TagName] = tagDevice_ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Delete unset tags value
|
|
|
|
|
|
|
|
for tagKey := range tags { |
|
|
|
|
|
|
|
tagDevice_ := tags_[tagKey] |
|
|
|
|
|
|
|
if tagDevice_.TagId == tagKey { |
|
|
|
|
|
|
|
delete(tags_, tagKey) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
deviceRecord.TagDevices = tags |
|
|
|
deviceRecord.TagDevices = tags_ |
|
|
|
deviceRecords = append(deviceRecords, deviceRecord) |
|
|
|
deviceRecords = append(deviceRecords, deviceRecord) |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|