Basic: BeRTOS shots

How do I write debug messages?

After initializing the debug serial port with kdbg_init(), call:

#include <cfg/debug.h>

kprintf("The sum is %d\n", sum);
kputs("string without formatting\n");

How do I read from serial/dataflash/eeprom/spi/fat/...?

Short answer

Just use KFile interface functions:

uint8_t buf[10];
// the struct and the initialization function varies
// based on the source you're reading from
Serial ser;
ser_init(&ser.fd, ...);
// ...
kfile_read(&ser.fd, buf, sizeof(buf));

Long answer

All BeRTOS IO modules use the same read/write KFile interface, which is similar to C standard library functions, such as fread(), fwrite(), fseek(), fclose() etc. The difference between modules lies in the initialization function. So if you want to read from a serial you must initialize a struct Serial while to read from a dataflash you must init a struct DataFlash.

All such structs have a fd field which is passed as the first parameter to each kfile_* function and this is enough to use the interface functions.