13#include <yarp/os/Searchable.h>
14#include <yarp/dev/CanBusInterface.h>
45#define BOARD_RUNNING 0
46#define BOARD_WAITING 1
47#define BOARD_WAITING_ACK 2
48#define BOARD_DOWNLOADING 3
52#define SPRS_STATE_WAIT 0
53#define SPRS_STATE_TYPE 1
54#define SPRS_STATE_ADDRESS 2
55#define SPRS_STATE_LENGTH 3
56#define SPRS_STATE_DATA 4
57#define SPRS_STATE_CHECKSUM 5
59#define SPRS_TYPE_0 '0'
60#define SPRS_TYPE_1 '1'
61#define SPRS_TYPE_3 '3'
62#define SPRS_TYPE_4 '4'
63#define SPRS_TYPE_7 '7'
66#define ID_BROADCAST 0x0F
82#include <iCubCanProto_types.h>
85#define DOWNLOADER_USE_IDRIVER2
88#if defined(DOWNLOADER_USE_IDRIVER2)
90#define DOWNLOADER_ETH_SUPPORTS_MULTIBUS
98 void load(
void *mem,
size_t s) { memmove(
data, mem,
sizeof(
data)); }
116#if defined(DOWNLOADER_USE_IDRIVER2)
118 vector<CanPacket> txBuffer;
119 vector<CanPacket> rxBuffer;
122 yarp::dev::CanBuffer txBuffer;
123 yarp::dev::CanBuffer rxBuffer;
129 bool strain_is_acquiring_in_calibratedmode;
132int download_motorola_line(
char* line,
int len,
int bus,
int board_pid);
133int download_hexintel_line(
char* line,
int len,
int bus,
int board_pid,
bool eeprom,
int board_type);
135int build_id(
int source,
int dest);
136int get_src_from_id (
int id);
137int get_dst_from_id (
int id);
139int verify_ack(
int command,
int read_messages);
142enum { ampl_gain_numberOf = 13 };
159int initdriver(yarp::os::Searchable &config,
bool verbose =
true);
163int startscheda (
int bus,
int board_pid,
bool board_eeprom,
int download_type);
165int download_file (
int bus,
int board_pid,
int download_type,
bool eeprom);
171int get_firmware_version(
int bus,
int target_id, eObrd_cantype_t boardtype, eObrd_info_t *info,
bool &noreply);
188int strain_calibrate_offset (
int bus,
int target_id, icubCanProto_boardType_t boardtype,
unsigned int middle_val,
string *errorstring = NULL);
190int strain_calibrate_offset2 (
int bus,
int target_id, icubCanProto_boardType_t boardtype,
const std::vector<strain2_ampl_discretegain_t> &gains,
const std::vector<int16_t> &targets,
string *errorstring = NULL);
193int strain_get_adc (
int bus,
int target_id,
char channel,
unsigned int& adc,
int type,
string *errorstring = NULL);
197int strain_get_curr_bias (
int bus,
int target_id,
char channel,
signed int& bias,
string *errorstring = NULL);
251 if(NULL == ss6)
return;
252 for(
size_t i=0; i<6; i++) { ss6[i] =
static_cast<unsigned short>(
channel[i]) - 0x7fff; }
270void set_external_logger(
void *caller = NULL,
void (*logger)(
void *,
const std::string &) = NULL);
276#if defined(DOWNLOADER_USE_IDRIVER2)
280 void set_bus(yarp::dev::CanMessage &msg,
int bus);
281 int get_bus(yarp::dev::CanMessage &msg);
287 int strain_calibrate_offset2_strain1(
int bus,
int target_id, int16_t t,
string *errorstring);
288 int strain_calibrate_offset2_strain1safer(
int bus,
int target_id, int16_t t, uint8_t nmeasures,
bool fullsearch,
string *errorstring);
289 int strain_calibrate_offset2_strain2(
int bus,
int target_id,
const std::vector<strain2_ampl_discretegain_t> &gains,
const std::vector<int16_t> &targets,
string *errorstring = NULL);
291 int readADC(
int bus,
int target_id,
int channel,
int nmeasures = 2);
293 void (*_externalLoggerFptr)(
void *caller,
const std::string &output);
294 void * _externalLoggerCaller;
296 void Log(
const std::string &msg);
int open_file(std::string file)
int strain_get_serial_number(int bus, int target_id, char *serial_number, string *errorstring=NULL)
int strain_set_matrix_gain(int bus, int target_id, unsigned int gain, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_acquire_start(int bus, int target_id, uint8_t txratemilli=20, bool calibmode=true, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
int strain_get_offset(int bus, int target_id, char channel, unsigned int &offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int change_card_address(int bus, int target_id, int new_id, int board_type)
int strain_get_full_scale(int bus, int target_id, unsigned char channel, unsigned int &full_scale, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_get_calib_bias(int bus, int target_id, char channel, signed int &bias, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_reset_curr_bias(int bus, int target_id, string *errorstring=NULL)
int get_board_info(int bus, int target_id, char *board_info)
int strain_set_offset(int bus, int target_id, char channel, unsigned int offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int startscheda(int bus, int board_pid, bool board_eeprom, int download_type)
int strain_set_serial_number(int bus, int target_id, const char *serial_number, string *errorstring=NULL)
int strain_acquire_stop(int bus, int target_id, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, string *errorstring=NULL)
int strain_set_amplifier_discretegain(int bus, int target_id, unsigned char channel, strain2_ampl_discretegain_t ampset, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_get_regulationset(int bus, int target_id, int ®set, const int regsetmode=strain_regsetmode_temporary, string *errorstring=NULL)
int stopscheda(int bus, int board_pid)
int strain_save_to_eeprom(int bus, int target_id, string *errorstring=NULL)
void set_verbose(bool verbose)
int strain_acquire_get(int bus, int target_id, vector< strain_value_t > &values, const unsigned int howmany=10, void(*updateProgressBar)(void *, float)=NULL, void *arg=NULL, strain_acquisition_mode_t acqmode=strain_acquisition_mode_streaming, const unsigned int maxerrors=1, string *errorstring=NULL)
int change_board_info(int bus, int target_id, char *board_info)
int strain_get_adc(int bus, int target_id, char channel, unsigned int &adc, int type, string *errorstring=NULL)
int strain_stop_sampling(int bus, int target_id, string *errorstring=NULL)
strain_acquisition_mode_t
@ strain_acquisition_mode_polling
@ strain_acquisition_mode_streaming
int initdriver(yarp::os::Searchable &config, bool verbose=true)
int strain_set_calib_bias(int bus, int target_id, char channel, signed int bias, int regset=strain_regset_inuse, string *errorstring=NULL)
void set_canbus_id(int id)
int strain_get_eeprom_saved(int bus, int target_id, bool *status, string *errorstring=NULL)
int get_firmware_version(int bus, int target_id, eObrd_cantype_t boardtype, eObrd_info_t *info, bool &noreply)
int get_serial_no(int bus, int target_id, char *board_info)
int strain_reset_calib_bias(int bus, int target_id, string *errorstring=NULL)
int strain_get_matrix_gain(int bus, int target_id, unsigned int &gain, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_get_matrix_rc(int bus, int target_id, char r, char c, unsigned int &elem, int regset=strain_regset_inuse, string *errorstring=NULL)
void set_external_logger(void *caller=NULL, void(*logger)(void *, const std::string &)=NULL)
int strain_set_full_scale(int bus, int target_id, unsigned char channel, unsigned int full_scale, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_regulationset(int bus, int target_id, int regset=strain_regset_one, int regsetmode=strain_regsetmode_temporary, string *errorstring=NULL)
@ strain_regsetmode_permanent
@ strain_regsetmode_temporary
int strain_set_calib_bias(int bus, int target_id, string *errorstring=NULL)
int strain_get_amplifier_regs(int bus, int target_id, unsigned char channel, strain2_ampl_regs_t &regs, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_curr_bias(int bus, int target_id, string *errorstring=NULL)
int strain_get_curr_bias(int bus, int target_id, char channel, signed int &bias, string *errorstring=NULL)
int strain_start_sampling(int bus, int target_id, string *errorstring=NULL)
int download_file(int bus, int board_pid, int download_type, bool eeprom)
int strain_get_amplifier_gain_offset(int bus, int target_id, unsigned char channel, float &gain, uint16_t &offset, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_matrix_rc(int bus, int target_id, char r, char c, unsigned int elem, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_curr_bias(int bus, int target_id, char channel, signed int bias, string *errorstring=NULL)
int strain_set_amplifier_regs(int bus, int target_id, unsigned char channel, const strain2_ampl_regs_t &regs, int regset=strain_regset_inuse, string *errorstring=NULL)
int strain_set_amplifier_gain_offset(int bus, int target_id, unsigned char channel, float gain, uint16_t offset, int regset=strain_regset_inuse, string *errorstring=NULL)
float strain_amplifier_discretegain2float(strain2_ampl_discretegain_t c)
int strain_calibrate_offset2(int bus, int target_id, icubCanProto_boardType_t boardtype, const std::vector< strain2_ampl_discretegain_t > &gains, const std::vector< int16_t > &targets, string *errorstring=NULL)
int strain_calibrate_offset(int bus, int target_id, icubCanProto_boardType_t boardtype, unsigned int middle_val, string *errorstring=NULL)
void drv_sleep(double time)
strain2_ampl_discretegain_t
icubCanProto_strain_saturationInfo_t saturationinfo[6]
void extract(signed short *ss6) const
bool applicationisrunning
void load(void *mem, size_t s)