Home > Back-end >  Under Windows serial port as a file to operation, fread () to read less than content
Under Windows serial port as a file to operation, fread () to read less than content

Time:11-28

Using the serial debugging assistants open com2 port, send data to the com1, use fread () function to read data
In the buff in [], but the buff in [] without the data, how be to return a responsibility??????? Pray god help!


Void recDataVer2 ()
{

The FILE * fp.
//the staging data read
Unsigned char buff [8]={0};

Int CNT=0;
Time_t current_time, start_time;

//open the serial port
If ((fp=fopen (" com1 ", "r"))==NULL)
{
Puts (" ReadDev donnot work! \n");
}
The else
{
Puts (" ReadDev way work! \n");
While (1)
{
//read data
CNT=fread (buff, 1, 8, fp);

If (CNT)
{
//print out the data
Printf (" data: \ t \ n ", buff2);
}

Time (& amp; Start_time);
Do
{
Time (& amp; Current_time);
}
While ((current_time - start_time) & lt; 1);

}

}
}

CodePudding user response:

Should be in the read

CodePudding user response:

Printf (" data: \ t \ n ", buff2);
You see that you write is what?
  • Related