Hello, everyone! Relatively recently I received a task to work with a nextion display on a UC32 controller.
When I send a command to just arduino uno it works, but on uc32 the port monitor just doesn't see the command.
By testing it was found that all ruins the string
if (((uint32_t)(rxBuf + rxPtr - 4) & 0xFFFFFFFFFF00) == 0xFFFFFFFFFF00) {
please tell me what I can do with this
code:
#define NEX_RXBUF_SIZE 256
#define NEX_RXPTR_WARN (NEX_RXBUF_SIZE-3)
uint8_t MainByteTT;
uint8_t x6Byte;
uint8_t rxByte;
uint8_t rxPtr = 0;
uint8_t rxBuf[NEX_RXBUF_SIZE] = {0};
int32_t rxVal;
char* rxTxt;
int32_t test = 0;
void setup() {
Serial.begin(9600);
while (!Serial);
}
void loop() {
String rxValShow = String(rxVal);
if (Serial.available()) {
rxByte = Serial.read();
if ((*(uint32_t*)(rxBuf + rxPtr - 4) & 0xFFFFFF00) == 0xFFFFFF00) { // its not worked!
if (rxByte == 0xFF || rxPtr < NEX_RXPTR_WARN) {
rxBuf[rxPtr++] = rxByte; //
}
if (rxBuf[0] == 0x71) {
rxVal = (int32_t)(((int32_t)rxBuf[4] * 256 + rxBuf[3]) * 256 + rxBuf[2]) * 256 + rxBuf[1];
Serial.println(rxVal);
Serial.print("\xFF\xFF\xFF");
}
if (rxBuf[0] == 02) {
x6Byte = (int32_t)(((int32_t)rxBuf[4] * 256 + rxBuf[3]) * 256 + rxBuf[2]) * 256 + rxBuf[1];
rxVal = rxVal*6;
Serial.print("t0.txt=\"" + rxValShow + "\"");
Serial.print("\xFF\xFF\xFF");
}
rxPtr = 0;
}
}
}