ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
i am very new to C but making my way through.
im using calls to a shared lib for controlling a robotics microcontroller.
a function, defined in the header, like this:
aServo_GetPosition(stem, GPMOD, SRV2, srv1pos);
it gets the position of a servo and puts the value in srv1pos an 'unsigned char'.
the result is a number between 0 and 255.
printf("servo postion = %d\n", srv1pos);
yeilds # servo position = 178
so all i want to do is to put that '178' into a file.
i have defined another function where the file is to be written
and i want to pass 'srv1pos' as a variable to that function.
i've tried using fputc(), fputs() and fwrite() and i just can't get it to work.
but it doesn't work like expected
../stem/servo/dest-0 contains 127
the servo should move to match this number after it is gotten from the file
by fscanf()
but instead it moves to 224
all the values i put into files with aServo_GetPosition() and filewriter() are correct, but the values i get out with fscanf dont work properly
in aServo_SetPositionAbs().
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.