我正在尝试使用本指南通过 UART(来自 ESP32)发送一个由 Python 处理的结构。
// we send this to the host, to be processed by python script
struct package {
uint8_t modifier;
uint8_t keyboard_keys[6];
};
// instantiate struct
package to_send = {};
// send the contents of keyboard_keys and keyboard_modifier_keys
// https://folk.uio.no/jeanra/Microelectronics/TransmitStructArduinoPython.html
void usb_keyboard_send(void)
{
to_send.modifier = keyboard_modifier_keys;
for(uint8_t i = 0; i < 6; i++) {
to_send.keyboard_keys[i] = keyboard_keys[i];
}
printf("S");
printf((uint8_t *)&to_send, sizeof(to_send));
printf("E");
}
但是我得到了错误:invalid conversion from 'uint8_t* {aka unsigned char*}' to 'const char*' [-fpermissive]
我对 C++ 很陌生,我尝试了各种类型的转换,但我就是无法让它工作。有人可以提供指导吗?