-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsgDF.R
More file actions
30 lines (26 loc) · 943 Bytes
/
Copy pathmsgDF.R
File metadata and controls
30 lines (26 loc) · 943 Bytes
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
source("convertHex.R")
messageDF <- function(payload){
fieldName = c("Message ID", "IOD", "Navigation State", "WN","TOW","ECEF POS_X",
"ECEF POS_Y","ECEF POS_Z","ECEF VEL_X","ECEF VEL_Y","ECEF VEL_Z",
"Clock Bias","Clock Drift","GDOP","PDOP","HDOP","VDOP","TDOP","Timestamp")
field = c(1,1,1,2,8,8,8,8,4,4,4,8,4,4,4,4,4,4)
indexPayload = 1
messageBody = c()
for(i in field){
hex = ""
for(k in 1:i){
hex = paste(hex, payload[indexPayload], sep = "")
indexPayload = indexPayload + 1
}
if (i == 1) messageBody <- append(messageBody, strtoi(hex,16L))
else if (i == 2) messageBody <- append(messageBody, strtoi(hex,16L))
else messageBody <- append(messageBody,convertHexToFloat(hex))
}
ts = messageBody[4] * 7 * 24 * 3600 + messageBody[5]
messageBody <- append(messageBody, ts)
data <- data.frame(
fieldName,
messageBody
)
return (data)
}