The Arduino reference https://www.arduino.cc/reference/en/lan ... readbytes/ says that Allowed data types: array of char or byte. But when I compile the following code it only works when using char* serialAsBytes.
Code: Select all
//char* serialAsBytes;
byte* serialAsBytes;
void setup() {
Serial.begin(115200);
}
void loop() {
while (Serial.available()) {
Serial.readBytes(serialAsBytes, 1);
}
}
Code: Select all
/tmp/arduino_modified_sketch_144682/Blink.ino: In function 'void loop()':
Blink:11:22: error: invalid conversion from 'byte*' {aka 'unsigned char*'} to 'char*' [-fpermissive]
11 | Serial.readBytes(serialAsBytes, 1);
| ^~~~~~~~~~~~~
| |
| byte* {aka unsigned char*}
In file included from /home/mark/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/Arduino.h:158,
from sketch/Blink.ino.cpp:1:
/home/mark/.arduino15/packages/adafruit/hardware/samd/1.7.10/cores/arduino/USB/USBAPI.h:141:25: note: initializing argument 1 of 'size_t Serial_::readBytes(char*, size_t)'
141 | size_t readBytes(char *buffer, size_t length);
| ~~~~~~^~~~~~
exit status 1
invalid conversion from 'byte*' {aka 'unsigned char*'} to 'char*' [-fpermissive]