+/* Decode high byte and low byte into a float. */
+static float decode_value(uint8_t hi, uint8_t lo, float divisor)
+{
+ return ((float)hi * 240.0 + (float)lo) / divisor;
+}
+
+/* Encode a float into high byte and low byte. */
+static void encode_value(float current, uint8_t *hi, uint8_t *lo, float divisor)
+{
+ int value;
+
+ value = (int)(current * divisor);
+ sr_dbg("Value %d %d %d", value, value / 240, value % 240);
+ *hi = value / 240;
+ *lo = value % 240;
+}
+
+/* Send updated configuration values to the load. */
+static int send_cfg(struct sr_serial_dev_inst *serial, struct dev_context *devc)
+{
+ uint8_t send[] = { 0xfa, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8 };
+
+ encode_value(devc->current_limit, &send[2], &send[3], 1000.0);
+
+ send[8] = send[1] ^ send[2] ^ send[3] ^ send[4] ^ send[5] ^ \
+ send[6] ^ send[7];
+
+ return send_cmd(serial, send, 10);
+}
+