void train_process(PROCESS self, PARAM param) { disable_keyboard(); run_train(); enable_keyboard(); remove_ready_queue(self); resign(); }
void train_test() { /* Check contact 2 should return 2 */ disable_keyboard(); Serial_Message msg; char input_buf[4]; char contact_buf[5]; char *buf_ptr = contact_buf; int contact_id = 2; *buf_ptr = 'C'; buf_ptr++; /* Give more space if contact_id is bigger than 1 */ if (contact_id > 9) { k_memcpy(buf_ptr, int_to_string[contact_id], 2); buf_ptr += 2; } else { k_memcpy(buf_ptr, int_to_string[contact_id], 1); buf_ptr += 1; } *(buf_ptr) = '\015'; buf_ptr++; *(buf_ptr) = '\0'; msg.output_buffer = contact_buf; msg.input_buffer = input_buf; msg.len_input_buffer = sizeof(input_buf); clear_buf(); kprintf("Send Message:"); send(serial_port, &msg); cmd_sleep(); int i = 0; kprintf("Got Message:"); for (i = 0; i < sizeof(input_buf); i++) { kprintf("%x ", input_buf[i]); } kprintf("\n"); kprintf("Result = %d, shoulde be 1", input_buf[1] - '0'); enable_keyboard(); }
int termcap_init(void) { char *name_term; manage_signal(); if ((get_stuff()->fd = open(ttyname(0), O_WRONLY | O_NOCTTY)) == -1) return (-1); if ((name_term = getenv("TERM")) == NULL) return (-1); if (tgetent(NULL, name_term) == -1) return (-1); if (tcgetattr(get_stuff()->fd, get_term()) == -1) return (-1); get_term()->c_lflag &= ~(ICANON | ECHO); get_term()->c_cc[VMIN] = 1; get_term()->c_cc[VTIME] = 0; if (tcsetattr(get_stuff()->fd, TCSADRAIN, get_term()) == -1) return (-1); tputs(tgetstr("ti", NULL), 1, ft_putchr); hide_cursor(); enable_keyboard(); get_s_win(); return (0); }