#include "plt.h" void e3ks_comm_dac( int idx ) { unsigned short tab_us[128]={0}; struct e3ks_t* dev = &e3ks[idx]; struct comm_t* comm = &dev->comm; int start, nb; int chanidx = comm->chanidx; int addr = comm->adr; if(comm_get_state(comm) != COMMST_NORMAL){ return; } comm_start_cal_dac_timing(comm); nb = 77; start = 0x0000; if( chan_read_holdingregisters_with_retry( chanidx, addr, start, nb, tab_us) < 0){ comm_set_state(comm, COMMST_ERR); return; }else{ /* read ok */ dev->bat_v = tab_us[8 - start]/10; dev->temp = tab_us[13 - start]/10; dev->status = tab_us[64 - start]&0xF; if( dev->status == E3KS_STATUS_BAT ){ strcpy(dev->szstatus, "bat"); }else if( dev->status == E3KS_STATUS_LINE ){ strcpy(dev->szstatus, "line"); }else{ strcpy(dev->szstatus, "unknown"); } dev->line = tab_us[64 - start]>>7&0x01; comm_stop_cal_dac_timing(comm); } } int e3ks_comm_init(int idx) { struct e3ks_t* dev = &e3ks[idx]; struct comm_t* comm = &dev->comm; comm_set_state( comm, COMMST_ERR ); } int e3ks_comm_reset(int idx) { struct e3ks_t* dev = &e3ks[idx]; struct comm_t* comm = &dev->comm; comm_set_state( comm, COMMST_NORMAL ); }