print

xod/uart/print

Writes a string bytes per byte into UART. Possible errors: — No bytes written. Probably due to buffer overflow
print
@/print
Writes a string bytes per byte into UART. Possible errors: — No bytes written. Probably due to buffer overflow
UART@/uart
An UART object
DATAstring
String to be sent into UART. Could contain "\r\n" symbols to sent few lines.
SENDpulse
Triggers write of a string into UART
print
UART
DATA
SEND
DONE
DONEpulse
Pulses when all String has been written

C++ implementation

#pragma XOD evaluate_on_pin disable
#pragma XOD evaluate_on_pin enable input_SEND
#pragma XOD error_raise enable

node {
    void evaluate(Context ctx) {
        if (!isInputDirty<input_SEND>(ctx))
            return;

        auto uart = getValue<input_UART>(ctx);
        auto data = getValue<input_DATA>(ctx);

        for (auto it = data.iterate(); it; ++it) {
            bool err = !(uart->writeByte((char)*it));
            if (err)
                return raiseError(ctx);
        }
        if (!uart->writeByte('\r'))
            return raiseError(ctx);
        if (!uart->writeByte('\n'))
            return raiseError(ctx);
        uart->flush();
        emitValue<output_DONE>(ctx, 1);
    }
}