'I want to Store the serial data in the variable using Arduino

I am working with a DWIN 480x272 LCD touch screen. The screen provides UART serial communication at a baud rate of 115200. I want to store the transmitted data into a format I can process. Can anyone point me in the correct direction to find the format of the data? Here is my code:

int dataval = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(114200);
  pinMode(13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  if(Serial.available()){
    dataval = Serial.read();
    Serial.println(dataval);
  }
}

The data transmitted from the LCD was in the format below.

90 165 6 131 16 0 1 0 1



Solution 1:[1]

You can find the format of the serial commands in the DWIN DGUS DEV GUIDE. Page 20 shows the format of the data frame:

2 bytes Frame Header

1 byte Data Length (including command byte)

1 byte Command

n bytes Data

The data frame you received was:

Frame Header = 90 165 = 0x5A 0xA5

Data Length = 6 bytes

Command = 131 = 0x83 (Read data in designated addresses in variable SRAM)

Data = 0x10 0x00 0x01 0x00 0x01

For the data section 0x1000 is the address of the data, there are 0x01 words being read, that word is 0x0001.

The linked document should tell you everything you need to know about the format.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1