Library of functions for SERIAL PORT communication with a qbMove. More...


Go to the source code of this file.
Classes | |
| struct | comm_settings |
Macros | |
| #define | BAUD_RATE_T_2000000 0 |
| #define | BAUD_RATE_T_460800 1 |
| #define | INVALID_HANDLE_VALUE -1 |
| #define | MAX_WATCHDOG_TIME 500 |
| #define | READ_TIMEOUT 4000 |
Typedefs | |
| typedef struct comm_settings | comm_settings |
Functions | |
Virtual COM (RS485) functions | |
| int | RS485listPorts (char list_of_ports[10][255]) |
| This function is used to return a list of available serial ports. More... | |
| void | openRS485 (comm_settings *comm_settings_t, const char *port_s, int BAUD_RATE=B2000000) |
| This function is used to open a serial port for using with the qbMove or the qbHand. More... | |
| void | closeRS485 (comm_settings *comm_settings_t) |
| This function is used to close a serial port being used with the qbMove or an qbHand. More... | |
| int | RS485read (comm_settings *comm_settings_t, int id, char *package) |
| This function is used to read a package from the device. More... | |
| int | RS485ListDevices (comm_settings *comm_settings_t, char list_of_ids[255]) |
| This function is used to list the number of devices connected to the serial port and get their relative IDs. More... | |
| void | RS485GetInfo (comm_settings *comm_settings_t, char *buffer) |
| This function is used to ping the serial port for a qbMove or a qbHand and to get information about the device. More... | |
qbAPI Commands | |
| int | commPing (comm_settings *comm_settings_t, int id) |
| This function is used to ping the qbMove or the qbHand. More... | |
| void | commActivate (comm_settings *comm_settings_t, int id, char activate) |
| This function activates or deactivates a qbMove or a qbHand connected to the serial port. More... | |
| void | commSetBaudRate (comm_settings *comm_settings_t, int id, short int baudrate) |
| This function sets the baudrate of communication. More... | |
| void | commSetWatchDog (comm_settings *comm_settings_t, int id, short int wdt) |
| This function sets watchdog timer of a qbMove or a qbHand. More... | |
| void | commSetInputs (comm_settings *comm_settings_t, int id, short int inputs[]) |
| This function send reference inputs to a qbMove or a qbHand connected to the serial port. More... | |
| int | commSetInputsAck (comm_settings *comm_settings_t, int id, short int inputs[]) |
| This function send reference inputs to a qbMove or a qbHand connected to the serial port and expects an acknowledgment reply from the device. More... | |
| void | commSetPosStiff (comm_settings *comm_settings_t, int id, short int inputs[]) |
| This function send reference inputs to a qbMove connected to the serial port. More... | |
| int | commGetInputs (comm_settings *comm_settings_t, int id, short int inputs[2]) |
| This function gets input references from a qbMove or a qbHand connected to the serial port. More... | |
| int | commGetMeasurements (comm_settings *comm_settings_t, int id, short int measurements[3]) |
| This function gets position measurements from a qbMove or a qbHand connected to the serial port. More... | |
| int | commGetCounters (comm_settings *comm_settings_t, int id, short unsigned int counters[20]) |
| This function gets counters values from a qbMove connected to the serial port. More... | |
| int | commGetCurrents (comm_settings *comm_settings_t, int id, short int currents[2]) |
| This function gets currents from a qbMove or a qbHand connected to the serial port. More... | |
| int | commGetCurrAndMeas (comm_settings *comm_settings_t, int id, short int *values) |
| This function gets currents and position measurements from a qbMove or a qbHand connected to the serial port. More... | |
| int | commGetEmg (comm_settings *comm_settings_t, int id, short int emg[2]) |
| This function gets measurements from electomyographics sensors connected to the qbHand. More... | |
| int | commGetVelocities (comm_settings *comm_settings_t, int id, short int measurements[]) |
| This function gets velocities of the two motors and the shaft from a qbMove connected to a serial port or from the only shaft of the qbHand. More... | |
| int | commGetAccelerations (comm_settings *comm_settings_t, int id, short int measurements[]) |
| This function gets the acceleration of the qbHand motor. More... | |
| int | commGetActivate (comm_settings *comm_settings_t, int id, char *activate) |
| This function gets the activation status of a qbMove or a qbHand connected to the serial port. More... | |
| int | commGetInfo (comm_settings *comm_settings_t, int id, short int info_type, char *info) |
| This function is used to ping the qbMove or the qbHand and get information about the device. More... | |
| int | commBootloader (comm_settings *comm_settings_t, int id) |
| This function sends the board in bootloader modality in order to update the firmware on the board. More... | |
| int | commCalibrate (comm_settings *comm_settings_t, int id) |
| This function is used to calibrate the maximum stiffness value of the qbMove. More... | |
| int | commHandCalibrate (comm_settings *comm_settings_t, int id, short int speed, short int repetitions) |
| This function is used to make a series of opening and closures of the qbHand. More... | |
qbAPI Parameters | |
| int | commSetZeros (comm_settings *comm_settings_t, int id, void *values, unsigned short num_of_values) |
| This function sets the encoders's zero positon value that remains stored in the qbMove or qbHand memory. More... | |
| int | commGetParamList (comm_settings *comm_settings_t, int id, unsigned short index, void *values, unsigned short value_size, unsigned short num_of_values, uint8_t *buffer) |
| This function gets all the parameters that are stored in the qbMove or qbHand memory and sets one of them if requested. More... | |
| int | commStoreParams (comm_settings *comm_settings_t, int id) |
| This function stores all parameters that were set in the qbMove or the qbHand memory. More... | |
| int | commStoreDefaultParams (comm_settings *comm_settings_t, int id) |
| This function stores the factory default parameters. More... | |
| int | commRestoreParams (comm_settings *comm_settings_t, int id) |
| This function restores the factory default parameters. More... | |
| int | commInitMem (comm_settings *comm_settings_t, int id) |
| This function initialize the EEPROM memory of the board by loading the default factory parameters. More... | |
General Functions | |
| long | timevaldiff (struct timeval *starttime, struct timeval *finishtime) |
| This functions returns a difference between two timeval structures in order to obtain time elapsed between the two timeval;. More... | |
| char | checksum (char *data_buffer, int data_length) |
| This functions returns an 8 bit LCR checksum over the lenght of a buffer. More... | |
Functions for other devices | |
| int | commExtDrive (comm_settings *comm_settings_t, int id, char ext_input) |
| This function is used with the armslider device. More... | |
| void | commSetCuffInputs (comm_settings *comm_settings_t, int id, int flag) |
| This function send reference inputs to a qbMove board connected to the serial port. More... | |
| int | commGetJoystick (comm_settings *comm_settings_t, int id, short int joystick[2]) |
| This function gets joystick measurementes from a softhand connected to the serial port. More... | |
Library of functions for SERIAL PORT communication with a qbMove.
Function Prototypes.
This library contains all necessary functions for communicating with a qbMove when using a USB to RS485 connector that provides a Virtual COM interface.
Definition in file qbmove_communications.h.
| #define BAUD_RATE_T_2000000 0 |
Definition at line 79 of file qbmove_communications.h.
| #define BAUD_RATE_T_460800 1 |
Definition at line 80 of file qbmove_communications.h.
| #define INVALID_HANDLE_VALUE -1 |
Definition at line 72 of file qbmove_communications.h.
| #define MAX_WATCHDOG_TIME 500 |
Definition at line 81 of file qbmove_communications.h.
| #define READ_TIMEOUT 4000 |
Definition at line 82 of file qbmove_communications.h.
| typedef struct comm_settings comm_settings |
Definition at line 92 of file qbmove_communications.h.
| char checksum | ( | char * | data_buffer, |
| int | data_length | ||
| ) |
| void closeRS485 | ( | comm_settings * | comm_settings_t | ) |
This function is used to close a serial port being used with the qbMove or an qbHand.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| void commActivate | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| char | activate | ||
| ) |
This function activates or deactivates a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| activate | TRUE to turn motors on. FALSE to turn motors off. |
| int commBootloader | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function sends the board in bootloader modality in order to update the firmware on the board.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| int commCalibrate | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function is used to calibrate the maximum stiffness value of the qbMove.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| int commExtDrive | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| char | ext_input | ||
| ) |
This function is used with the armslider device.
Is used to drive another board with the inputs of the first one
| comm_settings_t | A comm_settings structure containing info about the comunication settings. |
| id | The id of the board drive. |
| ext_input | A flag used to activate the external drive functionality of the board. |
| int commGetAccelerations | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | measurements[] | ||
| ) |
This function gets the acceleration of the qbHand motor.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| measurements | Velocity measurements. |
| int commGetActivate | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| char * | activate | ||
| ) |
This function gets the activation status of a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| activation | Activation status. |
| int commGetCounters | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short unsigned int | counters[20] | ||
| ) |
This function gets counters values from a qbMove connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| counters | Counters |
| int commGetCurrAndMeas | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int * | values | ||
| ) |
This function gets currents and position measurements from a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| values | Current and position measurements. Currents are in first two positions |
| int commGetCurrents | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | currents[2] | ||
| ) |
This function gets currents from a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| currents | Currents. |
| int commGetEmg | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | emg[2] | ||
| ) |
This function gets measurements from electomyographics sensors connected to the qbHand.
IS USED ONLY WHEN THE BOARD IS USED FOR A QBHAND
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| values | Emg sensors measurements. |
| int commGetInfo | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | info_type, | ||
| char * | info | ||
| ) |
This function is used to ping the qbMove or the qbHand and get information about the device.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| buffer | Buffer that stores a string with information about the device. BUFFER SIZE MUST BE AT LEAST 500. |
| info_type | Information to be retrieved. |
| int commGetInputs | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | inputs[2] | ||
| ) |
This function gets input references from a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| inputs | Input references. |
| int commGetJoystick | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | joystick[2] | ||
| ) |
This function gets joystick measurementes from a softhand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| joystick | Joystick analog measurements. |
| int commGetMeasurements | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | measurements[3] | ||
| ) |
This function gets position measurements from a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| measurements | Measurements. |
| int commGetParamList | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| unsigned short | index, | ||
| void * | values, | ||
| unsigned short | value_size, | ||
| unsigned short | num_of_values, | ||
| uint8_t * | buffer | ||
| ) |
This function gets all the parameters that are stored in the qbMove or qbHand memory and sets one of them if requested.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| index | The index relative to the parameter to be get. |
| values | An array with the parameter values. |
| value_size | The byte size of the parameter to be get |
| num_of_values | The size of the array of the parameter to be get |
| buffer | The array where the parameters' values and descriptions are saved |
| int commGetVelocities | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | measurements[] | ||
| ) |
This function gets velocities of the two motors and the shaft from a qbMove connected to a serial port or from the only shaft of the qbHand.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| measurements | Velocity measurements. |
| int commHandCalibrate | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | speed, | ||
| short int | repetitions | ||
| ) |
This function is used to make a series of opening and closures of the qbHand.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| speed | The speed of hand closure and opening [0 - 200] |
| repetitions | The nnumber of closures needed to be done [0 - 32767] |
| int commInitMem | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function initialize the EEPROM memory of the board by loading the default factory parameters.
After the initialization a flag is set.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| int commPing | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function is used to ping the qbMove or the qbHand.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| buffer | Buffer that stores a string with information about the device. BUFFER SIZE MUST BE AT LEAST 500. |
| int commRestoreParams | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function restores the factory default parameters.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| void commSetBaudRate | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | baudrate | ||
| ) |
This function sets the baudrate of communication.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| baudrate | BaudRate requested 0 = 2M baudrate, 1 = 460.8k baudrate |
| void commSetCuffInputs | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| int | flag | ||
| ) |
This function send reference inputs to a qbMove board connected to the serial port.
Is used only when the device is a Cuff.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| flag | A flag that indicates used to activate the cuff driving functionality of the board. |
| void commSetInputs | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | inputs[] | ||
| ) |
This function send reference inputs to a qbMove or a qbHand connected to the serial port.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| inputs | Input references. |
| int commSetInputsAck | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | inputs[] | ||
| ) |
This function send reference inputs to a qbMove or a qbHand connected to the serial port and expects an acknowledgment reply from the device.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| inputs | Input references. |
| void commSetPosStiff | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | inputs[] | ||
| ) |
This function send reference inputs to a qbMove connected to the serial port.
The reference is in shaft position and stiffness preset. IS VALID ONLY WHEN USED FOR THE qbMove, NOT FOR THE qbHand
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| inputs | Input references. |
| void commSetWatchDog | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| short int | wdt | ||
| ) |
This function sets watchdog timer of a qbMove or a qbHand.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| wdt | Watchdog timer in [csec], max value: 500 [cs] / min value: 0 (disable) [cs] |
| int commSetZeros | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| void * | values, | ||
| unsigned short | num_of_values | ||
| ) |
This function sets the encoders's zero positon value that remains stored in the qbMove or qbHand memory.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| value | An array with the encoder readings values. |
| num_of_values | The size of the values array, equal to the sensor number. |
| int commStoreDefaultParams | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function stores the factory default parameters.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| int commStoreParams | ( | comm_settings * | comm_settings_t, |
| int | id | ||
| ) |
This function stores all parameters that were set in the qbMove or the qbHand memory.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| void openRS485 | ( | comm_settings * | comm_settings_t, |
| const char * | port_s, | ||
| int | BAUD_RATE = B2000000 |
||
| ) |
This function is used to open a serial port for using with the qbMove or the qbHand.
| comm_settings | A comm_settings structure containing info about the communication settings. |
| port_s | The string to the serial port path. |
| BAUD_RATE | The default baud rate value of the serial port |
| void RS485GetInfo | ( | comm_settings * | comm_settings_t, |
| char * | buffer | ||
| ) |
This function is used to ping the serial port for a qbMove or a qbHand and to get information about the device.
ONLY USE WHEN ONE DEVICE IS CONNECTED ONLY.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| buffer | Buffer that stores a string with information about the device. BUFFER SIZE MUST BE AT LEAST 500. |
| int RS485ListDevices | ( | comm_settings * | comm_settings_t, |
| char | list_of_ids[255] | ||
| ) |
This function is used to list the number of devices connected to the serial port and get their relative IDs.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| list_of_ids[255] | Buffer that stores a list of IDs to ping, in order to see which of those IDs is connected. Is then filled with the IDs connected to the serial port. |
| int RS485listPorts | ( | char | list_of_ports[10][255] | ) |
This function is used to return a list of available serial ports.
A maximum of 10 ports are found.
| list_of_ports | An array of strings with the serial ports paths. |
| int RS485read | ( | comm_settings * | comm_settings_t, |
| int | id, | ||
| char * | package | ||
| ) |
This function is used to read a package from the device.
| comm_settings_t | A comm_settings structure containing info about the communication settings. |
| id | The device's id number. |
| package | Package will be stored here. |
| long timevaldiff | ( | struct timeval * | starttime, |
| struct timeval * | finishtime | ||
| ) |
This functions returns a difference between two timeval structures in order to obtain time elapsed between the two timeval;.
| starttime | The timeval structure containing the start time |
| finishtime | The timeval structure containing the finish time |