/*set up hash table with configuration strings to match values in moses.conf*/ void main_init() { uint config_size = num_threads + NUM_IO; char * config_strings[num_threads + NUM_IO]; /*allocate strings to match with configuration file*/ config_strings[hlp_control_thread] = HLP_CONTROL_CONF; config_strings[hlp_down_thread] = DOWN_CONF; config_strings[gpio_control_thread] = GPIO_CONTROL_CONF; config_strings[hlp_shell_thread] = SHELL_CONF; config_strings[sci_timeline_thread] = SCIENCE_CONF; config_strings[telem_thread] = TELEM_CONF; config_strings[image_writer_thread] = IMAGE_WRITER_CONF; config_strings[fpga_server_thread] = FPGA_SERVER_CONF; config_strings[hlp_up_interface] = HKUP_CONF; config_strings[hlp_down_interface] = HKDOWN_CONF; config_strings[roe_interface] = ROE_CONF; config_strings[image_sim_interface] = IMAGE_SIM_CONF; config_strings[synclink_interface] = SYNCLINK_CONF; /*initialize memory for configuration hash table*/ if ((config_hash_table = calloc(config_size, sizeof (node_t))) == NULL) { record("calloc failed to allocate hash table\n"); } /*fill hash table with array of strings matching indices for configuration values*/ uint i; for (i = 0; i < config_size; i++) { int * int_def = malloc(sizeof (int)); *int_def = i; /*insert node into hash table*/ installNode(config_hash_table, config_strings[i], int_def, config_size); } /*fill array of function pointers for pthread call*/ tfuncs[hlp_control_thread] = hlp_control; tfuncs[hlp_down_thread] = hlp_down; tfuncs[gpio_control_thread] = gpio_control; tfuncs[hlp_shell_thread] = hlp_shell_out; tfuncs[sci_timeline_thread] = science_timeline; tfuncs[telem_thread] = telem; tfuncs[image_writer_thread] = write_data; tfuncs[fpga_server_thread] = fpga_server; /*initialize locking queues*/ for (i = 0; i < QUEUE_NUM; i++) { lockingQueue_init(&lqueue[i]); } }
void * controlThread(void * arg){ lockingQueue_init(&hkupQueue); while(ts_alive){ Packet p = dequeue(&hkupQueue); if(p.valid){ printf("%s%s%s%s%s%s%d\n",p.timeStamp, p.type, p.subtype, p.dataLength, p.data, p.checksum, p.valid); //printf("%c%c\n", p.type, p.checksum); } else{ printf("Bad Packet\n"); } printf("\n"); } lockingQueue_destroy(&hkupQueue); return; }