static void do_write(struct ZS_thread_state *thd_state, uint32_t start, uint32_t cnt, int iter, bool overflow_freq) { char *key; uint32_t keylen; ZS_status_t status; uint32_t i; for (i = start; i < start + cnt; i++) { key = malloc(ZS_MAX_KEY_LEN); sprintf(key, "key_%04d", i); keylen = strlen(key) + 1; if (overflow_freq && (i % overflow_freq)) { values[i].vallen = OVERFLOW_DATA_SIZE; } else { values[i].vallen = INNODE_DATA_SIZE; } gen_data(values[i].value, values[i].vallen, iter); status = ZSWriteObject(thd_state, cguid, key, keylen, values[i].value, values[i].vallen, 0); if (status != ZS_SUCCESS) { printf("ZSWrite failed for key %d\n", i); fflush(stdout); } free(key); } }
bool range_update_cb(char *key, uint32_t keylen, char *data, uint32_t datalen, void *callback_args, char **new_data, uint32_t *new_datalen) { *new_datalen = 0; (*new_data) = NULL; objs_processed++; if (!change_data) { return false; } if (length_incr) { assert((datalen + length_incr) > 0); (*new_data) = (char *) malloc(datalen + length_incr); if (*new_data == NULL) { return false; } *new_datalen = datalen + length_incr; //Change in data size gen_data(*new_data, *new_datalen, 999 + objs_processed); } else { data[0] = 'O'; } return true; }
char *levenshtein(char *str, UNUSED char **env) { char **dic; char **command; int i; int pos; i = 0; pos = 0; command = cut_command(str); if ((dic = gen_data(save_my_env(NULL))) == NULL) return (str); while (command && command[i] != NULL) { if (i == 0 || is_separator_ext(command[i - 1][0]) == 0) { if (check_command(command[i], save_my_env(NULL)) == -1) { pos = where_is_space(command[i]); command[i] = change_command(command[i], leven(dic, po_s(command[i], pos))); } } i++; } free_array_char(dic); return (tab_string(command)); }
static void do_mput(struct ZS_thread_state *thd_state, uint32_t start, uint32_t cnt, int iter, uint32_t overflow_freq) { int i; ZS_status_t status; ZS_obj_t *objs = NULL; uint32_t objs_written; uint32_t keyind = start; objs = (ZS_obj_t *) malloc(sizeof(ZS_obj_t) * cnt); if (objs == NULL) { printf("Cannot allocate memory.\n"); fflush(stdout); exit(0); } memset(objs, 0, sizeof(ZS_obj_t) * cnt); for (i = 0, keyind = start; i < cnt; i++, keyind++) { objs[i].key = malloc(ZS_MAX_KEY_LEN); if (objs[i].key == NULL) { printf("Cannot allocate memory.\n"); fflush(stdout); exit(0); } sprintf(objs[i].key, "key_%04d", start + i); objs[i].key_len = strlen(objs[i].key) + 1; if ((overflow_freq == 0) || (i % overflow_freq)) { values[keyind].vallen = INNODE_DATA_SIZE; } else { values[keyind].vallen = OVERFLOW_DATA_SIZE; } gen_data(values[keyind].value, values[keyind].vallen, iter); objs[i].data = values[keyind].value; objs[i].data_len = values[keyind].vallen; objs[i].flags = 0; } uint32_t flags = 0; status = ZSMPut(thd_state, cguid, cnt, &objs[0], flags, &objs_written); if (status != ZS_SUCCESS) { printf("Failed to write objects using ZSMPut, status = %d.\n", status); fflush(stdout); assert(0); return ; } for (i = 0; i < cnt; i++) { free(objs[i].key); } }
/* Function: Reset the Network Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the NR command Parameters: reset --> Possible values are 0/1 0: reset the node network interface 1: reset the entirely network */ uint8_t WaspXBeeZB::resetNetwork(uint8_t reset) { int8_t error=2; error_AT=2; gen_data(reset_network_ZB,reset); gen_checksum(reset_network_ZB); error=gen_send(reset_network_ZB); return error; }
/* Function: Restore module parameters to compiled defaults Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the R1 command. */ uint8_t WaspXBee900::restoreCompiled() { int8_t error=2; error_AT=2; char buffer[20]; //restore_compiled_900 strcpy_P(buffer, (char*)pgm_read_word(&(table_900[6]))); gen_data(buffer); error=gen_send(buffer); return error; }
/* Function: Get the minimum value of the back-off exponent in CSMA/CA Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "delaySlots" variable the back-off exponent */ uint8_t WaspXBee802::getDelaySlots() { int8_t error=2; error_AT=2; gen_data(get_delay_slots_802); error=gen_send(get_delay_slots_802); if(!error) { delaySlots=data[0]; } return error; }
/* Function: Gets the number of retries than can be sent for a given unicast RF packet Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the RR command */ uint8_t WaspXBee868::getMacRetries() { int8_t error=2; error_AT=2; gen_data(get_retries_868); error=gen_send(get_retries_868); if(error==0) { macRetries=data[0]; } return error; }
/* Function: Get the maximum number of hops for each broadcast data transmission Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the BH command. Stores in global "maxBroadcastHops" variable the max number of broadcast hops */ uint8_t WaspXBeeZB::getMaxBroadcastHops() { int8_t error=2; error_AT=2; gen_data(get_max_brd_hops_ZB); error=gen_send(get_max_brd_hops_ZB); if(error==0) { maxBroadcastHops=data[0]; } return error; }
/* Function: Get the ZigBee Stack profile Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the ZS command. Stores in global "stackProfile" variable the stack profile */ uint8_t WaspXBeeZB::getStackProfile() { int8_t error=2; error_AT=2; gen_data(get_stack_profile_ZB); error=gen_send(get_stack_profile_ZB); if(error==0) { stackProfile=data[0]; } return error; }
/* Function: Get the Mac Mode Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "macMode" variable the Mac Mode */ uint8_t WaspXBee802::getMacMode() { int8_t error=2; error_AT=2; gen_data(get_mac_mode_802); error=gen_send(get_mac_mode_802); if(!error) { macMode=data[0]; } return error; }
/* Function: Returns the number of children which can still connect to the current device Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the NC command. Stores in global "remainingChildren" variable the number of remaining children which can connect to this device */ uint8_t WaspXBeeZB::getRemainingChildren() { int8_t error=2; error_AT=2; gen_data(get_rem_children_ZB); error=gen_send(get_rem_children_ZB); if(error==0) { remainingChildren=data[0]; } return error; }
/* Function: Tells the reason for the last module reset Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the R# command */ uint8_t WaspXBee868::getResetReason() { int8_t error=2; error_AT=2; gen_data(get_reset_reason_868); error=gen_send(get_reset_reason_868); if(error==0) { resetReason=data[0]; } return error; }
/* Function: Get the % it has been used of available Duty Cicle Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the DC command */ uint8_t WaspXBee868::getDutyCicle() { int8_t error=2; error_AT=2; gen_data(get_duty_cicle_868); error=gen_send(get_duty_cicle_868); if(error==0) { dutyCicle=data[0]; } return error; }
/* Function: Read the channel verification parameter Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the JV command. Stores in global "channelVerification" variable any error happened while execution */ uint8_t WaspXBeeZB::getChannelVerification() { int8_t error=2; error_AT=2; gen_data(get_channel_verif_ZB); error=gen_send(get_channel_verif_ZB); if(error==0) { channelVerification=data[0]; } return error; }
/* Function: Gets the number of additional broadcast retransmissions Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the MT command */ uint8_t WaspXBee868::getMultipleBroadcast() { int8_t error=2; error_AT=2; gen_data(get_mult_broadcast_868); error=gen_send(get_mult_broadcast_868); if(error==0) { multipleBroadcast=data[0]; } return error; }
/* Function: Get the Energy Threshold used in the CCA process Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Stores in global "energyThreshold" variable any error happened while execution */ uint8_t WaspXBee802::getEnergyThreshold() { int8_t error=2; error_AT=2; gen_data(get_energy_thres_802); error=gen_send(get_energy_thres_802); if(!error) { energyThreshold=data[0]; } return error; }
/* do a chi-squared test */ static void chi2_test(void (*gen_data)(double *data, int idx)) { double sample_data[DATA_SIZE], chi2_data[DATA_SIZE], chi2; for (int i = 0; i < ARRAY_SIZE(chi2_data); i++) { gen_data(sample_data, i); chi2_data[i] = get_chi2(sample_data, uniform_dist); } chi2 = get_chi2(chi2_data, chi2_dist); ck_assert_msg(chi2 < CV, "chi-square test failed (chi-square: %lf," " critical value: %lf)", chi2, CV); }
/* Function: Read the time that a Coordinator/Router allows nodes to join Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the NJ command. Stores in global "joinTime" variable the time allowing join */ uint8_t WaspXBeeZB::getJoinTime() { int8_t error=2; error_AT=2; gen_data(get_join_time_ZB); error=gen_send(get_join_time_ZB); if(error==0) { joinTime=data[0]; } return error; }
/* Function: Read information regarding last node join request Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the AI command. Stores in global "associationIndication" variable any error happened while execution */ uint8_t WaspXBeeZB::getAssociationIndication() { int8_t error=2; error_AT=2; gen_data(get_assoc_indic_ZB); error=gen_send(get_assoc_indic_ZB); if(error==0) { associationIndication=data[0]; } return error; }
int do_sdtest3(int fd, nsc_size_t loops, nsc_size_t filesize, int h, nsc_fd_t *sdfd) { nsc_off_t *seekpos; int err = 0; nsc_size_t i; ssize_t r; seekpos = malloc(loops*sizeof (nsc_off_t)); if (seekpos == NULL) { perror("Test3: malloc"); (void) nsc_close(sdfd); exit(errno); } gen_data(buf1, bufsize); for (i = 0; i < loops; i++) { seekpos[i] = ( #ifdef NSC_MULTI_TERABYTE ((nsc_off_t)rand() << 48) | ((nsc_off_t)rand() << 32) | #endif (rand() << 16) | rand()) % filesize; seekpos[i] -= seekpos[i] % fba_num_bufsize; r = pwrite(fd, buf1, bufsize, (off_t)(seekpos[i] << SCTRSHFT)); if (r <= 0) { perror("Test3: write"); err++; goto cleanup; } } for (i = 0; i < loops; i++) { buf2[0] = '\0'; /* clear buf to make sure something is read */ r = pread(fd, buf2, bufsize, (off_t)(seekpos[i] << SCTRSHFT)); if (r <= 0) { perror("Test3: read"); err++; goto cleanup; } if (memcmp(buf1, buf2, bufsize)) { (void) printf("Data corruption, fd:%s, fpos:%" PRId64 ", len:%d\n", name[h], (int64_t)(seekpos[i] << SCTRSHFT), bufsize); err++; } } cleanup: free(seekpos); return (err); }
/* Function: Read the power mode of the device Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the PM command. Stores in global "powerMode" variable the power mode */ uint8_t WaspXBeeZB::getPowerMode() { int8_t error=2; error_AT=2; gen_data(get_power_mode_ZB); error=gen_send(get_power_mode_ZB); if(error==0) { powerMode=data[0]; } return error; }
/* Function: Read options for encryption Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the EO command. Stores in global "encrypOptions" variable any error happened while execution */ uint8_t WaspXBeeZB::getEncryptionOptions() { int8_t error=2; error_AT=2; gen_data(get_encryp_options_ZB); error=gen_send(get_encryp_options_ZB); if(error==0) { encryptOptions=data[0]; } return error; }
/* Function: Get time between consecutive aggregate route broadcast messages Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the AR command. Stores in global "aggregateNotification" variable the time */ uint8_t WaspXBeeZB::getAggregateNotification() { int8_t error=2; error_AT=2; gen_data(get_aggreg_notif_ZB); error=gen_send(get_aggreg_notif_ZB); if(error==0) { aggregateNotification=data[0]; } return error;; }
/* Function: Read the join notification setting Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Executes the JN command. Stores in global "error" variable any error happened while execution */ uint8_t WaspXBeeZB::getJoinNotification() { int8_t error=2; error_AT=2; gen_data(get_join_notif_ZB); error=gen_send(get_join_notif_ZB); if(error==0) { joinNotification=data[0]; } return error; }
/* Function: Set the channel verification parameter Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the JV command Parameters: verif: channel verification parameter (0-1) */ uint8_t WaspXBeeZB::setChannelVerification(uint8_t verif) { int8_t error=2; error_AT=2; gen_data(set_channel_verif_ZB,verif); gen_checksum(set_channel_verif_ZB); error=gen_send(set_channel_verif_ZB); if(error==0) { channelVerification=verif; } return error; }
/* Function: Set the power mode of the device Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the PM command Parameters: power: power mode (0-1) */ uint8_t WaspXBeeZB::setPowerMode(uint8_t power) { int8_t error=2; error_AT=2; gen_data(set_power_mode_ZB,power); gen_checksum(set_power_mode_ZB); error=gen_send(set_power_mode_ZB); if(error==0) { powerMode=power; } return error; }
/* Function: Configure options for encryption Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the EO command Parameters: eoptions: options for encryption (0x00-0xFF) */ uint8_t WaspXBeeZB::setEncryptionOptions(uint8_t eoptions) { int8_t error=2; error_AT=2; gen_data(set_encryp_options_ZB,eoptions); gen_checksum(set_encryp_options_ZB); error=gen_send(set_encryp_options_ZB); if(error==0) { encryptOptions=eoptions; } return error; }
/* Function: Set time between consecutive aggregate route broadcast messages Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the AR command Parameters: anotif: time between consecutive aggregate route broadcast messages (0x00-0xFF) */ uint8_t WaspXBeeZB::setAggregateNotification(uint8_t anotif) { int8_t error=2; error_AT=2; gen_data(set_aggreg_notif_ZB,anotif); gen_checksum(set_aggreg_notif_ZB); error=gen_send(set_aggreg_notif_ZB); if(error==0) { aggregateNotification=anotif; } return error; }
/* Function: Set the join notification setting Returns: Integer that determines if there has been any error error=2 --> The command has not been executed error=1 --> There has been an error while executing the command error=0 --> The command has been executed with no errors Values: Change the JN command Parameters: notif: join notification setting (0-1) */ uint8_t WaspXBeeZB::setJoinNotification(uint8_t notif) { int8_t error=2; error_AT=2; gen_data(set_join_notif_ZB,notif); gen_checksum(set_join_notif_ZB); error=gen_send(set_join_notif_ZB); if(error==0) { joinNotification=notif; } return error; }