Commit ea7be1d9 authored by Joshua Supra's avatar Joshua Supra
Browse files

added get date function

parent bb749943
......@@ -91,7 +91,6 @@ int main (int argc, char *argv[]){
* TEST Functions
**************************************************************************/
/**************************************************************************
......
......@@ -89,6 +89,7 @@ int FunctionCall(zmq_data *zmq_data_struct){
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;
case GET_DATE:value = GetDate(zmq_data_struct);break;
case INIT_IO_CARDS: PiLC2InitIOCards();break;
}
if(value == 1){
......@@ -472,3 +473,27 @@ void PiLC2InitIOCards(void) {
InitIOCards(IOCards);
}
int GetDate(zmq_data *zmq_data_struct) {
unsigned int *buffer;
buffer = (unsigned int *)malloc(6*sizeof(int));
time_t rawtime = time(NULL);
struct tm *ptm = localtime(&rawtime);
buffer[0] = ptm->tm_year+1900;
buffer[1] = ptm->tm_mon+1;
buffer[2] = ptm->tm_mday;
buffer[3] = ptm->tm_hour;
buffer[4] = ptm->tm_min;
buffer[5] = ptm->tm_sec;
//printf("%i \n", buffer[1]);
zmq_send (zmq_data_struct->socket, buffer, 42, 0);
free(buffer);
return 0;
}
......@@ -18,7 +18,7 @@
#define GET_DATA 0x5
#define GET_IO_CARDS 0x6
#define GET_PILC_INET 0x7
#define GET_DATE 0x8
#define INIT_IO_CARDS 0x9
typedef struct {
......@@ -43,6 +43,7 @@ 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 GetDate(zmq_data *zmq_data_struct);
void PiLC2InitIOCards(void);
void *context;
......
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