Hello Tzu-Hsuan,
According to the related Mbed documentation the BufferedSerial::read(void* buffer, size_t length)
function returns the number of bytes actually read. If end of file is read then it returns 0 and on error a negative number. The length
parameter (num
in your example) tells the function the maximum number of bytes your program is capable to read in one shot. So if more bytes are send to your program then several read's
are needed to get all of them. You can have a look also at this example.
Best regards, Zoltan