WPILibC++  2018.4.1-20180729124724-1140-gcbb62fb
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
SerialPort.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2016-2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <stdint.h>
11 
12 #include "hal/Types.h"
13 
14 // clang-format off
15 HAL_ENUM(HAL_SerialPort) {
16  HAL_SerialPort_Onboard = 0,
17  HAL_SerialPort_MXP = 1,
18  HAL_SerialPort_USB1 = 2,
19  HAL_SerialPort_USB2 = 3
20 };
21 // clang-format on
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
35 void HAL_InitializeSerialPort(HAL_SerialPort port, int32_t* status);
36 
46 void HAL_InitializeSerialPortDirect(HAL_SerialPort port, const char* portName,
47  int32_t* status);
48 
57 void HAL_SetSerialBaudRate(HAL_SerialPort port, int32_t baud, int32_t* status);
58 
67 void HAL_SetSerialDataBits(HAL_SerialPort port, int32_t bits, int32_t* status);
68 
82 void HAL_SetSerialParity(HAL_SerialPort port, int32_t parity, int32_t* status);
83 
95 void HAL_SetSerialStopBits(HAL_SerialPort port, int32_t stopBits,
96  int32_t* status);
97 
108 void HAL_SetSerialWriteMode(HAL_SerialPort port, int32_t mode, int32_t* status);
109 
122 void HAL_SetSerialFlowControl(HAL_SerialPort port, int32_t flow,
123  int32_t* status);
124 
131 void HAL_SetSerialTimeout(HAL_SerialPort port, double timeout, int32_t* status);
132 
141 void HAL_EnableSerialTermination(HAL_SerialPort port, char terminator,
142  int32_t* status);
143 
149 void HAL_DisableSerialTermination(HAL_SerialPort port, int32_t* status);
150 
157 void HAL_SetSerialReadBufferSize(HAL_SerialPort port, int32_t size,
158  int32_t* status);
159 
166 void HAL_SetSerialWriteBufferSize(HAL_SerialPort port, int32_t size,
167  int32_t* status);
168 
175 int32_t HAL_GetSerialBytesReceived(HAL_SerialPort port, int32_t* status);
176 
187 int32_t HAL_ReadSerial(HAL_SerialPort port, char* buffer, int32_t count,
188  int32_t* status);
189 
198 int32_t HAL_WriteSerial(HAL_SerialPort port, const char* buffer, int32_t count,
199  int32_t* status);
200 
206 void HAL_FlushSerial(HAL_SerialPort port, int32_t* status);
207 
213 void HAL_ClearSerial(HAL_SerialPort port, int32_t* status);
214 
220 void HAL_CloseSerial(HAL_SerialPort port, int32_t* status);
221 #ifdef __cplusplus
222 } // extern "C"
223 #endif