]>
Commit | Line | Data |
---|---|---|
afdcb8c1 MF |
1 | #ifndef COMMS_H_ |
2 | #define COMMS_H_ | |
3 | ||
4 | #include <stdbool.h> | |
5 | #include <pthread.h> | |
6 | ||
7 | #include "usb_cmd.h" | |
8 | #include "uart.h" | |
9 | ||
10 | #ifndef CMD_BUFFER_SIZE | |
11 | #define CMD_BUFFER_SIZE 50 | |
12 | #endif | |
13 | ||
14 | #ifndef MAX_DEMOD_BUF_LEN | |
15 | #define MAX_DEMOD_BUF_LEN (1024*128) | |
16 | #endif | |
17 | ||
18 | #ifndef BIGBUF_SIZE | |
19 | #define BIGBUF_SIZE 40000 | |
20 | #endif | |
21 | ||
22 | typedef struct { | |
23 | // If TRUE, continue running the uart_receiver thread. | |
24 | bool run; | |
25 | ||
26 | // Lock around serial port receives | |
27 | pthread_mutex_t recv_lock; | |
28 | } receiver_arg; | |
29 | ||
30 | ||
31 | // Wrappers required as static variables can only be used in one file. | |
32 | void SetSerialPort(serial_port* new_port); | |
33 | serial_port* GetSerialPort(); | |
34 | void SetOffline(bool new_offline); | |
35 | bool IsOffline(); | |
36 | ||
37 | void SendCommand(UsbCommand *c); | |
38 | void *uart_receiver(void *targ); | |
39 | void UsbCommandReceived(UsbCommand *UC); | |
40 | void clearCommandBuffer(); | |
41 | bool WaitForResponseTimeoutW(uint64_t cmd, UsbCommand* response, size_t ms_timeout, bool show_warning); | |
42 | bool WaitForResponseTimeout(uint64_t cmd, UsbCommand* response, size_t ms_timeout); | |
43 | bool WaitForResponse(uint64_t cmd, UsbCommand* response); | |
44 | ||
45 | #endif // COMMS_H_ |