Is there a way to get the number of characters waiting in the Serial Buffer (incoming) without reading them? Similar to the Serial.available() in Arduino. Thanks!

Thanks! Not sure what to use as File Descriptor though. Something like this?

#include <sys/ioctl.h>
...
  int bytes_avail;
  char tempBuffer[maxLen];
  ioctl(gSerial.read(tempBuffer, 128, 100), FIONREAD, &bytes_avail);
  return bytes_avail;

no, you need to use it from within the class and use the fd variable. It doesn't seem to work for me, it always gives me bytes_avail == 0, even if the ioctl succeeds.

Wow, fantastic! Thanks so much for adding this!

I downloaded Serial.h + Serial.cpp and put in my project folder, but what is the correct way to update (or add new) library files?

Thanks! I can browse to the /root/Bela/libraries folder via ssh and see the files there. But how do I transfer files from my PC? I tried using scp serial.h root@bela.local:root/Bela/libraries/Serial but it said the host was not known.

    I use the Windows command prompt and type ssh root@bela.local . Then I can see the files on Bela. But my understanding of the Linux world is very limited unfortunately.

    Then this scp Serial.h root@bela.local:root/Bela/libraries/Serial should not return a host not known error message, as you are using exactly the same host as ssh root@bela.local.

    I'm clearly doing this wrong. I've placed a file here C:\Users\m\test.txt but I'm not sure what directory I should be in when i issue the copy command. (I'm sorry to bother you with this, it's really not a Bela issue, rather me not understanding Linux)

    C:\Users\m>scp test.txt root@bela.local:root/Bela/libraries/Serial
    scp: root/Bela/libraries/Serial: No such file or directory
    
    C:\Users\m>ssh root@bela.local
    [...]
     ____  _____ _        _
    | __ )| ____| |      / \
    |  _ \|  _| | |     / _ \
    | |_) | |___| |___ / ___ \
    |____/|_____|_____/_/   \_\
    
    The platform for ultra-low latency audio and sensor processing
    [...]
    Bela image, v0.3.8h, 5 January 2023
    [...]
    root@bela:~# scp test.txt root@bela.local:root/Bela/libraries/Serial
    Warning: Permanently added the ECDSA host key for IP address '192.168.6.2' to the list of known hosts.
    test.txt: No such file or directory
    root@bela:~#

      m3rten No such file or directory

      that's very different from "host not known". The issue is the missing / before root/ in the destination path: if the first character after : is a forward slash, it is an absolute path, otherwise it is a relative path (relative to /root/. In your case you are trying to copy to /root/root/Bela/libraries/Serial, which doesn't exist. You can do ;scp text.txt root@bela.local:Bela/libraries/Serial or scp text.txt root@bela.local:/root/Bela/libraries/Serial

      Great, it works now! Thanks for the patience!