This class implements the DIOC communication protocol. More...
#include <class_dioc.h>
Public Types | |
| enum | id_enum { STATUS =0, FRONT, RIGHT, LEFT, REVERSE, BRAKE, BLUE, RED, GREEN, CROSS_A, CROSS_B } |
| enum | status_enum { ON, OFF, BLINK1, BLINK3 } |
Public Member Functions | |
| class_dioc (const char *pdevice) | |
| Constructor. More... | |
| int | CommStatus (void) |
| Get the comm status. More... | |
| int | GetStatus (id_enum ID) |
| Get the status of a input/output. More... | |
| void | perr (int ret) |
| Print error function. More... | |
| int | SetStatus (id_enum ID, status_enum ENUM) |
| Set the status of a input/output. More... | |
| int | SetStatus (id_enum ID, int status) |
| Set the status of a input/output. More... | |
| ~class_dioc () | |
| De-constructor. More... | |
Private Member Functions | |
| void | CleanBuffer (void) |
| Cleans the buffer. More... | |
Private Attributes | |
| bool | active |
| This variable indicates that the communication is active. More... | |
| char * | device |
| Communication device to use. More... | |
| char | err [1024] |
| int | port |
| Communication port to use. More... | |
| int | ret |
| Auxiliary return code. More... | |
This class implements the DIOC communication protocol.
This class allows to control the discreet input/output PCB.
Definition at line 55 of file class_dioc.h.
| enum class_dioc::id_enum |
| Enumerator | |
|---|---|
| STATUS | |
| FRONT | |
| RIGHT | |
| LEFT | |
| REVERSE | |
| BRAKE | |
| BLUE | |
| RED | |
| GREEN | |
| CROSS_A | |
| CROSS_B | |
Definition at line 76 of file class_dioc.h.
| Enumerator | |
|---|---|
| ON | |
| OFF | |
| BLINK1 | |
| BLINK3 | |
Definition at line 75 of file class_dioc.h.
| class_dioc::class_dioc | ( | const char * | pdevice | ) |
Constructor.
This functions sets the default values for internal variables and opens communication with the servos.
| pdevice | Name of the device to use in communications |
Definition at line 33 of file class_dioc.cpp.
| class_dioc::~class_dioc | ( | ) |
De-constructor.
This function closes the communication with the servos.
Definition at line 69 of file class_dioc.cpp.
|
private |
Cleans the buffer.
This function clean the communication input buffer.
Definition at line 75 of file class_dioc.cpp.
| int class_dioc::CommStatus | ( | void | ) |
| int class_dioc::GetStatus | ( | id_enum | ID | ) |
Get the status of a input/output.
| ID | id of the IO |
Definition at line 173 of file class_dioc.cpp.
| void class_dioc::perr | ( | int | ret | ) |
Print error function.
This function prints the error present in the err variable (this is a private variable of the gamepad class). The ret number specifies what kind of error is this, -1 is a error that raises a SIGINT signal, -2 is an warning that allows the program to continue and -3 is a error that prints perror and raises SIGINT.
| ret | error code |
Definition at line 228 of file class_dioc.cpp.
| int class_dioc::SetStatus | ( | id_enum | ID, |
| status_enum | ENUM | ||
| ) |
Set the status of a input/output.
| ID | id of the IO |
| ENUM | required status |
Definition at line 110 of file class_dioc.cpp.
| int class_dioc::SetStatus | ( | id_enum | ID, |
| int | status | ||
| ) |
Set the status of a input/output.
| ID | id of the IO |
| status | required status |
Definition at line 91 of file class_dioc.cpp.
|
private |
This variable indicates that the communication is active.
Definition at line 132 of file class_dioc.h.
|
private |
Communication device to use.
Definition at line 141 of file class_dioc.h.
|
private |
Definition at line 143 of file class_dioc.h.
|
private |
Communication port to use.
Definition at line 135 of file class_dioc.h.
|
private |
Auxiliary return code.
Definition at line 138 of file class_dioc.h.