This shows you the differences between two versions of the page.
| — | sdk:scripts:serial-tcsetattr [2015/05/05 15:04] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== SDK Script serial-tcsetattr.are ====== | ||
| + | <code c serial-tcsetattr.are> | ||
| + | /* DESC: This script can be used to set/get the attributes of the serial port. | ||
| + | * Copyright (C) 2012 NetModule AG, Switzerland | ||
| + | */ | ||
| + | |||
| + | void usage() | ||
| + | { | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | printf(" | ||
| + | |||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | |||
| + | if (argc < 6) { | ||
| + | | ||
| + | } | ||
| + | |||
| + | DEV = argv[1]; | ||
| + | BAUD = (int)argv[2]; | ||
| + | DATABIT = (int)argv[3]; | ||
| + | STOPBIT = (int)argv[4]; | ||
| + | PARITY | ||
| + | FLOWCTL = (int)argv[6]; | ||
| + | |||
| + | /* check serial port config */ | ||
| + | idx = right(DEV, 1); | ||
| + | |||
| + | if (idx < 0 || idx > 1) { | ||
| + | nb_syslog(" | ||
| + | exit(1); | ||
| + | |||
| + | } | ||
| + | st = nb_config_get(sprintf(" | ||
| + | if (st != " | ||
| + | nb_syslog(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | |||
| + | ret = nb_serial_setattr(DEV, | ||
| + | if (ret == 0) { | ||
| + | printf(" | ||
| + | } else { | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | attr = nb_serial_getattr(DEV); | ||
| + | if (is_void(attr)) { | ||
| + | printf(" | ||
| + | exit(1); | ||
| + | } | ||
| + | |||
| + | printf(" | ||
| + | printf(" | ||
| + | struct_get(attr, | ||
| + | struct_get(attr, | ||
| + | struct_get(attr, | ||
| + | struct_get(attr, | ||
| + | struct_get(attr, | ||
| + | ); | ||
| + | |||
| + | |||
| + | exit(0); | ||
| + | |||
| + | </ | ||