Skip to content

3.1. Device Info

Fernando Chorney edited this page Apr 11, 2024 · 1 revision

StepManiaX Stage Device Info

The first thing you will typically want to do when communicating with the SMX Stage is get its device information. This information contains its serial number, firmware version, and if it is player 1 or 2.

Request Packet

To request the device info there are two different packets you could use.

The "i" command

Command: "i" (105, 0x69)
Arguments: None
Packet Count: 1
Packet: [5, 5, 1, 105, 0, ..., 0]

The i packet is sent when you are already established to the stage and for whatever reason need to update the device info. This is a fairly safe command to send whenever you need this information, but you might want to use the 0x80 method instead if you are requesting this close to USB enumeration as explained below.

The PACKET_FLAG_DEVICE_INFO (0x80) command

Command: 0x80 (128)
Arguments: None
Packet Count: 1
Packet: [5, 128, 0, ..., 0]

Technically this is less of a command, and more of a special flag that the SMX MCU responds to. You'll notice that the packet consists of the report ID, and the device info flag, and nothing else. This special flag goes where the start of command/end of command/etc flags usually sit.

This command is essentially the same as sending the "i" command, but it can be safely sent at any time, even if another application is talking to the device. Thus, you might want to use this during enumeration instead of "i".

Receive Packet

The SMX Stage will essentially return the same data on both packets, but in a slightly different way.

The "I" Command

Yes you read that correctly. The stage will return an "I" command when we sent an "i". Typically the stage will return with the same command that was sent, but for this particular situation it's different and I don't really understand why.

Command: 'I' (73, 0x49)
Data: Device Info
Packet Count: 1
Packet: [6, 5, 23, 73, data]

As usual, for a single packet you will see a 6 for the report ID, a 5 designating this is the first and last packet, the number of bytes of data, and the "I" command that we are looking for.

The PACKET_FLAG_DEVICE_INFO (0x80) Command

The biggest difference her from the "I" result, is that the flag will be different.

Command: 0x80 (128)
Data: Device Info
Packet Count: 1
Packet: [6, 133, 23, 73, data]

The difference here is that the flag is 0x80 (PACKET_FLAG_DEVICE_INFO) | 0x4 (Start of Command) | 0x1 (End of Command)

Caveat

There is a caveat with this command as far as interpreting the results. Apparently any application can send this packet, so if you didn't request it specifically you may want to ignore any responses you pick up that may have been sent by other programs.

Decoding The Data

Once you remove the preamble, and the padding bytes at the end, you end up with the following 23 bytes:

[
     73,  21, 48,  32,  64, 234, 80, 92,
     23, 155, 54, 227, 211,  44, 53, 71,
    239,  35, 80,  88,   5,   0, 10,
]

These bytes can be unpacked into the following c-struct:

struct data_info_packet {
        char cmd;               // always 'I'
     uint8_t packet_size;       // not used
        char player;            // '0' for P1, '1' for P2:
        char unused2;           // not used
     uint8_t serial[16];        // 16 character serial number
    uint16_t firmware_version;  // firmware version
        char unused3;           // always '\n'
};

The unpacked data will look like the following:

             cmd: "I"
     packet_size: 21
          player: "0"
         unused2: " "
          serial: "40EA505C179B36E3D32C3547EF235058"
firmware_version: 5
         unused3: "\n"