20 FILE *sysFs = fopen(
"/sys/class/thermal/thermal_zone0/temp",
"r");
22 skn_logger(
SD_WARNING,
"Warning: Failed to OPEN CPU temperature: %d:%s\n", errno, strerror(errno));
26 rc = fscanf(sysFs,
"%ld", &lRaw);
29 if (rc != 1 || lRaw < 0) {
30 skn_logger(
SD_WARNING,
"Warning: Failed to READ CPU temperature: %d:%s\n", strerror(errno));
35 snprintf(temps->
c,
sizeof(temps->
c),
"%3.1f%cC", (
double )(lRaw / 1000.0), 223);
36 snprintf(temps->
f,
sizeof(temps->
f),
"%3.1f%cF", (
double )(lRaw / 1000.0 * 9 / 5 + 32), 223);
38 strncpy(temps->
cbName,
"CpuTemps",
sizeof(temps->
cbName) - 1);
53 memset(&cpuTemp, 0,
sizeof(
CpuTemps));
55 mLen = snprintf(msg,
SZ_INFO_BUFF-1,
"%s %s", cpuTemp.
c, cpuTemp.
f);
64 int main(
int argc,
char *argv[])
72 long host_update_cycle = 0;
74 memset(registry, 0,
sizeof(registry));
75 memset(request, 0,
sizeof(request));
76 strncpy(registry,
"DisplayClient: Raspberry Pi where are you?",
sizeof(registry) - 1);
80 "Send messages to the 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);
109 skn_logger(
SD_NOTICE,
"Application Active...");
115 char *service_name =
"lcd_display_service";
124 skn_logger(
" ",
"\nLCD DisplayService (%s) is located at IPv4: %s:%d\n", pre->
name, pre->
ip, pre->
port);
141 if (request[0] == 0) {
149 if ((vIndex == EXIT_FAILURE) && (
gd_i_update == 0)) {
154 switch (host_update_cycle++) {
166 host_update_cycle = 0;
174 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
long getCpuTemps(PCpuTemps temps)
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 generate_uname_info(char *msg)
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)
char cbName[SZ_CHAR_LABEL]
int skn_udp_service_request(PServiceRequest psr)
int skn_udp_host_create_broadcast_socket(int port, double rcvTimeout)
int generate_datetime_info(char *msg)
int generate_loadavg_info(char *msg)
void skn_program_name_and_description_set(const char *name, const char *desc)
int generate_cpu_temps_info(char *msg)
PRegistryEntry service_registry_find_entry(PServiceRegistry psreg, char *serviceName)
int main(int argc, char *argv[])