Question

uint32 InterruptLatency;
uint8 measurements[32];
char buf[256];
int kernelinterrupt time()
{
fscanf(fp,"%lu", InterruptLatency);  // I am reading the data from kernel which is not shown here
measurements[17] = InterrupLatency;
buf = &measurements;            // I am getting error here as below

// after storing it in buffer I am  sending the data from but to another layer
}

ERROR : incompatible type when assigning of type char[256] from type uint8 (*)[32]

could some one help me how to solve this ??

Was it helpful?

Solution

In C you cannot assign arrays. You have to copy the memory explicitly.

Probably you want to do this:

memcpy(buf, measurements, sizeof(measurements));

But you gave no details about what you actually want to do.

PS: Your fscanf() is wrong. It should take the address of the variable that will hold the read value.

And if you use uint32_t you should use the SCNu32 specification, from <inttypes.h>, to be sure that you do not break things:

fscanf(fp,"%"SCNu32, &InterruptLatency);

OTHER TIPS

You are trying to assign a pointer value to an array. You can't do that.

Use memcpy:

memcpy(buf, &measurements, sizeof(measurements));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top