示例#1
0
int main(int argc, char *argv[]){
	char* serial_port_name;
	if (argc ==1){
		serial_port_name = SERIALPORTDEFAULT;
	}else if (argc == 2){ // if a command line argument was supplied
		serial_port_name = argv[1]; // the argument is the name of the serial port to open
	}else if(argc > 2){
		printf("Usage is: monitor [serial port name]\n");
	}
	PRINTDEBUG&&printf("main called..\n");
	mysetup_serial_port(serial_port_name);
	PRINTDEBUG&&printf("done setup...\n");
	configureUI();
	
	// setup the log file
	if (LOG)
		logfile = open("log",O_WRONLY|O_APPEND|O_CREAT,0666);// the 0666 is an octal number which sets up proper permissions so we can actually open the log file after writing to it

	//blank out the buffers
	clear_user_command_buffer();
	clear_serial_command_buffer();
	while(1){
		read_from_serial_port(); // read in and buffer stuff in from the serial port
		buffer_input();		 // buffer user input
		refresh();		 // refresh the display
	}
	return quit();
}
示例#2
0
int main(){
	PRINTDEBUG&&printf("main called..\n");
	mysetup_serial_port();
	PRINTDEBUG&&printf("done setup...\n");
	configureUI();
	char buf[21];
	buf[20] = '\0';
	while(1){
		move(0,0);
		printw("DATA: ");
		char i = read(serialport,buf,20);	
		if (i == -1){
			// No data read.
		}else{
			buf[i] = '\0';
		}
		printw("%s",buf);
		run_in_loop();
	}
	return quit();
}