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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217
#[doc(hidden)]
pub const E_LINK_RECIEVER: core::ffi::c_uint = 0;
// PROS PLS FIX 🥺
pub use E_LINK_RECIEVER as E_LINK_RECEIVER;
pub const E_LINK_TRANSMITTER: core::ffi::c_uint = 1;
pub const E_LINK_RX: core::ffi::c_uint = E_LINK_RECEIVER;
pub const E_LINK_TX: core::ffi::c_uint = E_LINK_TRANSMITTER;
pub type link_type_e_t = core::ffi::c_uint;
extern "C" {
/**
Initializes a link on a radio port, with an indicated type. There might be a
1 to 2 second delay from when this function is called to when the link is initializes.
PROS currently only supports the use of one radio per brain.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\param link_id
Unique link ID in the form of a string, needs to be different from other links in
the area.
\param type
Indicates whether the radio link on the brain is a transmitter or receiver,
with the transmitter having double the transmitting bandwidth as the receiving
end (1040 bytes/s vs 520 bytes/s).
\return PROS_ERR if initialization fails, 1 if the initialization succeeds.
*/
pub fn link_init(port: u8, link_id: *const core::ffi::c_char, r#type: link_type_e_t) -> u32;
/**
Initializes a link on a radio port, with an indicated type and the ability for
vexlink to override the controller radio. There might be a 1 to 2 second delay
from when this function is called to when the link is initializes.
PROS currently only supports the use of one radio per brain.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\param link_id
Unique link ID in the form of a string, needs to be different from other links in
the area.
\param type
Indicates whether the radio link on the brain is a transmitter or receiver,
with the transmitter having double the transmitting bandwidth as the receiving
end (1040 bytes/s vs 520 bytes/s).
\return PROS_ERR if initialization fails, 1 if the initialization succeeds.
*/
pub fn link_init_override(
port: u8,
link_id: *const core::ffi::c_char,
r#type: link_type_e_t,
) -> u32;
/**
Checks if a radio link on a port is active or not.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\return If a radio is connected to a port and it's connected to a link.
*/
pub fn link_connected(port: u8) -> bool;
/**
Returns the bytes of data available to be read
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\return PROS_ERR if port is not a link/radio, else the bytes available to be
read by the user.
*/
pub fn link_raw_receivable_size(port: u8) -> u32;
/**
Returns the bytes of data available in transmission buffer.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\return PROS_ERR if port is not a link/radio,
*/
pub fn link_raw_transmittable_size(port: u8) -> u32;
/**
Send raw serial data through vexlink.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
EBUSY - The transmitter buffer is still busy with a previous transmission, and there is no
room in the FIFO buffer (queue) to transmit the data.
EINVAL - The data given is NULL
\param port
The port of the radio for the intended link.
\param data
Buffer with data to send
\param data_size
Bytes of data to be read to the destination buffer
\return PROS_ERR if port is not a link, and the successfully transmitted
data size if it succeeded.
*/
pub fn link_transmit_raw(port: u8, data: *const core::ffi::c_void, data_size: u16) -> u32;
/**
Receive raw serial data through vexlink.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
EINVAL - The destination given is NULL, or the size given is larger than the FIFO buffer
or destination buffer.
\param port
The port of the radio for the intended link.
\param dest
Destination buffer to read data to
\param data_size
Bytes of data to be read to the destination buffer
\return PROS_ERR if port is not a link, and the successfully received
data size if it succeeded.
*/
pub fn link_receive_raw(port: u8, dest: *mut core::ffi::c_void, data_size: u16) -> u32;
/**
Send packeted message through vexlink, with a checksum and start byte.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
EBUSY - The transmitter buffer is still busy with a previous transmission, and there is no
room in the FIFO buffer (queue) to transmit the data.
EINVAL - The data given is NULL
\param port
The port of the radio for the intended link.
\param data
Buffer with data to send
\param data_size
Bytes of data to be read to the destination buffer
\return PROS_ERR if port is not a link, and the successfully transmitted
data size if it succeeded.
*/
pub fn link_transmit(port: u8, data: *const core::ffi::c_void, data_size: u16) -> u32;
/**
Receive packeted message through vexlink, with a checksum and start byte.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
EINVAL - The destination given is NULL, or the size given is larger than the FIFO buffer
or destination buffer.
EBADMSG - Protocol error related to start byte, data size, or checksum.
\param port
The port of the radio for the intended link.
\param dest
Destination buffer to read data to
\param data_size
Bytes of data to be read to the destination buffer
\return PROS_ERR if port is not a link or protocol error, and the successfully
transmitted data size if it succeeded.
*/
pub fn link_receive(port: u8, dest: *mut core::ffi::c_void, data_size: u16) -> u32;
/**
Clear the receive buffer of the link, and discarding the data.
This function uses the following values of errno when an error state is
reached:
ENXIO - The given value is not within the range of V5 ports (1-21).
ENODEV - The port cannot be configured as a radio.
ENXIO - The sensor is still calibrating, or no link is connected via the radio.
\param port
The port of the radio for the intended link.
\return PROS_ERR if port is not a link, and the successfully received
data size if it succeeded.
*/
pub fn link_clear_receive_buf(port: u8) -> u32;
}