Commit 86ab93fb authored by Joshua Supra's avatar Joshua Supra
Browse files

added GetPilc2Inet

parent 1b45aa19
......@@ -20,9 +20,13 @@
#include "pilc2_functions/pilc2_IO_mux.h"
int thread_nr;
int main (int argc, char *argv[]){
thread_nr = 0;
unsigned int front_LED_update_ctr = 0;
initContCounterDone = 0;
......
......@@ -333,8 +333,8 @@ void *updateIOLeds(void *vargp) {
led_color.Blue = 8;break;
}
} else if (IOCard[i-1].TypeID == THERMO) {
value_int = getThermovalue(((i-1)/2+16));
if(value_int == NO_THERMO_COUPLE){
value_int = getThermoRawvalue(((i-1)/2+16));
if((value_int & PILC_THERMO_ERR_MASK) != 0){
led_color.Red = 8;
led_color.Green = 8;
led_color.Blue = 0;break;
......@@ -366,8 +366,8 @@ void *updateIOLeds(void *vargp) {
led_color.Blue = 0;break;
}
}
case THERMO: value_int = getThermovalue(((i)/2+16));
if(value_int == NO_THERMO_COUPLE){
case THERMO: value_int = getThermoRawvalue(((i)/2+16));
if((value_int & PILC_THERMO_ERR_MASK) != 0){
led_color.Red = 8;
led_color.Green = 8;
led_color.Blue = 0;break;
......
......@@ -21,7 +21,11 @@
#include "pilc2_cdma.h"
#include "pilc2_continous_counter.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <net/if.h>
#include <arpa/inet.h>
int init_network(void){
......@@ -79,6 +83,7 @@ int FunctionCall(zmq_data *zmq_data_struct){
case GET_NR_OF_DATA :value = GetNrOfData(zmq_data_struct);break;
case GET_DATA:value = PiLC2GetRamData(funcArg[0],funcArg[1],zmq_data_struct->socket);break;
case GET_IO_CARDS:value = PiLC2GetIOCards(zmq_data_struct);break;
case GET_PILC_INET:value = getPiLCinet(zmq_data_struct);break;
}
if(value == 0){
//echo the command
......@@ -354,3 +359,55 @@ int PiLC2GetIOCards(zmq_data *zmq_data_struct) {
free(buffer);
return 1;
}
int getPiLCinet(zmq_data *zmq_data_struct){
//int getPiLCinet(void){
unsigned int *buffer;
int len;
char hostname[50];
gethostname(hostname, sizeof(hostname));
char mac[18];
FILE * file =fopen("/sys/class/net/eth1/address", "r");
fscanf( file, "%s", &mac[0] );
fclose(file);
int fd;
struct ifreq ifr;
char iface[] = "eth1";
char ipaddr[16];
fd = socket(AF_INET, SOCK_DGRAM, 0);
ifr.ifr_addr.sa_family = AF_INET;
//Copy the interface name in the ifreq structure
strncpy(ifr.ifr_name , iface , IFNAMSIZ-1);
ioctl(fd, SIOCGIFADDR, &ifr);
close(fd);
strncpy(ipaddr, inet_ntoa(( (struct sockaddr_in *)&ifr.ifr_addr )->sin_addr) , IFNAMSIZ-1);
strcat(hostname, ";");
strcat(hostname, mac);
strcat(hostname, ";");
strcat(hostname, ipaddr);
printf("%s\n", hostname);
len = strlen(hostname);
printf("%i\n", len);
buffer = (unsigned int *)malloc(len*sizeof(char));
zmq_send (zmq_data_struct->socket, hostname, len, 0);
free(buffer);
return 0;
}
......@@ -4,11 +4,6 @@
#include <stdbool.h>
#define PORT 8080
#define SERV_IP_ADDR "192.168.178.200"
#define REC_BUFFER 100
#define SEND_BUFFER 100
/**Communication Errors**/
#define ERR_OUT_OF_BONDS -1
#define ERR_RANGE_EXCEED -2
......@@ -22,6 +17,7 @@
#define GET_NR_OF_DATA 0x4
#define GET_DATA 0x5
#define GET_IO_CARDS 0x6
#define GET_PILC_INET 0x7
typedef struct {
void *socket;
......@@ -44,6 +40,10 @@ int FunctionCall(zmq_data *zmq_data_struct);
int GetNrOfData(zmq_data *zmq_data_struct);
int PiLC2GetRamData(unsigned int RAMBaseAddress, unsigned int numofdata, void *socket);
int PiLC2GetIOCards(zmq_data *zmq_data_struct);
int getPiLCinet(zmq_data *zmq_data_struct);
//int getPiLCinet(void);
void *context;
void *client_responder;
void *gui_responder;
......
......@@ -23,6 +23,7 @@
#define PILC_THERMO_RAW_OFFSET 0x8
#define NO_THERMO_COUPLE 0x2000
#define PILC_THERMO_ERR_MASK 0x07
unsigned int getThermovalue(unsigned int Thermochannel);
unsigned int getThermoRawvalue(unsigned int Thermochannel);
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