Closed MkLHX closed 3 years ago
buffer_
holds the following content (shown on README):
Start | Length | Data[0] | Data[1] | ... | Data[n-1] | CRC8 | End | |
---|---|---|---|---|---|---|---|---|
byte index | 0 | 1 | 2 | 3 | ... | n+1 | n+2 | n+3 |
value | 0x02 | n+4 | data[0] | data[1] | ... | data[n-1] | crc of [1..(n+1)] | 0x04 |
CRC is calculated from buffer_[1]
to buffer_[n+1]
. So buffer_[1]
which holds totalLength
is added to the CRC on the previous line
and
updates the CRC with the contents of data
i.e. buffer[2...n+1]
.
Why using packer and unpacker data workflow?
It's explained here: https://github.com/gutierrezps/ESP32_I2C_Slave#how-it-works
@gutierrezps yeah i read and understand everything. but my question is really what is the goal in c++ side to make buffer + 2 operation? buffer is an byte array and wat do the + 2 operation on this array? i cannot understand by my self sorry.
buffer is a pointer to the first byte of the array. buffer + 2 is therefore a pointer to the third byte of the array.
https://www.tutorialspoint.com/cplusplus/cpp_pointer_arithmatic.htm
ok thx 👍
Hello, here my work to allow raspberry pi to communicate with ESP32 as slave on i2c bus https://github.com/MkLHX/Raspberry_Pi_Master_for_ESP32_I2C_SLAVE
Great! I've added the link to your library on README.md.
Hello, i'm working on python class to permit Raspberry as i2c Master with ESP32 slave. look #2
I have to convert the parcker and unpacker class into python code and i'm facing about this operation => https://github.com/gutierrezps/ESP32_I2C_Slave/blob/1224da32dd54f31ce62016438a25871d8d67324c/src/WirePacker.cpp#L63
What is the goal of >buffer_ + 2< ? bytearray + 2 🤓
Why using packer and unpacker data workflow? is it the esp-idf layer who need this data format?