Click here to Skip to main content
15,895,011 members

Comments by boonC (Top 4 by date)

boonC 17-Mar-20 3:34am View    
even you say google, google cannot help so much. google cannot give you any related solution. if the google have solution, i won't had write a forum get some advise or help from others.
boonC 13-Mar-20 3:59am View    
Deleted
i tried to add gtk_label_set_text and g_timeout_add_second(). but i still stuck that my reading does not able update by itself, you need to reopen it to get it new value. this is my current code that i made. could you help me to corrected it if i had put something wrong.

#include <wiringpi.h>
#include <sys types.h="">
#include <sys stat.h="">
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <gtk gtk.h="">
#include <string.h>
#include <glib.h>


#define BUFSIZE 128

// typedef unsigned char uchar;
// typedef unsigned int uint;


float tempRead(void)
{
float temp;
int i, j;
int fd;
int ret;

char buf[BUFSIZE];
char tempBuf[5];

fd = open("/sys/bus/w1/devices/28-0314979400b5/w1_slave", O_RDONLY);

if(-1 == fd){
perror("open device file error");
return 1;
}

while(1){
ret = read(fd, buf, BUFSIZE);
if(0 == ret){
break;
}
if(-1 == ret){
if(errno == EINTR){
continue;
}
perror("read()");
close(fd);
return 1;
}
}

for(i=0;i
boonC 11-Mar-20 7:00am View    
may i ask if printf show variable reading value, is it possible to transfer the printf reading to inside gtk, how i compile the code using c-language?
boonC 11-Mar-20 6:22am View    
i mean is the sensor is already connect to raspberry pi, when i open the created gtk, it will show the temperature value and its value will automatically update per second according the sensor detect.