-/* Message logging helpers with subsystem-specific prefix string. */
-#define LOG_PREFIX "cem-dt-885x: "
-#define sr_log(l, s, args...) sr_log(l, LOG_PREFIX s, ## args)
-#define sr_spew(s, args...) sr_spew(LOG_PREFIX s, ## args)
-#define sr_dbg(s, args...) sr_dbg(LOG_PREFIX s, ## args)
-#define sr_info(s, args...) sr_info(LOG_PREFIX s, ## args)
-#define sr_warn(s, args...) sr_warn(LOG_PREFIX s, ## args)
-#define sr_err(s, args...) sr_err(LOG_PREFIX s, ## args)
+#define LOG_PREFIX "cem-dt-885x"
+
+/* When retrieving samples from device memory, group this many
+ * together into a sigrok packet. */
+#define SAMPLES_PER_PACKET 50
+
+/* Various temporary storage, at least 8 bytes. */
+#define BUF_SIZE SAMPLES_PER_PACKET * 2
+
+/* When in hold mode, force the last measurement out at this interval.
+ * We're using 50ms, which duplicates the non-hold 20Hz update rate. */
+#define HOLD_REPEAT_INTERVAL 50 * 1000
+
+enum {
+ TOKEN_WEIGHT_TIME_FAST = 0x02,
+ TOKEN_WEIGHT_TIME_SLOW = 0x03,
+ TOKEN_HOLD_MAX = 0x04,
+ TOKEN_HOLD_MIN = 0x05,
+ TOKEN_TIME = 0x06,
+ TOKEN_MEAS_RANGE_OVER = 0x07,
+ TOKEN_MEAS_RANGE_UNDER = 0x08,
+ TOKEN_STORE_FULL = 0x09,
+ TOKEN_RECORDING_ON = 0x0a,
+ TOKEN_MEAS_WAS_READOUT = 0x0b,
+ TOKEN_MEAS_WAS_BARGRAPH = 0x0c,
+ TOKEN_MEASUREMENT = 0xd,
+ TOKEN_HOLD_NONE = 0x0e,
+ TOKEN_BATTERY_LOW = 0x0f,
+ TOKEN_MEAS_RANGE_OK = 0x11,
+ TOKEN_STORE_OK = 0x19,
+ TOKEN_RECORDING_OFF = 0x1a,
+ TOKEN_WEIGHT_FREQ_A = 0x1b,
+ TOKEN_WEIGHT_FREQ_C = 0x1c,
+ TOKEN_BATTERY_OK = 0x1f,
+ TOKEN_MEAS_RANGE_30_80 = 0x30,
+ TOKEN_MEAS_RANGE_30_130 = 0x40,
+ TOKEN_MEAS_RANGE_50_100 = 0x4b,
+ TOKEN_MEAS_RANGE_80_130 = 0x4c,
+};
+
+enum {
+ CMD_TOGGLE_RECORDING = 0x55,
+ CMD_TOGGLE_WEIGHT_FREQ = 0x99,
+ CMD_TOGGLE_WEIGHT_TIME = 0x77,
+ CMD_TOGGLE_HOLD_MAX_MIN = 0x11,
+ CMD_TOGGLE_MEAS_RANGE = 0x88,
+ CMD_TOGGLE_POWER_OFF = 0x33,
+ CMD_TRANSFER_MEMORY = 0xac,
+};
+
+enum {
+ RECORD_DBA = 0xaa,
+ RECORD_DBC = 0xcc,
+ RECORD_DATA = 0xac,
+ RECORD_END = 0xdd,
+};
+
+enum {
+ DATA_SOURCE_LIVE,
+ DATA_SOURCE_MEMORY,
+};