hello,
I'm writing a program to collect the data from a sonar of a robot. the robot is running Fedora 6. I want to collect the data in an external file as there is a lot of information to be reviewed. the program is fine when I direct the sonar data to the monitor with printf. however, when I try to use the 'fputs' I get the following warning message and nothing is deposited in the file.
"passing arg 1 of 'fputs' makes pointer from integer without a cast"
the data that I'm collecting is declared as integer. perhaps there is another function, instead of 'fputs' that I should use to redirect the incoming data. I appreciate any sort of help.
================================================
#include <stdio.h>
#include <stdlib.h>
#include "Nclient.h"
/* turn on the sonar sensors */
void turn_sonar_on(void)
{
int sn_order[16] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15};
/* turn on all sonars (sn_order) and set them to fire in certain order (15*4 miliseconds = 60 miliseconds) */
conf_sn(15, sn_order);
/* configure time out of the robot (in seconds) */
conf_tm(15);
}
/*
* main body of the program designated to collect the sensor data
*/
main(void)
{
/* create a file to deposit the data to */
FILE * pFile;
pFile = fopen ("mylog.txt","a");
/* connect to the robot */
connect_robot(1)
/* alternate connection to the robot */
// connect_robot(1, MODEL_SCOUT2, "/dev/ttyS0", 38400);
/* turn on the sonar sensors */
turn_sonar_on();
/* collect the data from the robot sensors and motion and deposit it in external file via STATE variable */
gs();
while(1)
{
/* deposit sonar data */
short i = 0;
do
{
fputs ("Sonar data:\n",pFile);
fputs (State[STATE_SONAR_0+i],pFile);
fputs ("end of Sonar data:\n",pFile);
i++;
} while (i<16);
}
return(0);
}