Skip to content

Instantly share code, notes, and snippets.

@z3t0
Created May 30, 2018 14:13
Show Gist options
  • Save z3t0/039900ac8ae16cd8568b17c8fb7060ce to your computer and use it in GitHub Desktop.
Save z3t0/039900ac8ae16cd8568b17c8fb7060ce to your computer and use it in GitHub Desktop.
converting hex bytes to json struct
{"source_address": 1,
"destination_address": 0,
"payload_type": 0,
"length": 0,
"crc_present": 0,
"payload": {"mission_time": 0,
"state": 0,
"flag_ematch_1_present": 0,
"flag_ematch_2_present": 0,
"flag_parachute_deployed": 0,
"adc_cap_voltage": 0,
"flag_gps_data_valid": 0,
"flag_7": 0,
"flag_8": 0,
"flag_9": 0,
"flag_10": 0,
"flag_11": 0,
"adc_temp_1": 0,
"flag_12": 0,
"flag_13": 0,
"flag_14": 0,
"flag_15": 0,
"flag_16": 0,
"flag_17": 0,
"adc_temp_2": 0,
"flag_18": 0,
"flag_19": 0,
"flag_20": 0,
"flag_21": 0,
"flag_22": 0,
"flag_23": 0,
"adc_3": 0,
"flag_24": 0,
"flag_25": 0,
"flag_26": 0,
"flag_27": 0,
"flag_28": 0,
"flag_29": 0,
"adc_4": 0,
"flag_30": 0,
"flag_31": 0,
"flag_32": 0,
"flag_33": 0,
"flag_34": 0,
"flag_35": 0,
"adc_5": 0,
"flag_36": 0,
"flag_37": 0,
"flag_38": 0,
"flag_39": 0,
"flag_40": 0,
"flag_41": 0,
"adc_6": 0,
"flag_42": 0,
"flag_43": 0,
"flag_44": 0,
"flag_45": 0,
"flag_46": 0,
"flag_47": 0,
"adc_batt_voltage": 0,
"acceleration_x": 0,
"acceleration_y": 0,
"acceleration_z": 0,
"pitch_rate": 0,
"roll_rate": 0,
"yaw_rate": 0,
"gyro_temp": 0,
"altitude_lsb": 0,
"altitude_csb": 0,
"altitude_msb": 0,
"alt_temp_lsb": 0,
"alt_temp_msb": 0,
"gps_time": 0,
"lattitude": 0,
"longitude": 0,
"ground_speed": 0,
"course_over_ground": 0,
"gps_sample_time": 0
}
,
"crc": 0
}
# Bytes is the array we would read from the serial port
export BYTES="1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0"
./api BYTES
# The data will be printed below as json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment