aboutsummaryrefslogtreecommitdiff
path: root/rpc_client_serial.c
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2016-07-01 18:44:13 -0400
committerRob Austein <sra@hactrn.net>2016-07-01 18:44:13 -0400
commit904361120ef5eed8b0bb06da8ec90e4b7f1ef81a (patch)
treecc46c735677d217fce3a4a6c2cc8d9ae0c27e767 /rpc_client_serial.c
parent6603db3cdf1ea39d0f2c908d679a4707a204afde (diff)
Use environment variables to specify serial device rather than hard-wiring it.
Diffstat (limited to 'rpc_client_serial.c')
-rw-r--r--rpc_client_serial.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/rpc_client_serial.c b/rpc_client_serial.c
index 149998e..34da852 100644
--- a/rpc_client_serial.c
+++ b/rpc_client_serial.c
@@ -47,7 +47,17 @@
hal_error_t hal_rpc_client_transport_init(void)
{
- return hal_serial_init(HAL_CLIENT_SERIAL_DEFAULT_DEVICE, HAL_CLIENT_SERIAL_DEFAULT_SPEED);
+ const char *device = getenv(HAL_CLIENT_SERIAL_DEVICE_ENVVAR);
+ const char *speed_ = getenv(HAL_CLIENT_SERIAL_SPEED_ENVVAR);
+ uint32_t speed = HAL_CLIENT_SERIAL_DEFAULT_SPEED;
+
+ if (device == NULL)
+ device = HAL_CLIENT_SERIAL_DEFAULT_DEVICE;
+
+ if (speed_ != NULL)
+ speed = (uint32_t) strtoul(speed_, NULL, 10);
+
+ return hal_serial_init(device, speed);
}
hal_error_t hal_rpc_client_transport_close(void)