-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmsgE8.R
47 lines (40 loc) · 1.17 KB
/
msgE8.R
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
source("convertHex.R")
messageE8 <- function(payload){
fieldName = c("Message ID", "Version", "IOD", "NSVS")
first4bytes = c()
indexPayload = 1
field = c(1,1,1,1)
######################
for(i in field){
hex = ""
for(k in 1:i){
hex = paste(hex, payload[indexPayload], sep = "")
indexPayload = indexPayload + 1
}
first4bytes <- append(first4bytes, hex)
}
names(first4bytes) <- fieldName
###########################
numberOfSatellite <- strtoi(first4bytes[4], 16L)
SVstatus = data.frame(
Status = c("GNSS Type", "SVID", "Elevation", "Azimuth")
)
###########################
for(index in 1:numberOfSatellite){
new = c()
channelField = c(1,1,2,2)
for(i in channelField){
hex = ""
for(k in 1:i){
hex = paste(hex, payload[indexPayload], sep = "")
indexPayload = indexPayload + 1
}
if (i==1) new <- append(new, strtoi(hex,16L))
else new <- append(new, convertHexToFloat(hex))
}
SVstatus[,ncol(SVstatus)+1] <- new
colnames(SVstatus)[ncol(SVstatus)] <- paste("SV",index, "status", sep =" ")
}
data = list(first4bytes, SVstatus)
return(data)
}