예제 #1
0
파일: main.c 프로젝트: pdNor/Matlab-Arduino
int main (void)
{
	sysclk_init();
	board_init();
	uart_config((uint32_t)UART_BAUDRATE);
	init_adc();
	pwm_setup();
	dac_setup();
	start_coms();					//Run state machine
	
	
}
예제 #2
0
파일: ifc.c 프로젝트: BwRy/fuzzer-android
void ifc_thread(void *data)
{
	log("thread start\n")
	status_wait = 0;
	
	for (;;) {
		if (coms == -1) {
			start_coms();
			continue;
		}
			
		log("%s sleeping... %d\n", __func__, status_wait)
		
		struct pollfd pfd[1];
		pfd[0].fd = coms;
         pfd[0].events = POLLIN|POLLPRI|POLLERR;
		int pfn = poll(pfd, 1, 10000);
		//log("pfn %d\n", pfn)
		
		if (pfd[0].revents & POLLIN == POLLIN || pfd[0].revents & POLLPRI == POLLPRI) {
			char cmdp[4096] = {0};
			int rd = read(coms, cmdp, sizeof(cmdp));
		
			if (rd <= 0) {
				log("coms read error\n")
				close(coms);
				coms = -1;
				continue;
			}
			
			log("coms rd = %d\n", rd);
			int i;
			for (i = 0; i < rd; i++) {
				if (i%16 == 0) log("\n")
				log("%0.2x", cmdp[i]);
			}
			log("\n");
			
			fake_card = malloc(rd);
			memcpy(fake_card, cmdp, rd);
			fake_card_len = rd;
			
			log("fake card state 0->1 (via pty)\n")
			fake_card_state = 1;
			// trigger call to ifc_call_cb from other thread
			wrapper.msg.eMsgType = 0xffffff00;
			ptr_phDal4Nfc_msgsnd = msgsend;
			ptr_phDal4Nfc_msgsnd(global_msqid, (struct msgbuf *)&wrapper, sizeof(phLibNfc_Message_t), 0);
			
		}
		if (pfd[0].revents & POLLERR == POLLERR) {
			log("pollerr\n")
			close(coms);
			coms = -1;
			continue;
		}
		if (pfd[0].revents & POLLHUP == POLLHUP) {
			log("pollhup\n")		
		}
	}
}