38
—
SOFTWARE
GENERAL MANUAL — SEP 8, 2022 — RELEASE: V1.1.0
•
•
int commGetCurrents(comm_settings *file_descriptor, int device_id, short int
currents[2])
: fills
"currents"
with the current of the motor on the qb SoftHand with the given
id, and returns 0 on success; only the first value is meaningful and it is expressed in milliamperes.
void commSetInputs(comm_settings *file_descriptor, int device_id, short int
inputs[2])
: sends a reference position command to the qb SoftHand with the given id; only the first
value is meaningful and it is expressed in motor ticks which lay in range
"0, 19000"
.
Usage example
#include <iostream>
#include <string.h>
#include <unistd.h>
#include "qbmove_communications.h"
int
main (
int
argc,
char
** argv) {
char
serial_ports[10][255];
int
serial_ports_count = RS485listPorts(ports);
if
(serial_ports_count <= 0) {
std::cout <<
"ERROR: no serial port found"
<< std::endl;
return
-1;
}
for
(
int
i=0; i<serial_ports_count; i++) {
std::cout <<
"INFO : serial port "
<< serial_ports[i] <<
"found."
<< std::endl;
}
// ...
comm_settings file_descriptor;
openRS485(&file_descriptor,
"/dev/ttyUSB0"
);
// use one of the values from RS485listPorts
if
(file_descriptor.file_handle == INVALID_HANDLE_VALUE) {
std::cout <<
"ERROR: fails while opening the serial resource (sets errno ["
<<
strerror
(
errno
) <<
"])."
<< std::endl;
return
-1;
}
// ...
int
device_id = 1;
commActivate(&file_descriptor, device_id, TRUE);
//activate motor
usleep(10000);
char
status;
int
result = commGetActivate(&file_descriptor, device_id, &status);
CRITICAL:
These commands are meant to be used by expert users only.