| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- //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));
- (*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--------------------------------------------------------
- char * frame_ptr = cmd_build(page_read, page_size);
- for(int i=0; i<3; i++, frame_ptr++){
- write(USB, frame_ptr, sizeof(char));
- printf("%d \n", *frame_ptr);
- }
- char cmd_check = 0;
- frame_ptr = &cmd_arr[0];
- while(cmd_check < 3){
- read(USB, frame_ptr, sizeof(char));
- printf("Return: %d \n", *frame_ptr);
- if(*frame_ptr == page_size){
- cmd_check++;
- }
- }
- printf("Read Acknoledged \n");
- char * page_ptr = page_build();
- for(int i=0; i<70; i++){
- write(USB, page_ptr, sizeof(char));
- }
- frame_ptr = &cmd_arr[0];
- for(int i=0; i<3; i++, frame_ptr++){
- read(USB, frame_ptr, sizeof(char));
- printf("Return: %d \n", *frame_ptr);
- }
- close(USB);
- return EXIT_SUCCESS;
- }
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|