#include #include #include #include #include "bus.h" #ifdef __linux__ #define PIN_DATA 2 #define PIN_CLK 3 #define PIN_ACK 4 int data[3]={0}; #include "io.h" int main() { bus_t bus; pthread_t thread; FILE* file = NULL; struct timeval tv; setup_io(); bus_init_recv(&bus, PIN_DATA, PIN_CLK, PIN_ACK); init_read_pin(PIN_DATA, PIN_CLK, PIN_ACK); pthread_create(&thread, NULL, bus_recv_thread, &bus); while(1) { uint32_t c; double w; char buffer[16]; bus_read(&bus, &c, 4); gettimeofday(&tv, NULL); printf("%ld' s %ld ms %'d us \n", c/1000000, c%1000000/1000, c%1000); w=3600.0/(((double)c)/1000000.0); printf("%ld : %.2lf W %.2lf\n\n", tv.tv_sec, w, w/220); } } #endif