Skip to content

Commit

Permalink
Merge pull request #29 from noahm/fc/add-more-logs
Browse files Browse the repository at this point in the history
Add more logs
  • Loading branch information
fchorney authored Apr 16, 2024
2 parents 5f53684 + 190b346 commit 78857ec
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
8 changes: 6 additions & 2 deletions sdk/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,12 +348,15 @@ export class SMXConfig {
/**
* Take in the data array and decode it into this.
*/
constructor(data: Array<number>, firmware_version: number) {
this.firmwareVersion = firmware_version;
constructor(data: Array<number>, firmwareVersion: number) {
this.firmwareVersion = firmwareVersion;
console.log("Config Firmware Version: ", this.firmwareVersion);
console.log("CONFIG RAW DATA: ", data.toString());

if (this.firmwareVersion >= 5) {
this.config = smx_config_t.decode(data.slice(2, -1), true);
} else {
console.log("Reading Old Config");
this.oldConfig = smx_old_config_t.decode(data.slice(2, -1), true);
this.config = this.convertOldToNew(this.oldConfig);
}
Expand All @@ -365,6 +368,7 @@ export class SMXConfig {
}

if (!this.oldConfig) throw new ReferenceError("Can not encode old config as it is null");
console.log("Writing Old Config");
this.convertNewToOld();
return Array.from(new Uint8Array(smx_old_config_t.encode(this.oldConfig, true).buffer));
}
Expand Down
1 change: 1 addition & 0 deletions sdk/commands/data_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export class SMXDeviceInfo {
player = 0;

constructor(data: Array<number>) {
console.log("DEVICEINFO RAW DATA: ", data.toString());
this.#decode(data);
}

Expand Down
7 changes: 3 additions & 4 deletions sdk/packet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ export async function send_data(dev: HIDDevice, data: Array<number>, debug = fal
// Split data into packets
const packets = make_packets(data);

if (debug) {
console.log("Sending Packets: ", packets);
}

// Send each packet
for (const packet of packets) {
if (debug) {
console.log("OUTGOING RAW PACKET: ", packet.toString());
}
await dev.sendReport(HID_REPORT_OUTPUT, packet);
}
}
Expand Down
2 changes: 0 additions & 2 deletions sdk/smx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ export class SMXStage {
* SET_PANEL_TEST_MODE
*
* Double Stretch Goal:
* GET_CONFIG (old firmware)
* WRITE_CONFIG (old_firmware)
* SET_SERIAL_NUMBERS
*/

Expand Down
2 changes: 1 addition & 1 deletion sdk/state-machines/collate-packets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const collatePackets: StateF<DataView, PacketHandlingState, Packet> = (st
let currentPacket = state.currentPacket;
const data = new Uint8Array(event.value.buffer);

// console.log("Raw Packet Data: ", data);
console.log("INCOMING RAW PACKET: ", data.toString());

// Return if packet is empty
if (data.length <= PACKET_PREAMBLE_SIZE) {
Expand Down

0 comments on commit 78857ec

Please sign in to comment.