void Task1() { int i, j; unsigned char t1, t2; while(1) { for(i = 0; i < 8; i++) { t1 = (0x01 << i); // Disable column transmit_data(0, 1); // which rows t2 = 0; for(j = 0; j < 5; j++) { t2 |= field[4-j][7-i] << j; } transmit_data(~(t2), 0); // which column transmit_data(t1, 1); vTaskDelay(2); } } }
void input_person_sampleSerial::on_b_ok_clicked() { if(ui->lineEdit_people->hasFocus()){ emit transmit_data(ui->lineEdit_people->text()); }else if (ui->lineEdit_serial->hasFocus()){ emit transmit_data(ui->lineEdit_serial->text()); } on_b_return_clicked(); }
void patternDraw(struct lightSet *lights) { lights->len = pattern[lights->p][0]; // Actions switch(lights->state2) { case INIT: transmit_data(0, lights->line); break; case WAIT: transmit_data(0, lights->line); break; case PLAY: transmit_data(pattern[lights->p][lights->i+1], lights->line); lights->i = (lights->i + 1) % lights->len; break; default: break; } // Transitions switch(lights->state2) { case INIT: lights->state2 = WAIT; break; case WAIT: if(lights->run) { lights->state2 = PLAY; } break; case PLAY: if(!lights->run) { lights->state2 = DIE; } break; case DIE: lights->state2 = INIT; break; default: lights->state2 = INIT; break; } }
int send_to_styr(unsigned char header,unsigned char data) { PORTB &= ~(1<<PB4); //Låg SS till styrenhet header=transmit_data(header); //Byt header while(!(GIFR & (1<<INTF1))) //vänta på att andra //enheten läst data { ; } GIFR = GIFR & 0x80; data=transmit_data(data); //Byt data PORTB |= (1<<PB4); tolka_och_skicka(header,data); return 0; }
/** * Got acknowledgement of a transmitted message part, continue transmission. * * @param tmit Transmission handle. */ void GNUNET_PSYC_transmit_got_ack (struct GNUNET_PSYC_TransmitHandle *tmit) { if (0 == tmit->acks_pending) { LOG (GNUNET_ERROR_TYPE_WARNING, "Ignoring extraneous message ACK\n"); GNUNET_break (0); return; } tmit->acks_pending--; switch (tmit->state) { case GNUNET_PSYC_MESSAGE_STATE_MODIFIER: case GNUNET_PSYC_MESSAGE_STATE_MOD_CONT: transmit_mod (tmit); break; case GNUNET_PSYC_MESSAGE_STATE_DATA: transmit_data (tmit); break; case GNUNET_PSYC_MESSAGE_STATE_END: case GNUNET_PSYC_MESSAGE_STATE_CANCEL: break; default: LOG (GNUNET_ERROR_TYPE_DEBUG, "Ignoring message ACK in state %u.\n", tmit->state); } }
int send_to_sensor(unsigned char header,unsigned char data) { PORTB &= ~(1<<PB3); //Låg SS till sensorenhet header=transmit_data(header); //Byt header while(!(GIFR & (1<<INTF2))) //vänta på att andra enheten //läst data { ; } GIFR = GIFR & 0x20; data=transmit_data(data); //Byt data PORTB |= (1<<PB3); //Hög SS till sensorenhet tolka_och_skicka(header,data); //Skicka data vidare return 0; }
int main(void) { DDRA = 0x00; PORTA=0xFF; DDRC = 0xFF; transmit_data(0x00, 0); transmit_data(0xFF, 1); task1_state = INIT; task2_state = INIT; xTaskCreate(Task1, (signed portCHAR *)"Task1", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); xTaskCreate(Task2, (signed portCHAR *)"Task2", configMINIMAL_STACK_SIZE, NULL, 1, NULL ); vTaskStartScheduler(); return 0; }
/** * Resume transmission. * * @param tmit Transmission handle. */ void GNUNET_PSYC_transmit_resume (struct GNUNET_PSYC_TransmitHandle *tmit) { if (GNUNET_YES != tmit->in_transmit || GNUNET_NO != tmit->in_notify) return; if (0 == tmit->acks_pending) { tmit->paused = GNUNET_NO; transmit_data (tmit); } }
void main (void) { unsigned char i; unsigned char TX_Data [RF_PAYLOAD]; unsigned char RX_Data [RF_PAYLOAD]; int count = 0; Setup(); if (PORTAbits.RA3) { while(1) { if (SPI_IRQ == 0) // wait for anything { LED_ON read_RX(RX_Data); Usart_Send ( RX_Data ); // envia pela serial o recebido Delay1KTCYx(10); LED_OFF count++; } } } else { for (i=0; i< RF_PAYLOAD; i++) TX_Data[i] = i+ 0x30; while(1) { LED_ON transmit_data(TX_Data); Delay10KTCYx(255); LED_OFF Delay10KTCYx(255); nop(); } } }//
void writeScore(unsigned char givenNum){ unsigned char data = 0x00; switch(givenNum){ case 0: data = 0x7E; break; case 1: data = 0x48; break; case 2: data = 0x3D; break; case 3: data = 0x6D; break; case 4: data = 0x4B; break; case 5: data = 0x67; break; case 6: data = 0x77; break; case 7: data = 0x4C; break; case 8: data = 0x7F; break; case 9: data = 0x4F; break; default: data = 0x00; break; } transmit_data((~data)); }
void main(void) { // Have to init the clock first init_clock(); // These initialize variables // Mostly just zeroing them okay_to_transmit = FALSE; server_wants_header = FALSE; inside_non_blocking_interrupt = FALSE; last_connect_time = 0; check_in_period = 0; setup_button_pressed = FALSE; setup_button_time_trigger = 0; setup_button_time_duration = 0; main_mode = MAIN_MODE_INIT; init_internal_wattage_sensor(); init_temperature_sensor(); init_audio_sensor(); init_light_sensor(); uint8_t itor = 0; for (itor = 0; itor < NUMBER_OF_AUX_PORTS; itor++) { aux_sensor[itor] = 0; } // These initialize functions and interrupts init_timer(); init_time(); init_leds(); init_relay(); init_uart(); init_transmits(); init_buttons(); init_roving(&roving_call_back); setup_button_time_trigger = new_time(); setup_button_time_duration = new_time(); time_set_seconds(setup_button_time_duration, 2); _enable_interrupts(); // confirm roving works while (!enter_command_mode()) { reset_roving(); wait(500); } init_adc(); init_pll(); // This is for the check in // If we are disconnected, we wait 5 seconds before trying to reconnect last_connect_time = new_time(); check_in_period = new_time(); time_set_seconds(check_in_period, 5); // And go!!! set_led_anim(led_start); // MAIN LOOP while(1) { handle_roving_input(); // Check if it a long hold if(setup_button_pressed) { // If the button is pressed down if(time_cmp(global_time(), setup_button_time_trigger) >= 0) { // If enough time has passed if(in_setup_mode()) { leave_setup_mode(); } else { start_setup_mode(); } // Only want to check this once setup_button_pressed = FALSE; } } // MAIN BEHAVIOR // There is setup_mode and main_mode. // Setup mode is for configuring WiFi SSID and PASS // Main mode is for sampling if (in_setup_mode()) { if(main_mode != MAIN_MODE_SETUP) { stop_sampling(); set_led_anim(led_setup_start); main_mode = MAIN_MODE_SETUP; } do_setup(); } else if (in_main_mode()) { //regular mode if(main_mode != MAIN_MODE_SAMPLE) { set_led_anim(led_main_start); start_sampling(); main_mode = MAIN_MODE_SAMPLE; } if(!is_associated()) { associate(); } else if (!have_dhcp()) { get_dhcp(); } else { if(is_connected()) set_led_anim(led_main_connected); else set_led_anim(led_main_assoc); if(!is_connected() && (time_cmp(global_time(), last_connect_time) >= 0) ) { // If we are not connected, and enough time has passed, connect connect(); add_time_to_time(last_connect_time, check_in_period); } if(server_wants_header) { led_ping(); exit_command_mode(); transmit_header(); wait(100); } if(okay_to_transmit && have_data_to_transmit()) { led_ping(); exit_command_mode(); transmit_data(); } } } else { main_mode = MAIN_MODE_INIT; set_led_anim(led_error); stop_sampling(); } } }
/** * Request a modifier from a client to transmit. * * @param tmit Transmission handle. */ static void transmit_mod (struct GNUNET_PSYC_TransmitHandle *tmit) { uint16_t max_data_size = 0; uint16_t data_size = 0; char data[GNUNET_MULTICAST_FRAGMENT_MAX_PAYLOAD] = ""; struct GNUNET_MessageHeader *msg = (struct GNUNET_MessageHeader *) data; int notify_ret = GNUNET_YES; switch (tmit->state) { case GNUNET_PSYC_MESSAGE_STATE_MODIFIER: { struct GNUNET_PSYC_MessageModifier *mod = (struct GNUNET_PSYC_MessageModifier *) msg; msg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MODIFIER); msg->size = sizeof (struct GNUNET_PSYC_MessageModifier); if (NULL != tmit->notify_mod) { max_data_size = GNUNET_PSYC_MODIFIER_MAX_PAYLOAD; data_size = max_data_size; tmit->in_notify = GNUNET_YES; notify_ret = tmit->notify_mod (tmit->notify_mod_cls, &data_size, &mod[1], &mod->oper, &mod->value_size); tmit->in_notify = GNUNET_NO; } mod->name_size = strnlen ((char *) &mod[1], data_size) + 1; LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_mod (ret: %d, size: %u + %u): %.*s\n", notify_ret, mod->name_size, mod->value_size, data_size, &mod[1]); if (mod->name_size < data_size) { tmit->mod_value_remaining = mod->value_size - (data_size - mod->name_size); mod->value_size = htonl (mod->value_size); mod->name_size = htons (mod->name_size); } else if (0 < data_size) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Got invalid modifier name.\n"); notify_ret = GNUNET_SYSERR; } break; } case GNUNET_PSYC_MESSAGE_STATE_MOD_CONT: { msg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_MOD_CONT); msg->size = sizeof (struct GNUNET_MessageHeader); if (NULL != tmit->notify_mod) { max_data_size = GNUNET_PSYC_MOD_CONT_MAX_PAYLOAD; data_size = max_data_size; tmit->in_notify = GNUNET_YES; notify_ret = tmit->notify_mod (tmit->notify_mod_cls, &data_size, &msg[1], NULL, NULL); tmit->in_notify = GNUNET_NO; } tmit->mod_value_remaining -= data_size; LOG (GNUNET_ERROR_TYPE_DEBUG, "transmit_mod (ret: %d, size: %u): %.*s\n", notify_ret, data_size, data_size, &msg[1]); break; } default: GNUNET_assert (0); } switch (notify_ret) { case GNUNET_NO: if (0 == data_size) { /* Transmission paused, nothing to send. */ tmit->paused = GNUNET_YES; return; } tmit->state = (0 == tmit->mod_value_remaining) ? GNUNET_PSYC_MESSAGE_STATE_MODIFIER : GNUNET_PSYC_MESSAGE_STATE_MOD_CONT; break; case GNUNET_YES: /* End of modifiers. */ GNUNET_assert (0 == tmit->mod_value_remaining); break; default: LOG (GNUNET_ERROR_TYPE_ERROR, "TransmitNotifyModifier callback returned with error.\n"); tmit->state = GNUNET_PSYC_MESSAGE_STATE_CANCEL; msg->type = htons (GNUNET_MESSAGE_TYPE_PSYC_MESSAGE_CANCEL); msg->size = htons (sizeof (*msg)); transmit_queue_insert (tmit, msg, GNUNET_YES); tmit->in_transmit = GNUNET_NO; return; } if (0 < data_size) { GNUNET_assert (data_size <= max_data_size); msg->size = htons (msg->size + data_size); transmit_queue_insert (tmit, msg, GNUNET_NO); } if (GNUNET_YES == notify_ret) { tmit->state = GNUNET_PSYC_MESSAGE_STATE_DATA; if (0 == tmit->acks_pending) transmit_data (tmit); } else { transmit_mod (tmit); } }
void main(void) { init_system(); volatile enum states state; state = IDLE; volatile enum button_states button_state; button_state = NO_PUSH; __enable_interrupt(); while(1) { /* Check push button */ if (button_flag == 1) { button_flag = 0; // Check push button unsigned int push_cnt = 0; button_state = NO_PUSH; __delay_cycles(200000); // Wait 25 msec to debounce __delay_cycles(200000); // Wait 25 msec to debounce while (!(P4IN & BIT0)) { // Button pushed __delay_cycles(8000); // Wait 1 msec push_cnt++; if (push_cnt > TIME_SHORT_PUSH) { // Push button was pushed a short time button_state = SHORT_PUSH; LED1_on(); } if (push_cnt > TIME_LONG_PUSH) { // Push button was pushed a long time button_state = LONG_PUSH; LED2_on(); } } LED1_off(); LED2_off(); __delay_cycles(400000); // Wait 50 msec to debounce __delay_cycles(400000); // Wait 50 msec to debounce } /* Check states */ switch (state) { case IDLE: // toggle_led(LED1_PIN, TIME_3SEC); switch (button_state) { case LONG_PUSH: state = TRANSMIT; wdt_disable(); LED1_off(); toggle_led(LED2_PIN, TIME_05SEC); transmit_data(); break; case SHORT_PUSH: state = RECORD; wdt_disable(); LED2_off(); toggle_led(LED1_PIN, TIME_1SEC); record_data(); break; default: break; } break; case RECORD: switch (button_state) { case LONG_PUSH: // Delete data delete_data(); state = IDLE; break; case SHORT_PUSH: // Stop recording // Recording stop from inside recorde() state = IDLE; break; default: break; } // state = IDLE; break; case TRANSMIT: switch (button_state) { case LONG_PUSH: break; case SHORT_PUSH: break; default: break; } state = IDLE; break; default: break; } //button_state = NO_PUSH; PAIE |= BIT0; // Enable interrupt for push button if (state == IDLE) { toggle_led(LED1_PIN, TIME_3SEC); wdt_enable(); // Activate auto-deep-sleep-watchdog LPM3; _nop(); } } }
/*ARGSUSED*/ void main( int argc, char **argv) { errdesc = 1; debug = 0; if ( argc == 2 ) { conf_file = *(argv+1); } /* if */ /* * setup network connections */ setup_connections(); if ( batch ) { /* * check authentication */ authenticate_client(); read_config_info (); } else { strcpy ( uniq_str, "kxct-compatible" ); } /* if */ for (;;) { /* * read argument list for command */ read_arglist(); /* * check configuration */ check_config(); if ( start_batch ) { start_batch = 0; continue; } /* if */ if ( end_batch ) { break; } /* if */ /* * receive data file */ if (tempslot != 0) receive_data(); /* * execute command */ run_command(); /* * transmit data file */ if (tempslot != 0) transmit_data(); /* * transmit the exit status */ transmit_status(); if ( ! batch ) { break; } /* if */ } /* * that is all */ if ( made_temp_dir ) (void) rmdir(tempdir); /* if */ exit(0); }
void Terminal::create_transmit_button() { txButton = new QPushButton("Transmit", this); connect(txButton, SIGNAL(clicked()), this, SLOT(transmit_data())); txButton->setEnabled(false); }
void Terminal::create_transmit_editor() { txEditor = new QLineEdit(this); connect(txEditor, SIGNAL(returnPressed()), this, SLOT(transmit_data())); }
//------------------------------------------------------------------------------ void main(void) { unsigned int16 i; unsigned char tmpbcd; init_prog(); delay_ms (100); DS3231_init(); lcd_init (); //clear_usart_receiver(); EXT_INT_EDGE(2,L_TO_H); disable_interrupts(INT_EXT2); enable_interrupts(INT_TIMER0); enable_interrupts(INT_RDA); IOpin.buzzer=1; for(i=0;i<16;i++) RFIDmsg[i]=' '; lcd_gotoxy(4,1); printf(lcd_putc,"ELFATEK"); for(i=0;i<100;i++) { IOpin.buzzer=0; delay_us(500); IOpin.buzzer=1; delay_us(500); } //printf(lcd_putc,"ALGIFarm"); delay_ms(1000); lcd_putc('\f'); //lcd_gotoxy(1,1); //printf(lcd_putc,"ID:"); //setTime( hr,min,s,am_pm,hr_format); //setDate(dy, dt, mt, yr); txmode=1; get_date_time(); show_parameters(); set_CHID(); init_nrf24(); enable_interrupts(GLOBAL); for(;;) { //lcd_backlight=ON; if(msgrdy) { lcd_backlight=ON; IOpin.errorLED=1; set_CHID(); init_nrf24(); for(i=0;i<100;i++) { IOpin.buzzer=0; delay_us(500); IOpin.buzzer=1; delay_us(500); } lcd_putc('\f'); lcd_gotoxy(1,1); printf(lcd_putc,"ID:"); for(i=0;i<16;i++) { lcd_gotoxy(1+i,2); printf(lcd_putc,"%c",RFIDmsg[i]); } IOpin.errorLED=0; delay_ms(1000); lcd_gotoxy(1,2); lcd_putc('\f'); get_date_time(); for(i=0;i<10;i++) RFIDmsg_[i]=RFIDmsg[i]-48; TXBuffer[0]=0; TXBuffer[1]=hr; TXBuffer[2]=min; TXBuffer[3]=dt; TXBuffer[4]=mt; TXBuffer[5]=yr; TXBuffer[6]=RFIDmsg_[0];// country code TXBuffer[7]=RFIDmsg_[1];// country code TXBuffer[8]=RFIDmsg_[2];// country code TXBUffer[9]=RFIDmsg_[4]; TXBuffer[10]=RFIDmsg_[5]; TXBuffer[11]=RFIDmsg_[6]; TXBuffer[12]=RFIDmsg_[7]; TXBuffer[13]=RFIDmsg_[8]; TXBuffer[15]=RFIDmsg_[9]; lcd_putc('\f'); lcd_gotoxy(1,2); printf(lcd_putc,"%d",RFIDmsg_[9]); /* for(i=0;i<10;i++) { lcd_gotoxy(1+i,2); if(i!=3) printf(lcd_putc,"%d",RFIDmsg_[i]); else printf(lcd_putc,"%c",RFIDmsg[i]); }*/ delay_ms(2000); /* tmpbcd=(RFIDmsg[4]<<4)||RFIDmsg[5]; TXBuffer[9]=tmpbcd;//ID tmpbcd=(RFIDmsg[6]<<4)||RFIDmsg[7]; TXBuffer[10]=tmpbcd; tmpbcd=(RFIDmsg[8]<<4)||RFIDmsg[9]; TXBuffer[11]=tmpbcd; tmpbcd=(RFIDmsg[10]<<4)||RFIDmsg[11]; TXBuffer[12]=tmpbcd; tmpbcd=(RFIDmsg[12]<<4)||RFIDmsg[13]; TXBuffer[13]=tmpbcd; tmpbcd=(RFIDmsg[14]<<4)||RFIDmsg[15]; TXBuffer[14]=tmpbcd; */ transmit_data(); msgrdy=0; } get_date_time(); if(s!=sec) { show_parameters(); delay_ms(2000); } lcd_backlight=OFF; /* for(i=0;i<PAYLOADSIZE;i++) TXBuffer[i]=i; transmit_data(); */ } }