Created
July 11, 2017 23:01
-
-
Save mookerji/cc3c83308829c91a0486da8806772720 to your computer and use it in GitHub Desktop.
SBP-JSON timing tests, to test on an assumed hardware test log (in JSON).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Assumes you have in third_party libsbp, rapidjson, and b64.c (built) | |
g++ -O3 -g -v -stdlib=libstdc++\ | |
-Wall -Werror -Wno-c++11-extensions \ | |
-Ithird_party/rapidjson/include \ | |
-Ithird_party/libsbp/c/include \ | |
-Ithird_party/b64.c/ \ | |
third_party/b64.c/b64 $1; | |
time ./a.out |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rapidjson/document.h" | |
#include "rapidjson/error/en.h" | |
#include "rapidjson/reader.h" | |
#include "libsbp/navigation.h" | |
#include "libsbp/observation.h" | |
#include "b64.h" | |
#include <cstdio> | |
#include <fstream> | |
#include <iostream> | |
#include <string> | |
int main() { | |
std::string line; | |
std::ifstream myfile("./test.json"); | |
if (myfile.is_open()) { | |
rapidjson::Document dx; | |
while (getline(myfile, line)) { | |
dx.Parse(line.c_str()); | |
assert(dx.IsObject()); | |
assert(dx.HasMember("time")); | |
assert(dx.HasMember("data")); | |
const rapidjson::Value &data = dx["data"]; | |
assert(data.HasMember("payload")); | |
const rapidjson::Value &payload = data["payload"]; | |
assert(payload.IsString()); | |
unsigned char *dec = b64_decode(payload.GetString(), strlen(payload.GetString())); | |
const rapidjson::Value &msg_type = data["msg_type"]; | |
assert(msg_type.IsInt()); | |
switch (msg_type.GetInt()) { | |
// SBP_MSG_GPS_TIME | |
case 0x0102: { | |
// process_gps_time, | |
const msg_gps_time_t *tim = (msg_gps_time_t *)dec; | |
(void)tim; | |
break; | |
} | |
} | |
} | |
myfile.close(); | |
} | |
std::cout << "DONE!" << std::endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
log_datafile = "./test.json" | |
with open(log_datafile, 'r') as infile: | |
for line in infile: | |
json.loads(line) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
python gnss_analysis/tools/sbp2hdf5.py ./test.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sbp.client.loggers.json_logger import JSONLogIterator | |
log_datafile = "./test.json" | |
count = 0 | |
with open(log_datafile, 'r') as infile: | |
with JSONLogIterator(infile) as log: | |
for msg, metadata in log.next(): | |
count += 1 | |
if count % 10000 == 0: | |
print count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment