Forum Discussion
Altera_Forum
Honored Contributor
16 years agoThanks for the help I had a friend look at it as well and we came up with a working code for those that would need help from these posts, the code came out as below which is a function that I called in my main program to give back the weight;
voidget_weight_from_uart(char * weight) { FILE* fp; char in_char = 0; int pointer = 0; fp = fopen ("/dev/RS232", "r+"); //Open file for reading and writing if (fp ==0) { printf("error"); } if (fp) { while (1) { in_char = fgetc(fp); // Get a character from the UART. if ((in_char == '\n') | (in_char == '^') | (in_char == 0)) { weight[pointer] = 0; fclose (fp); return; } else { weight[pointer++] = in_char; // weight[pointer] = 0; // printf(weight); // delay(1000); } } fclose (fp); } // return 0; } Thanks for the help.