1

Why am I having extra character printed in serial port?
See the attached screenshot, please.

Extra character in my Nextion command see circled area
There is 0x1A received and I am not sending carriage return.

I developed a code to implement communication between nextion display and ATmega328P over serial port.
The issue at hand, in trying to update progress bar. The first value send to the component will deliver, but subsequent command/values, the simulator return errors.
I traced the problem to this terminating string: "\xff\xff\xff".
From the Nextion editor simulator. there is a stray character send by Atmega328P on the serial port and I am not able to understand here it is coming from.

I use Eclipse + AVR plugin, this is how I pack the command and send. The second function down involve the serial send.

void setValue(uint8_t* value){
    char buf[40]={};
    sprintf(buf, "%s.val=%u", get_name(), *value);
    return send_cmd_reply(buf);
}

bool send_cmd_reply(const char* cmd)
{
    UsartString(cmd);
    UsartString("\xff\xff\xff");
    return (TRUE);
}

int UsartString(const char* fmt, ...)
{
    char buff[200];
    va_list args;
    va_start(args, fmt);
    int status = vsnprintf(buff, sizeof(buff), fmt, args);
    va_end(args);
    uint8_t*s = (UI8_t *)&buff;
    while (*s) {UsartChar(*s++);}
    return (status);
}

When I tried using Arduino IDE and its serial implementation as below, everything as is fine.

String Tosend = "j1.val=";
Tosend += String(value);                                             
Serial.print(Tosend);
Serial.write(0xff);
Serial.write(0xff);
Serial.write(0xff);
gre_gor
  • 6,669
  • 9
  • 47
  • 52
avong
  • 21
  • 4

1 Answers1

0

I unfortunately am not familliar with Eclipse + AVR. However i can tell you that 0x1A (ctrl^z) is a pupular "end of transmission" character. I would suggest checking the configurations of your IDE or your USART Handler for that.

I can not make any sense of your screenshot so sorry if that is not at all the problem.

Hope I could help, Stromi

Stromi1011
  • 11
  • 3