This shows you the differences between two versions of the page.
| — | sdk:scripts:serial-readwrite [2015/05/05 15:04] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SDK Script serial-readwrite.are ====== | ||
| + | <code c serial-readwrite.are> | ||
| + | /* DESC: This script will write to and read from the serial port. | ||
| + | * Copyright (C) 2012 NetModule AG, Switzerland | ||
| + | */ | ||
| + | |||
| + | DEV = " | ||
| + | |||
| + | /* check serial port config */ | ||
| + | st = nb_config_get(" | ||
| + | if (st != " | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | /* set attributes first */ | ||
| + | ret = nb_serial_setattr(DEV, | ||
| + | if (ret != 0) { | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | |||
| + | if (nb_serial_write(DEV, | ||
| + | printf(" | ||
| + | } | ||
| + | |||
| + | |||
| + | while (1) { | ||
| + | msg = nb_serial_read(DEV); | ||
| + | if (msg) { | ||
| + | printf(" | ||
| + | } else { | ||
| + | sleep(1); | ||
| + | } | ||
| + | } | ||
| + | |||
| + | exit(0); | ||
| + | |||
| + | </ | ||