even if i changed to this code
result2 = write(mainfd, myCommand, sizeof(myCommand)); //return number of byte written to the port
if ( result2 < 0 ) { perror("error: write"); }
if...
Type: Posts; User: Marvin Gorres
even if i changed to this code
result2 = write(mainfd, myCommand, sizeof(myCommand)); //return number of byte written to the port
if ( result2 < 0 ) { perror("error: write"); }
if...
Hello Zuk, i changed it already. Thanks for the information, now my error looks like this:
error: write: Success
error in write, result = -45
but i just disable the second error and i get the...
its negative.
Yea you got a point there. Any suggestion how to check the error?
Now i'm trying to transfer 211 byte of data so i have this code below:
unsigned char myCommand[211] = { 245,65,0,196,0,0,133,245,245,0,1,1,245,0,0,0,15,29,40,43,193,34,...
Thanks Kurt!!
UPDATE:
int myCommand[8] = { 245,1,0,0,0,0,0,0 };
int str1, str2, str3, str4;
I wonder if i'm doing this correctly. Please correct me. This is what i did:
fscanf(fp, "%s %s %s %s", str1, str2, str3, str4);
two[1]= str1;
two[2]= str2;
two[3]= str3;
two[4]= str4;
alright thanks for the suggestion. Too many thing now and i keep forgetting things.
its in write() library, the write() will return you the number of byte as long as you set the correct parameter for it.
Owh sorry! i forgot to change the 801 to 8..my mistake. now it works properly already. thanks for pointing it out.
Now what i have to do is how to transfer an array which have the following value...
Tried already, my device seems to respond but the error is still there. 42 byte were sent.
This is what i've done:
unsigned char myCommand[810] = { 0xf5,0x01,0x00,0x01};
unsigned char two[50];
two[1]= "0x03";
two[2]= "0x00";
two[3]= "0x03";
convert? is there any other method without altering the original data?
This is what i did:
unsigned myCommand[100] = { 0xf5, 0x01, 0x00, 0x01, 0x03, 0x00, 0x03, 0xf5,};
result2 = write(mainfd, myCommand, sizeof(myCommand));
now my .txt file content is...
To make a quick understanding, i have one example:
char get[1000] = {"\\xF5\\x01\\x00\\x00"}, get_2[1000] = {"\\x00\\x00\\x01\\xF5"};
strcat(get,get_2);
printf("%s",get); //output...
I can read the file exactly as it is in .txt file n it looks like this:
\xf5\x00\x00\x00\x17\x0a\x16\x01\x61\x0e\x1d\x1a\x 01\x16\x95\x00\xc1\x1f\x26\x44\xa1\x1f\x88\x95\xe1 ...
Yes Jim, i printed out the correct data from the .txt file. The problem is how to combine the hex data in array(temp_final) with the existing hex data in here ==> "result2 =...
Hello Jim, now i have a big problem, hope you'll bear with me to solve this.
1.) i'm sending hex command to my device/port like the code below:
result2 =...
Oh man you're awesome dude..thanks for helping me..^^
So basically i cant have this kind of output? \xf5\x23\xc4\x00\x00\xe7\xf5\xf5\x00\x00\x00\x29?
Hello jim, the problem seems to be solved already. I did the input and output clear buffer and its settled. Now i have another problem, below is my code to print the output from the device into a...
Changed it already but still the output data i get sometimes correct and sometimes not correct. hmm.
The way i clear my buffer, is that a good way?
Thanks for pointing it out Jim. I've updated my code and get the correct result but sometimes it is correct and sometimes its not. comment on my code below:
chout = 0;
fp =...