ZestCode
Loading...
Searching...
No Matches
registry.h
Go to the documentation of this file.
1
13
14
#pragma once
15
16
#include "
pros/apix.h
"
17
#include "v5_api.h"
18
#include "
vdml/vdml.h
"
19
20
#ifdef __cplusplus
21
#define v5_device_e_t pros::c::v5_device_e_t
22
extern
"C"
{
23
#endif
24
25
typedef
struct
{
26
v5_device_e_t device_type;
27
V5_DeviceT device_info;
28
uint8_t pad[128];
// 16 bytes in adi_data_s_t times 8 ADI Ports = 128
29
}
v5_smart_device_s_t
;
30
31
/*
32
* Detects the devices that are plugged in.
33
*
34
* Pulls the type names of plugged-in devices and stores them in the buffer
35
* registry_types.
36
*/
37
void
registry_update_types();
38
39
/*
40
* Returns the information on the device registered to the port.
41
*
42
* This function uses the following values of errno when an error state is
43
* reached:
44
* ENXIO - The given value is not within the range of V5 ports (1-21).
45
*
46
* \param port
47
* The V5 port number from 1-21
48
*
49
* \return A struct containing the device type and the info needed for api
50
* functions
51
*/
52
v5_smart_device_s_t
* registry_get_device(uint8_t port);
53
54
/*
55
* Returns the information on the device registered to the port.
56
*
57
* This function uses the following values of errno when an error state is
58
* reached:
59
* ENXIO - The given value is not within the range of V5 ports (1-21).
60
*
61
* \param port
62
* The V5 port number from 0-32
63
*
64
* \return A struct containing the device type and the info needed for api
65
* functions
66
*/
67
v5_smart_device_s_t
* registry_get_device_internal(uint8_t port);
68
69
/*
70
* Checks whether there is a discrepancy between the binding of the port and
71
* what is actually plugged in.
72
*
73
* If a device is plugged in but not registered, registers the port.
74
* If a device is not plugged in and a device is registered, warns the user.
75
* If one type of device is registered but another is plugged in, warns the user.
76
*
77
* This function uses the following values of errno when an error state is
78
* reached:
79
* ENXIO - The given value is not within the range of V5 ports (1-21).
80
*
81
* \param port
82
* The V5 port number from 1-21
83
* \param expected_t
84
* The expected type (i.e., the type of function being called. If
85
* E_DEVICE_NONE, indicates that background processing is calling this,
86
* and a mismatch will only occur if there is an actual discrepancy
87
* between what is registered and what is plugged in.
88
*
89
* \return 0 if the device registered matches the device plugged and the
90
* expected device matches both of those or is E_DEVICE_NONE, 1 if the
91
* registered device is not plugged in, and 2 if there is a mismatch. PROS_ERR
92
* on exception.
93
*/
94
int32_t registry_validate_binding(uint8_t port, v5_device_e_t expected_t);
95
96
#ifdef __cplusplus
97
}
98
#undef v5_device_e_t
99
#endif
apix.h
v5_smart_device_s_t
Definition
registry.h:25
vdml.h
include
vdml
registry.h
Generated by
1.13.2