Issue with reading sensors in C++ JUCE project


#1

Hi,

I was trying to implement the Sensel Morph API in a C++ project using JUCE. I started by trying to implement the SenselForces example but using a JUCE thread instead of pthread. My main loop looks as follows:

while (!enter_pressed)
{
    unsigned int num_frames = 0;
    //Read all available data from the Sensel device
    senselReadSensor(handle);
    //Get number of frames available in the data read from the sensor
    senselGetNumAvailableFrames(handle, &num_frames);
    for (int f = 0; f < num_frames; f++)
    {
        senselGetFrame(handle, frame);
        
        if(frame->content_bit_mask & FRAME_CONTENT_PRESSURE_MASK || frame->content_bit_mask & FRAME_CONTENT_LABELS_MASK) {
            //Read one frame of data
            //Calculate the total force
            total_force = 0;
            for (int i = 0; i < sensor_info.num_cols*sensor_info.num_rows; i++)
            {
                total_force = total_force + frame->force_array[i];
            }
        }
        fprintf(stdout, "Total Force : %f\n", total_force);
    }
}
} 

The problem I am having is that only 0 values are printing into the terminal. Eventually I get the error:

" Failed to receive ack from sensor

Error reading frame data.

[fd:11] select() timedout with no data, ret=0

Any idea as to what could be the issue here?