示例#1
0
void ext_control_set_ptt_active(void) {
  event_add_message((void *)ext_control_set_txrx_relay_on, INTERVAL_PRE_TIME_TXRX, SEQUENCER_EVENT_TXRX_RELAY_ON);
  event_add_message((void *)ext_control_set_grid_relay_on, INTERVAL_PRE_TIME_GRID, SEQUENCER_EVENT_GRID_RELAY_ON);
  
  //Activate the PTT LED
  PORTE |= (1<<6);
  
  //Set the PTT status
  curr_state |= (1<<EXT_CONTROL_PTT_STATUS);
}
示例#2
0
void ext_control_set_ptt_deactive(void) {
  if (event_queue_drop_id(SEQUENCER_EVENT_TXRX_RELAY_ON) == 0) {
    event_add_message((void *)ext_control_set_txrx_relay_off, INTERVAL_POST_TIME_TXRX, SEQUENCER_EVENT_TXRX_RELAY_OFF);
  }
  
  if (event_queue_drop_id(SEQUENCER_EVENT_GRID_RELAY_ON) == 0) {
    event_add_message((void *)ext_control_set_grid_relay_off, INTERVAL_POST_TIME_GRID, SEQUENCER_EVENT_GRID_RELAY_OFF);
  }

  //Deactivate the PTT LED
  PORTE &= ~(1<<6);
  
  //UNSet the PTT status
  curr_state &= ~(1<<EXT_CONTROL_PTT_STATUS);
}
示例#3
0
/*! \brief Function which will parse the internal communication message 
 *  \param message The message that we wish to parse */
void event_internal_comm_parse_message(UC_MESSAGE message) {
	#ifdef INT_COMM_DEBUG
		printf("0x%02X\n",message.cmd);
	#endif
	
	//Init the sequence of saving all data and disable all outputs activated by this unit
	switch(message.cmd) {
		case UC_COMM_MSG_ACK:
			internal_comm_message_acked();
			break;
		case UC_COMM_MSG_NACK:
			internal_comm_message_nacked();
			break;
		case INT_COMM_TURN_DEVICE_OFF:
			event_add_message((void *)shutdown_device,3000,0);
			break;
		case INT_COMM_GET_BAND_BCD_STATUS:
			
      break;
    case INT_COMM_PC_CONNECT_TO_ADDR:
      ascii_comm_device_addr = message.data[0];
      break;
    case INT_COMM_PC_SEND_TO_ADDR:
      if (ascii_comm_device_addr != 0x00) {
        bus_add_tx_message(bus_get_address(), ascii_comm_device_addr,(1<<BUS_MESSAGE_FLAGS_NEED_ACK),BUS_CMD_ASCII_DATA,message.length,message.data);
      }
      break;
		default:
			break;
	}
}
示例#4
0
文件: ui.c 项目: abulmo/edax-reversi
/**
 * @brief Get an event
 *
 * Wait for an event from the standard input.
 *
 * @param ui User Interface.
 */
static void ui_read_input(UI *ui)
{
	char *buffer;
	char cmd[8];
	Event *event = ui->event;
	Play *play = ui->play;

	buffer = string_read_line(stdin);

	if (buffer == NULL) {
		if (ferror(stdin)) {
			if (errno == EINTR) clearerr(stdin);
			else fatal_error("stdin is broken\n");
		} else if (feof(stdin)) {
			buffer = string_duplicate("eof");
		}
		event->loop = false;
	} else {
		if (ui->type == UI_GTP) gtp_preprocess(buffer);
		parse_word(buffer, cmd, 5);
		string_to_lowercase(cmd);
		if (strcmp(cmd, "stop") == 0) {
			event_clear_messages(event);
			info("<stop>\n");
			play_stop(play);
			if (ui->type == UI_GGS) play_stop(play + 1);
		} else if (ui->type == UI_NBOARD && strcmp(cmd, "ping") == 0) {
			play_stop(play);
		} else if (ui->type == UI_XBOARD && strcmp(cmd, "?") == 0) {
			play_stop(play);
		} else {
			if (strcmp(cmd, "quit") == 0 || strcmp(cmd, "q") == 0) {
				event_clear_messages(event);
				play_stop(play);
				if (ui->type == UI_GGS) play_stop(play + 1);
				event->loop = false;
			}
		}
	}
	if (buffer) {
		lock(event);
			event_add_message(event, buffer);
			condition_signal(event);
		unlock(event);
	}
}