Reading Hex data over serial

Hello everyone.
I'm trying to receive a hexadecimal frame over serial from a stepper motor and print its data values in the serial monitor.

The stepper is a closed loop package from BIGTREETECH, it's their S57B model. The package comes with a 32 Bit microprocessor and their own custom firmware.
They specified a protocol that has the following format:

This is how far I've gotten with my experiments:
Command for the read request as per the specified protocol:

void sendReadRequest() {
    const size_t packet_length = 8;
    uint8_t packet[packet_length] = {0xFE, 0xFE, 0x05, 0xB0, 0xAA, 0xAA, 0x09, 0x16};
    Serial.write(packet, packet_length);
}

And on the reading side of things:

void loop() {
    if (Serial.available() > 0) {
        incomingByte = Serial.read();

        Serial.print("I received: ");
        Serial.println(incomingByte, HEX);
  }
}

There is only some gibberish being printed in the console, so I'm guessing it's in the wrong format and/or is being read in the wrong way. Maybe a Serial.readBytesUntil() would work?

I know that the command for the request must be right tho, because whenever I send it, there is something being printed in the serial monitor.

Thank you guys in advance!

PS: I should also mention that there is an SPI and CAN interface available as well from the stepper. However, since documentation is sparse I do not know how to really use them.
Here is a link to the docs for the stepper: BIGTREETECH-Stepper-Motor-Driver/S57B at master · bigtreetech/BIGTREETECH-Stepper-Motor-Driver · GitHub

Have you set the terminal to 38400 baud?

That is a lot of printing for every single character that comes in. I wonder if it can keep up, given that the serial monitor data rate cannot exceed 115200 Baud.

How are you using Serial to both send binary to your S57 and send text to Serial Monitor?!?

I tried it without the "I received: " part as well, so that doesn't seem to be the problem. I think it is just a formatting issue of some sort, or that I'm reading the incoming data in the wrong way..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.