- Edited
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!
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!
not at the moment, but this should be the answer: https://stackoverflow.com/a/5900399/2958741
I may able to get to it later today, if you don't get there first.
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.
Ah, ok. Thanks!
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?
Updating the files in /root/Bela/libraries/Serial or update the entirety of the bela core code to the branch containing the relevant version of the files ( dev branch in this case)
https://learn.bela.io/using-bela/bela-techniques/updating-bela/#updating-to-an-experimental-release
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.
m3rten host was not known.
how do you ssh onto the board?
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!