Buffer won’t fill.

Im getting this kind of Packets:

55 AA 07 20 65 00 04 28 27 00 00 20 FF

55 AA 09 20 64 00 06 29 27 00 00 72 00 AA FE

Already tested through serial monitor gives me packets from above.

I’m currently building a method which separates the packet structure.
But not even the first two bytes are filled by my receiverbuffer array.

anyone a hint ?

//struct for recieve buffer
typedef struct
{
    uint8_t len;
    uint8_t buffer[36]; //0x24 or 36 maximum size of one packet inclunding cmd, arg, payload
} queuebuf;

//reciever used by receivedata()
queuebuf receiverbuffer;


//M365 - serial receiver
uint8_t readindex = 0;
uint8_t m365receiverstate = 0;

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

void loop()
{
    void recievedata();
    Serial.print(receiverbuffer.buffer[0]);
    Serial.print(receiverbuffer.buffer[1]);          
}

void recievedata()
{
     uint8_t newbyte;
   //Expect Packet  55 AA 07 20 65 00 04 28 27 00 00 20 FF 
    while (Serial2.available() > 0)
    {
        newbyte = Serial2.read();
        
        switch (m365receiverstate)
        {
        case 0:       //we are waiting for 1st byte of packet header 0x55
            if (newbyte == 0x55) //  = 0x55
            {
                m365receiverstate = 1;
                  receiverbuffer.buffer[0] = newbyte;
                
            }
            break;
        case 1:     //we are waiting for 2nd byte of packet header 0xAA
            if (newbyte == 0xAA) //  = 0xAA
            {
                m365receiverstate = 0;
                receiverbuffer.buffer[1] = newbyte;
            }
            break;
        }
    } 
}
    void recievedata();

That's not calling the function

Serial.print can't print array (only a null terminated char array = C string)

AWOL:

    void recievedata();

That's not calling the function

the void is the problem DAMMM ITTTT
Thanks :slight_smile:
It working fine now xD

Juraj:
Serial.print can't print array (only a null terminated char array = C string)

im printing only one char from the array and its working fine now thanks :slight_smile: