33 lines
1,006 B
C
33 lines
1,006 B
C
// Minimal headless serial self-test -- NO jlInit (no video/graphics), so it
|
|
// runs even where the graphics HAL can't (e.g. AROS on the Amiga). Opens the
|
|
// DEFAULT port at 9600 8N1, sends a banner (TX heartbeat), then echoes every
|
|
// received byte forever. A host serial peer verifies banner (TX) + echo (RX).
|
|
#include <joey/serial.h>
|
|
|
|
int main(void) {
|
|
jlSerialConfigT cfg;
|
|
static const char banner[] = "JLSERTEST-READY\r\n";
|
|
|
|
cfg.baud = 9600u;
|
|
cfg.dataBits = 8u;
|
|
cfg.stopBits = 1u;
|
|
cfg.parity = JL_SERIAL_PARITY_NONE;
|
|
cfg.flow = JL_SERIAL_FLOW_NONE;
|
|
cfg.unit = 0u;
|
|
if (!jlSerialOpen(JL_SERIAL_DEFAULT, &cfg)) {
|
|
return 1;
|
|
}
|
|
jlSerialWrite((const uint8_t *)banner, (uint16_t)(sizeof(banner) - 1u));
|
|
|
|
for (;;) {
|
|
uint8_t buf[64];
|
|
uint16_t n;
|
|
|
|
jlSerialPoll();
|
|
n = jlSerialRead(buf, (uint16_t)sizeof(buf));
|
|
if (n > 0u) {
|
|
jlSerialWrite(buf, n);
|
|
}
|
|
}
|
|
/* not reached */
|
|
}
|