aboutsummaryrefslogblamecommitdiff
path: root/utils/cores.c
blob: 1126e85e8ccf92876e88092690d1e98567a7bb93 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
generated by cgit v1.2.3 (git 2.25.1) at 2024-11-01 09:30:31 +0000
lass="o">!= 0) return perror("tcgetattr"), HAL_ERROR_RPC_TRANSPORT; #if !HAL_RPC_SERIAL_USE_MACOSX_IOCTL switch (speed) { case 115200: termios_speed = B115200; break; case 921600: termios_speed = B921600; break; default: hal_log(HAL_LOG_ERROR, "invalid line speed %lu\n", (unsigned long) speed); return HAL_ERROR_RPC_TRANSPORT; } cfsetospeed (&tty, termios_speed); cfsetispeed (&tty, termios_speed); #endif tty.c_cflag &= ~CSIZE; tty.c_cflag |= (CS8 | CLOCAL | CREAD); tty.c_iflag = 0; tty.c_oflag = 0; tty.c_lflag = 0; tty.c_cc[VMIN] = 1; tty.c_cc[VTIME] = 0; if (tcsetattr (fd, TCSANOW, &tty) != 0) return perror("tcsetattr"), HAL_ERROR_RPC_TRANSPORT; #if HAL_RPC_SERIAL_USE_MACOSX_IOCTL termios_speed = speed; if (ioctl(fd, IOSSIOSPEED, &speed) < 0) return perror("ioctl(IOSSIOSPEED)"), HAL_ERROR_RPC_TRANSPORT; #endif return HAL_OK; } hal_error_t hal_serial_close(void) { int ret = close(fd); fd = -1; if (ret != 0) return perror("close"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } hal_error_t hal_serial_send_char(const uint8_t c) { if (write(fd, &c, 1) != 1) return perror("write"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } hal_error_t hal_serial_recv_char(uint8_t * const c) { if (read(fd, c, 1) != 1) return perror("read"), HAL_ERROR_RPC_TRANSPORT; return HAL_OK; } /* Access routine for the file descriptor, so daemon can poll on it. */ int hal_serial_get_fd(void) { return fd; }