Realterm and Arduino

In Realterm, there is the option to send numbers or send ascii. When I write the bytes on send numbers for eg. 0x01 0x03 0xF2 0xE6 0xFE 0x71 is it the same as my arduino code using serial.write? Is the data write the same format as realterm?

void setup() {
  Serial.begin(115200);
}

void loop() {
  byte command[] = {0xFC, 0x74, 0x01, 0x00, 0xFE, 0x71};
  int commandLength = sizeof(command) / sizeof(command[0]);
  
  Serial.write(command, commandLength); // Send the command
  delay(500);
}

The values are obviously not the same

I was asking about the format, the code is an old draft, it's changed to byte command[] = {0x01, 0x03, 0xF2, 0xE6, 0xFE, 0x71};

To answer this you need to clarify what's means "send numbers" for Realterm case. What is format of these "numbers" ? Do you have a documentation?

it should be.

if you select send numbers and If you input, say 21 there and press Send Numbers, it will send a byte which value is 0x15 (21 in decimal). if you had selected send ASCII, it would have sent 2 bytes, the ASCII code for '2' and the one for '1'

In RealTerm You can also enter data directly as hexadecimal 0x15 and press Send Numbers, it would have worked in the same way (the 0x is understood to mean you provided an Hexadecimal representation)

You could easily validate what's sent by writing a small Arduino program listening to the serial and printing the hex values of the received bytes as they come in. Then you'll see what is really sent.

something like this (typed here, not tested)

void setup() {
  Serial.begin(115200); Serial.println();
}

void loop() {
  if (Serial.available()) {
    byte b = Serial.read();
    Serial.print("0x");
    if (b < 0x10) Serial.write('0');
    Serial.println(b, HEX);
  }
}

configure realTerm at 115200 bauds and select the Arduino com port. Don't open the IDE's Serial monitor of course.

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