10 #define kXADCPATH "/sys/bus/iio/devices/iio:device0/" 17 if((sysfile = fopen(
kXADCPATH "in_temp0_offset",
"ra")) == NULL) {
18 fprintf(stderr,
"ERROR: Can't open offset device file\n");
23 *nOffset = atoi(strRead);
25 if((sysfile = fopen(
kXADCPATH "in_temp0_scale",
"ra")) == NULL) {
26 fprintf(stderr,
"ERROR: Can't open scale device file\n");
31 *fScale = atof(strRead);
39 int sknGetTemp(
double *fTemp,
double *cTemp,
int nOffset,
float fScale) {
44 if(nOffset == 0 || fScale == 0.0)
47 if((sysfile = fopen(
kXADCPATH "in_temp0_raw",
"ra")) == NULL) {
55 *fTemp = (double ) (nRaw + nOffset) * fScale / 1000.0;
57 *cTemp = (double ) (*fTemp - 32.0) * 5 / 9;
63 int main(
int argc,
char *argv[])
74 memset(registry, 0,
sizeof(registry));
75 memset(request, 0,
sizeof(request));
76 strncpy(registry,
"DisplayClient: Raspberry Pi where are you?",
sizeof(registry) - 1);
79 "para_display_client",
80 "Send Epiphany III ( Zynq ) Temperature to Display Service." 92 }
else if (argc == 2) {
93 strcpy(request, argv[1]);
96 skn_logger(
SD_DEBUG,
"Request Message [%s]", request);
97 skn_logger(
SD_DEBUG,
"Registry Message [%s]", registry);
101 skn_logger(
SD_ERR,
"GetConstants() Failed! Shutting Down!");
115 skn_logger(
SD_NOTICE,
"Application Active...");
121 char *service_name =
"lcd_display_service";
130 skn_logger(
" ",
"\nLCD DisplayService (%s) is located at IPv4: %s:%d\n", pre->
name, pre->
ip, pre->
port);
146 if (request[0] == 0) {
156 if ((vIndex == EXIT_FAILURE) && (
gd_i_update == 0)) {
162 snprintf(pnsr->
request,
sizeof(pnsr->
request) -1,
"%.1fF %.1fC", fTemp, cTemp);
169 skn_logger(
SD_WARNING,
"Unable to create Network Request.");
long skn_get_number_of_cpu_cores()
int skn_udp_host_create_regular_socket(int port, double rcvTimeout)
char * gd_pch_service_name
int sknGetConstants(int *nOffset, float *fScale)
int service_registry_entry_count(PServiceRegistry psr)
void signals_cleanup(int sig)
int skn_handle_locator_command_line(int argc, char **argv)
PServiceRegistry service_registry_get_via_udp_broadcast(int i_socket, char *request)
int sknGetTemp(double *fTemp, double *cTemp, int nOffset, float fScale)
sig_atomic_t gi_exit_flag
void service_registry_destroy(PServiceRegistry psreg)
char request[SZ_INFO_BUFF]
PServiceRequest skn_service_request_create(PRegistryEntry pre, int host_socket, char *request)
int skn_udp_service_request(PServiceRequest psr)
int skn_udp_host_create_broadcast_socket(int port, double rcvTimeout)
void skn_program_name_and_description_set(const char *name, const char *desc)
int main(int argc, char *argv[])
PRegistryEntry service_registry_find_entry(PServiceRegistry psreg, char *serviceName)