UPDATE:
this is how i take data from .tct file and add up into the myCommand array:Code:
int myCommand[8] = { 245,1,0,0,0,0,0,0 };
int str1, str2, str3, str4;
note: the .txt file has this value ==> "0 0 1 245"Code:fp = fopen ("file.txt", "r");
rewind(fp);
fscanf(fp, "%d %d %d %d", &str1, &str2, &str3, &str4);
printf("%d",str1);
myCommand[4] = str1;
myCommand[5] = str2;
myCommand[6] = str3;
myCommand[7] = str4;
i was supposed to send 8 byte of data which is "245,1,0,0,0,0,1,245" but i get error:
error ==> error in write, result = 32Code:result2 = write(mainfd, myCommand, sizeof(myCommand)); //return number of byte written to the port
if ( result2 == -1 ) { perror("error: write"); }
if ( result2 != 8 ) { fprintf(stderr,"error in write, result = %d\n", result2); }