| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- //Include Header-----------------------------------------------------
- #include"prog.h"
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //Main-Program
- int main(int argc, const char * argv[]){
- delay(1000); //delete me!!
- //initializing USART at USB_PORT-------------------------------------
- int USB = open("/dev/ttyACM3", O_RDWR|O_NOCTTY);
- if(isatty(USB)==0){
- printf("ERROR: No File Descriptor! \n");
- return 0;
- }
- struct termios * termios_ptr = (struct termios *)
- malloc(sizeof(struct termios));
- if(termios_ptr==NULL){
- printf("ERROR: Termios not available! \n");
- return 0;
- }
- (*termios_ptr).c_iflag = IGNPAR; //ignore Parity-Err
- (*termios_ptr).c_oflag = 0;
- (*termios_ptr).c_cflag = CS8|CREAD; //set Size, enable RX
- (*termios_ptr).c_lflag = 0;
- // (*termios_ptr).c_cc[VMIN] = 2; //set min Characters
- // (*termios_ptr).c_cc[VTIME] = 0.1; //Timeout after 10ms
- cfsetspeed(termios_ptr, B19200); //set Baudrate 19.2k
- tcsetattr(USB, TCSANOW ,termios_ptr);
- //Get Command--------------------------------------------------------
- cmd_t * cmd_ptr = cmd_build(page_read, 0xFF);
- char * frame_ptr = &((*cmd_ptr).mode);
- for(int i=0; i<3; i++, frame_ptr++){
- write(USB, frame_ptr, sizeof(char));
- tcflush(USB, TCIFLUSH);
- }
- // frame_ptr = &frame[0];
- // read(USB, frame_ptr, sizeof(frame));
- // tcflush(USB, TCOFLUSH);
- close(USB);
- return EXIT_SUCCESS;
- }
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|