void drp_debug5(void){ int value=0, res=0; unsigned int index; printf("dat_reset_Payload_Buff()..\n"); int pay_i; int lenBuff=10, r_nextIndx, r_MaxIndx; for(pay_i=0; pay_i<dat_pay_last_one; pay_i++, lenBuff=lenBuff+1){ printf(" writing: "); dat_reset_Payload_Buff(pay_i, lenBuff, 0); printf(" dat_reset_Payload_Buff(%d, %d)\r\n", pay_i, lenBuff); printf(" reading: "); r_nextIndx = dat_get_NextPayIndx(pay_i); printf(" dat_get_NextPayIndx(%u) = %d | ", pay_i, r_nextIndx); r_MaxIndx = dat_get_MaxPayIndx(pay_i); printf(" dat_get_MaxPayIndx(%u) = %d | \n", pay_i, r_MaxIndx); printf(" comparing: "); if( r_nextIndx==0 && r_MaxIndx==(lenBuff-1) ){ printf("ok\n"); } else{ printf("fail\n"); return; } ClrWdt(); } printf("DAT_Payload_Buff..\n"); int maxind; BOOL st; for(pay_i=0; pay_i<dat_pay_last_one; pay_i++){ value=20000; st = TRUE; maxind = dat_get_MaxPayIndx(pay_i); for(index=0; st==TRUE; index++, value++){ printf(" writing: "); dat_set_Payload_Buff(pay_i, value, DAT_PAYBUFF_MODE_NO_MAXINDX); printf(" DAT_Payload_Buff[%u][%u] = %d | ",pay_i, index, value); printf("%d/%d [NextIndx/MaxIndx] | \n", dat_get_NextPayIndx(pay_i), dat_get_MaxPayIndx(pay_i) ); printf(" reading: "); dat_get_Payload_Buff(pay_i, index, &res); printf(" DAT_Payload_Buff[%u][%u] = %d | \n",pay_i, index, res); printf(" comparing: "); if( value==res ){ printf("ok\n"); } else{ printf("fail\n"); return; } if( dat_isFull_Payload_Buff(pay_i)==TRUE){ printf(" DAT_Payload_Buff[%u] esta lleno\r\n", pay_i); st = FALSE; } ClrWdt(); } printf("*******************************************\n"); } printf("End of drp_debug5\n"); }
int drp_print_dat_PayloadIndxs(void *param){ printf("===================================\r\n"); printf("Reading sta_PayloadIndxs Block\r\n"); printf("===================================\r\n"); // char buffer[10]; DAT_Payload_Buff pay_i; for(pay_i=0; pay_i<dat_pay_last_one; pay_i++) { unsigned int max = dat_get_MaxPayIndx( pay_i); unsigned int next = dat_get_NextPayIndx( pay_i); printf("pay_i = %u | maxIndx = %d | next = %d \r\n", (unsigned int)pay_i, max, next); // itoa(buffer, (unsigned int)pay_i,10); // con_printf(buffer); con_printf("\r\n"); // con_printf(" MaxIndx="); // itoa(buffer, (unsigned int)max,10); // sprintf (buffer, "0x%X", (unsigned int)max); // con_printf(buffer); con_printf("\r\n"); // con_printf(" NextIndx="); // //itoa(buffer, (unsigned int)next,10); // sprintf (buffer, "0x%X", (unsigned int)next); // con_printf(buffer); con_printf("\r\n"); } return 1; }
//Retorna FALSE si el indiex es invalido, TRUE si todo OK BOOL dat_get_Payload_Buff(DAT_Payload_Buff pay_i, unsigned int indx, int *value) { unsigned int desiredIndx, nextIndx; // Descarta si pay_i invalido if(pay_i>=dat_pay_last_one) { #if (SCH_DATAREPOSITORY_VERBOSE>=1) printf("dat_get_Payload_Buff: invalid payload\n"); #endif return FALSE; //payload invalido } // Descarta si indx invalido (fuera de rango) desiredIndx = indx; //maxIndx = dat_get_MaxPayIndx(pay_i); nextIndx = dat_get_NextPayIndx(pay_i); if(desiredIndx > nextIndx) { #if (SCH_DATAREPOSITORY_VERBOSE>=1) printf("dat_get_PayloadBuff: indx > nextIndx (%04u)\n", nextIndx); #endif return FALSE; } //obtengo el valor de value unsigned long block = dat_pay_i_to_block(pay_i); msd_getVar_256BlockExtMem(block, desiredIndx, value); return TRUE; }
BOOL dat_isFull_Payload_Buff(DAT_Payload_Buff pay_i) { unsigned int nextIndx, maxIndx; if(pay_i>=dat_pay_last_one) { #if (SCH_DATAREPOSITORY_VERBOSE>=2) printf("isFullPayload_Buffer: payload invalido\n"); #endif return FALSE; //payload invalido } nextIndx = dat_get_NextPayIndx(pay_i); maxIndx = dat_get_MaxPayIndx(pay_i); if(nextIndx>maxIndx) { #if (SCH_DATAREPOSITORY_VERBOSE>=2) printf("isFullPayload_Buffer: buffer lleno, desiredIndx>maxIndx\n"); #endif return TRUE; //buffer lleno, indice fuera de rango } return FALSE; }
/** * Save value in the corresponding pay_i dataRepo * @param pay_i * @param value * @param mode * @return FALSE if there is any problem, TRUE if not */ BOOL dat_set_Payload_Buff(DAT_Payload_Buff pay_i, int value) { // guarda "value" en la sgte posicion libre del buffer, // y retorna si lo logro o no (buffer lleno, payload invalido) unsigned int nextIndx; // Descarta si pay_i invalido if(pay_i>=dat_pay_last_one) { #if (SCH_DATAREPOSITORY_VERBOSE>=1) printf("dat_set_Payload_Buff: payload invalido\n"); #endif return FALSE; } // if(mode == DAT_PAYBUFF_MODE_USE_MAXINDX){ // printf("dat_set_PayloadBuff: Using MAXINDX mode\n"); // // Descarta si pay_i esta lleno // if( dat_isFull_Payload_Buff(pay_i)==TRUE){ // #if (SCH_DATAREPOSITORY_VERBOSE>=1) // printf("dat_set_PayloadBuff: nextIndx > maxIndx\n"); // #endif // return FALSE; // } // } //Obtiene nextIndx (posicion en la que se ha de guardar) nextIndx = dat_get_NextPayIndx(pay_i); #if (SCH_DATAREPOSITORY_VERBOSE>=2) printf("setPayloadVar [%04d] = %0x%X\n", nextIndx, value); #endif //guardo el valor de value unsigned long block = dat_pay_i_to_block(pay_i); msd_setVar_256BlockExtMem(block, nextIndx, value); //actualizo nextIndx dat_set_NextPayIndx(pay_i, nextIndx+1); return TRUE; }
void drp_debug4(void){ int value=0, res=0; unsigned int index; printf("DAT_TeleCmdBuff..\n"); value=20000; for(index=0; index<SCH_DATAREPOSITORY_MAX_BUFF_TELECMD; index++, value++){ printf(" writing: "); dat_set_TeleCmd_Buff(index, value); printf(" DAT_TeleCmdBuff[%u] = %d | ", index, value); printf(" reading: "); res = dat_get_TeleCmd_Buff(index); printf(" DAT_TeleCmdBuff[%u] = %d | ", index, res); printf("comparing: "); if( value==res ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } printf("DAT_FlightPlanBuff..\n"); value=1000; DispCmd NewCmd; for(index=0; index<(SCH_FLIGHTPLAN_N_CMD); index++, value++){ printf(" writing: "); dat_set_FlightPlan_cmd(index, value); printf(" DAT_FlightPlanBuff[%u].cmd = %d | ", index, value); dat_set_FlightPlan_param(index, value+1); printf(" DAT_FlightPlanBuff[%u].param = %d | \n", index, value+1); printf(" reading: "); NewCmd = dat_get_FlightPlan(index); printf(" DAT_FlightPlanBuff[%u].cmd = %d | ", index, NewCmd.cmdId); printf(" DAT_FlightPlanBuff[%u].param = %d | \n", index, NewCmd.param); printf(" comparing: "); if( value==NewCmd.cmdId && (value+1)==NewCmd.param ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } printf("DAT_NextPayBuff and DAT_MaxPayBuff..\n"); int pay_i; int n=0, m=49, res1, res2; for(pay_i=0; pay_i<dat_pay_last_one; pay_i++, m=m+10){ printf(" writing: "); dat_set_NextPayIndx(pay_i, n); printf(" DAT_NextPayBuff[%u] = %d | ", pay_i, n); dat_set_MaxPayIndx(pay_i, m); printf(" DAT_NextPayBuff[%u] = %d | \n", pay_i, m); printf(" reading: "); res1 = dat_get_NextPayIndx(pay_i); printf(" DAT_NextPayBuff[%u] = %d | ", pay_i, res1); res2 = dat_get_MaxPayIndx(pay_i); printf(" DAT_MaxPayBuff[%u] = %d | \n", pay_i, res2); printf(" comparing: "); if( n==res1 && m==res2 ){ printf("ok\n"); } else{ printf("fail\n"); return; } ClrWdt(); } printf("DAT_Payload_Buff..\n"); int maxind; for(pay_i=0; pay_i<dat_pay_last_one; pay_i++){ value=20000; maxind = dat_get_MaxPayIndx(pay_i); for(index=0; index<=maxind; index++, value++){ printf(" writing: "); dat_set_Payload_Buff(pay_i, value, DAT_PAYBUFF_MODE_NO_MAXINDX); printf(" DAT_Payload_Buff[%u][%u] = %d | ",pay_i, index, value); printf("%d/%d [NextIndx/MaxIndx] | \n", dat_get_NextPayIndx(pay_i), dat_get_MaxPayIndx(pay_i) ); printf(" reading: "); dat_get_Payload_Buff(pay_i, index, &res); printf(" DAT_Payload_Buff[%u][%u] = %d | \n",pay_i, index, res); printf(" comparing: "); if( value==res ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } printf("*******************************************\n"); } printf("DAT_AuxBuff..\n"); int aux_i; int maxind2; for(aux_i=0; aux_i<dat_aux_last_one; aux_i++){ value=20000; maxind2 = 30; for(index=0; index<=maxind2; index++, value++){ printf(" writing: "); dat_set_Aux_Buff(aux_i, index, value); printf(" DAT_AuxdBuff[%u] = %d | ", index, value); printf(" reading: "); res = dat_get_Aux_Buff(aux_i, index); printf(" DAT_AuxdBuff[%u] = %d | ", index, res); printf(" comparing: "); if( value==res ){ printf("ok\n"); } else{ con_printf("fail\n"); return; } ClrWdt(); } printf("*******************************************\n"); } printf("End of drp_debug4\n"); }