Commit 68c91288 authored by Joshua Supra's avatar Joshua Supra
Browse files

added eth1 link status to getDate

parent ea7be1d9
......@@ -477,7 +477,7 @@ void PiLC2InitIOCards(void) {
int GetDate(zmq_data *zmq_data_struct) {
unsigned int *buffer;
buffer = (unsigned int *)malloc(6*sizeof(int));
buffer = (unsigned int *)malloc(7*sizeof(int));
time_t rawtime = time(NULL);
......@@ -489,11 +489,26 @@ int GetDate(zmq_data *zmq_data_struct) {
buffer[3] = ptm->tm_hour;
buffer[4] = ptm->tm_min;
buffer[5] = ptm->tm_sec;
buffer[6] = CheckLink();;
//printf("%i \n", buffer[1]);
zmq_send (zmq_data_struct->socket, buffer, 42, 0);
zmq_send (zmq_data_struct->socket, buffer, 46, 0);
free(buffer);
return 0;
}
int CheckLink(void) {
char *ifname ="eth1";
int socId = socket(AF_INET, SOCK_DGRAM, IPPROTO_IP);
struct ifreq if_req;
(void) strncpy(if_req.ifr_name, ifname, sizeof(if_req.ifr_name));
ioctl(socId, SIOCGIFFLAGS, &if_req);
close(socId);
return (if_req.ifr_flags & IFF_UP) && (if_req.ifr_flags & IFF_RUNNING);
}
......@@ -45,7 +45,7 @@ int PiLC2GetIOCards(zmq_data *zmq_data_struct);
int getPiLCinet(zmq_data *zmq_data_struct);
int GetDate(zmq_data *zmq_data_struct);
void PiLC2InitIOCards(void);
int CheckLink(void);
void *context;
void *client_responder;
void *gui_responder;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment