send custom command error when we use comma

Sanjeewa3 years ago

When we want to send a custom command to a device with parameters, we need to insert commas,
for example, fifotrack protocol, Output control command is B12,1,0,20

Illegal hexadecimal character , at index 3 - DecoderException (... < DataConverter:29 < BaseProtocol:99 < ActiveDevice:48 < ...)

Anton Tananaev3 years ago

Looks like you have to send full message in HEX format.

Sanjeewa3 years ago

but in the code shows like this.

private Object formatCommand(Command command, String content) {
    String uniqueId = getUniqueId(command.getDeviceId());
    int length = 1 + uniqueId.length() + 3 + content.length();
    String result = String.format("##%02d,%s,1,%s*", length, uniqueId, content);
    result += Checksum.sum(result) + "\r\n";
    return result;
}

@Override
protected Object encodeCommand(Command command) {

    switch (command.getType()) {
        case Command.TYPE_CUSTOM:
            return formatCommand(command, command.getString(Command.KEY_DATA));
        case Command.TYPE_REQUEST_PHOTO:
            return formatCommand(command, "D05,3");
        default:
            return null;
    }
}
Anton Tananaev3 years ago

I don't see it. Can you please send a link to the file on GitHub.

Sanjeewa3 years ago
Anton Tananaev3 years ago

Interesting. Yes, I think it should work. Is your device connected?

Sanjeewa3 years ago

Yes, I checked again, it works.
Thanks for your time.