Can anyone plz check this one and report me back?. Coz all I'm doing now is reading the files from /sys/class/hwmon/hwmon1/device/ namely adc0 and adc1 every 1 second and as they return numeric values, I'm just using that to turn speakers on/off. Can someone plz tell what they are actually, coz they are giving random results in different scenarios like I mentioned above and from what I found in the web, it is suppose to give proximity value.
| The Following User Says Thank You to qwerty12 For This Useful Post: | ||
int fd = open("/sys/bus/platform/devices/proximity/state", O_RDONLY, O_NONBLOCK, O_NOCTTY);
GIOChannel *channel = g_io_channel_unix_new(fd);
g_io_add_watch(channel, G_IO_IN | G_IO_PRI, (GIOFunc)readState, NULL);
..........
gboolean readState(GIOChannel *channel, GIOCondition cond, gpointer data){
gchar *state;
gsize size;
GIOStatus ret = g_io_channel_read_line(channel, &state, &size, NULL, NULL);
if (ret != G_IO_STATUS_ERROR){
printf("STATE: %s", state);
if (strcmp(state, "open") == 0){
...........
}
else if (strcmp(state, "closed") == 0){
...........
}
g_free(state);
}else
return FALSE;
return TRUE;
}
int fd = open("/sys/bus/platform/devices/proximity/state", O_RDONLY, O_NONBLOCK, O_NOCTTY);
GIOChannel *channel = g_io_channel_unix_new(fd);
g_io_add_watch(channel, G_IO_IN | G_IO_PRI, (GIOFunc)readState, NULL);
..........
gboolean readState(GIOChannel *channel, GIOCondition cond, gpointer data){
gchar *state;
gsize size;
GIOStatus ret = g_io_channel_read_line(channel, &state, &size, NULL, NULL);
if (ret != G_IO_STATUS_ERROR){
printf("STATE: %s", state);
if (strcmp(state, "open") == 0){
...........
}
else if (strcmp(state, "closed") == 0){
...........
}
g_free(state);
}else
return FALSE;
return TRUE;
}
| The Following User Says Thank You to qwerty12 For This Useful Post: | ||
As, always all info are in that same post.
| The Following User Says Thank You to jaeezzy For This Useful Post: | ||
epends}. Any help would be great however installing the provided deb file in the #1 post goes well. Thanks
epends}. Any help would be great however installing the provided deb file in the #1 post goes well. Thanks