unsigned int index; /**< ID as exposed in the system */
int rx; /**< uart rx */
int tx; /**< uart tx */
- char* device_path; /**< To store "/dev/ttyS1" for example */
+ const char* device_path; /**< To store "/dev/ttyS1" for example */
/*@}*/
} mraa_uart_dev_t;
b->def_uart_dev = 0;
b->uart_dev[0].rx = 10;
b->uart_dev[0].tx = 8;
- int uart_path_length = strlen(UART_DEV_PATH) + 1;
- b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
- if (b->uart_dev[0].device_path == NULL) {
- goto error;
- }
- strncpy(b->uart_dev[0].device_path, UART_DEV_PATH, uart_path_length);
+ b->uart_dev[0].device_path = UART_DEV_PATH;
return b;
memset(dev, 0, sizeof(struct _uart));
dev->index = index;
- dev->path = plat->uart_dev[index].device_path;
+ dev->path = (char*) plat->uart_dev[index].device_path;
if (advance_func->uart_init_post != NULL) {
mraa_result_t ret = advance_func->uart_init_post(dev);
if (ret != MRAA_SUCCESS) {
b->def_uart_dev = 0;
b->uart_dev[0].rx = 26;
b->uart_dev[0].tx = 35;
+ b->uart_dev[0].device_path = UART_DEV_PATH;
return MRAA_SUCCESS;
}
b->def_uart_dev = 0;
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
-
- int uart_path_length = strlen(UART_DEV_PATH) + 1;
- b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
- if (b->uart_dev[0].device_path == NULL) {
- goto error;
- }
- strncpy(b->uart_dev[0].device_path, UART_DEV_PATH, uart_path_length);
+ b->uart_dev[0].device_path = UART_DEV_PATH;
int il;
for (il =0; il < MRAA_INTEL_EDISON_PINCOUNT; il++) {
b->spi_bus[0].miso = 12;
b->spi_bus[0].sclk = 13;
- int uart_path_length = strlen("/dev/ttyS0") + 1;
-
b->uart_dev_count = 2;
b->def_uart_dev = 0;
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
- b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
- if (b->uart_dev[0].device_path == NULL) {
- goto error;
- }
- strncpy(b->uart_dev[0].device_path, "/dev/ttyS0", uart_path_length);
+ b->uart_dev[0].device_path = "/dev/ttyS0";
b->uart_dev[1].rx = -1;
b->uart_dev[1].tx = -1;
- b->uart_dev[1].device_path = (char*) malloc(sizeof(char) * uart_path_length);
- if (b->uart_dev[1].device_path == NULL) {
- goto error;
- }
- strncpy(b->uart_dev[1].device_path, "/dev/ttyS1", uart_path_length);
+ b->uart_dev[1].device_path = "/dev/ttyS1";
return b;
error:
b->spi_bus[0].miso = 12;
b->spi_bus[0].sclk = 13;
- int uart_path_length = strlen("/dev/ttyS0") + 1;
-
b->uart_dev_count = 1;
b->def_uart_dev = 0;
b->uart_dev[0].rx = 0;
b->uart_dev[0].tx = 1;
- b->uart_dev[0].device_path = (char*) malloc(sizeof(char) * uart_path_length);
- if (b->uart_dev[0].device_path == NULL) {
- goto error;
- }
- strncpy(b->uart_dev[0].device_path, "/dev/ttyS0", uart_path_length);
+ b->uart_dev[0].device_path = "/dev/ttyS0";
return b;
error: