Sfoglia il codice sorgente

removed raspi-specific code

Julius Pfrommer 9 anni fa
parent
commit
03a7c39858

+ 0 - 130
examples/src/opcuaServer.c

@@ -1,17 +1,3 @@
-/*
- ============================================================================
- Name        : opcuaServer.c
- Author      :
- Version     :
- Copyright   : Your copyright notice
- Description : lala
- ============================================================================
- */
-#ifdef RASPI
-	#define _POSIX_C_SOURCE 199309L //to use nanosleep
-	#include <pthread.h>
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 
@@ -24,9 +10,6 @@
 #include <unistd.h>
 #include <time.h>
 #include <fcntl.h>
-#ifdef RASPI
-	#include "raspberrypi_io.h"
-#endif
 
 
 UA_Int32 serverCallback(void * arg) {
@@ -42,128 +25,15 @@ UA_Int32 serverCallback(void * arg) {
 		((UA_ServerStatusDataType*)(((UA_VariableNode*)node)->value.data))->currentTime = UA_DateTime_now();
 	}
 
-	const UA_Node *foundNode1 = UA_NULL;
-
-	Namespace_Entry_Lock *lock;
-	//node which should be filled with data (float value)
-	UA_NodeId tmpNodeId1;
-
-
-	tmpNodeId1.encodingByte = UA_NODEIDTYPE_TWOBYTE;
-	tmpNodeId1.identifier.numeric = 108;
-	tmpNodeId1.namespace =  0;
-
-
-	if(Namespace_get(ns0,&tmpNodeId1, &foundNode1,&lock) != UA_SUCCESS){
-		return UA_ERROR;
-	}
-
-
-#ifdef RASPI
-#else
-	*((float*)((UA_VariableNode *)foundNode1)->value.data) = *((float*)((UA_VariableNode *)foundNode1)->value.data) + 0.2f;
-#endif
-
-
-
 	return UA_SUCCESS;
 }
 
-#ifdef RASPI
-
-static float sharedTemperature = 0;
-static UA_Boolean sharedLED1 = 0;
-static UA_Boolean sharedLED2 = 0;
-
-static void* ioloop(void* ptr){
-    {
-	if(initIO())
-	{
-		printf("ERROR while initializing the IO \n");
-	}
-	else
-	{
-	        struct timespec t = {0, 50*1000*1000};
-		int j = 0;
-		for(;j<25;j++){
-		writePin(j%2,0);
-		writePin((j+1)%2,2);
-		nanosleep(&t, NULL);
-		}
-		writePin(0,0);
-		writePin(0,2);
-
-		printf("IO successfully initalized \n");
-	}
-
-	printf("done - io init \n");
-
-  
-
-        struct timespec t = {0, 50*1000*1000};
-    	while(1){
-		readTemp(&sharedTemperature);
-		writePin(sharedLED1,0);
-		writePin(sharedLED2,2);
-		nanosleep(&t, NULL);
-    	}
-    }
-	return UA_NULL;
-}
-#endif
 
 int main(int argc, char** argv) {
 	appMockup_init();
 	NL_data* nl = NL_init(&NL_Description_TcpBinary,16664);
 
 	struct timeval tv = {1, 0}; // 1 second
-#ifdef RASPI
-  	Namespace* ns0 = (Namespace*)UA_indexedList_find(appMockup.namespaces, 0)->payload;
-		const UA_Node *foundNode1 = UA_NULL;
-		const UA_Node *foundNode2 = UA_NULL;
-		const UA_Node *foundNode3 = UA_NULL;
-		Namespace_Entry_Lock *lock;
-		//node which should be filled with data (float value)
-		UA_NodeId tmpNodeId1;
-		UA_NodeId tmpNodeId2;
-		UA_NodeId tmpNodeId3;
-
-		tmpNodeId1.encodingByte = UA_NODEIDTYPE_TWOBYTE;
-		tmpNodeId1.identifier.numeric = 108;
-		tmpNodeId1.namespace =  0;
-
-		tmpNodeId2.encodingByte = UA_NODEIDTYPE_TWOBYTE;
-		tmpNodeId2.identifier.numeric = 109;
-		tmpNodeId2.namespace =  0;
-
-		tmpNodeId3.encodingByte = UA_NODEIDTYPE_TWOBYTE;
-		tmpNodeId3.identifier.numeric = 110;
-		tmpNodeId3.namespace =  0;
-            	
-			if(Namespace_get(ns0,&tmpNodeId1, &foundNode1,&lock) != UA_SUCCESS){
-				_exit(1);
-			}
-
-			if(Namespace_get(ns0,&tmpNodeId2, &foundNode2,&lock) != UA_SUCCESS){
-				_exit(1);
-			}
-
-			if(Namespace_get(ns0,&tmpNodeId3, &foundNode3,&lock) != UA_SUCCESS){
-				_exit(1);
-			}
-
-		((UA_VariableNode *)foundNode1)->value.data = &sharedTemperature;
-		((UA_VariableNode *)foundNode2)->value.data = &sharedLED1;
-		((UA_VariableNode *)foundNode3)->value.data = &sharedLED2;
-
-		pthread_t t;
-		pthread_create(&t, NULL, &ioloop, UA_NULL);
-
-	printf("raspi enabled \n");	
-  	//pid_t i = fork();
-	//printf("process id i=%d \n",i);
-#endif    
-
   	NL_msgLoop(nl, &tv, serverCallback, argv[0]);
 
 }

+ 0 - 65
examples/src/raspberrypi_io.c

@@ -1,65 +0,0 @@
-/*
- * raspberrypi_io.c
- *
- *  Created on: 23.06.2014
- *      Author: root
- */
-
-#include "raspberrypi_io.h"
-
-
-
-#ifdef RASPI
-static _Bool initialized = 0;
-int initIO()
-{
-	if (wiringPiSetup() == -1){
-		initialized = 0;
-		return 1;
-	}
-	initialized = 1;
-	return 0;
-}
-int readTemp(float *temp){
-	FILE *ptr_file;
-	char buf[1000];
-	char delimiter[] = "=";
-	char *ptr_temp;
-	long temperaturInmC;
-
-	ptr_file =fopen("/sys/bus/w1/devices/10-000802c607f3/w1_slave","r");
-	if (!ptr_file){
-		puts("ERROR: no sensor");
-		return 1;
-	}
-
-	fgets(buf, 1000, ptr_file);
-
-	fgets(buf, 1000, ptr_file);
-
-	ptr_temp = strtok(buf, (char*) delimiter);
-
-	ptr_temp = strtok((void*)0, (char*) delimiter);
-
-	temperaturInmC = atol(ptr_temp);
-
-	fclose(ptr_file);
-
-	*temp = (float)temperaturInmC/1000;
-	return 0;
-}
-
-int writePin(_Bool state, int pin){
-	if(initialized)
-	{
-		pinMode(0, OUTPUT);
-		if(state==(1==1)){
-			digitalWrite(pin, 1);
-		}else{
-			digitalWrite(pin, 0);
-		}
-		return 0;
-	}
-	return 1; //ERROR
-}
-#endif

+ 0 - 22
examples/src/raspberrypi_io.h

@@ -1,22 +0,0 @@
-/*
- * raspberrypi_io.h
- *
- *  Created on: 23.06.2014
- *      Author: root
- */
-
-#ifndef RASPBERRYPI_IO_H_
-#define RASPBERRYPI_IO_H_
-
-#include <wiringPi.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "string.h"
-int readTemp(float *temp);
-int writePin(_Bool state, int pin);
-int initIO();
-
-#endif /* RASPBERRYPI_IO_H_ */

+ 1 - 1
src/ua_types.h

@@ -109,7 +109,7 @@ typedef struct UA_String UA_XmlElement;
 
 /** @brief An identifier for a node in the address space of an OPC UA Server. */
 typedef struct UA_NodeId {
-	UA_Byte encodingByte;       //enum BID_NodeIdEncodingValuesType
+	UA_Byte encodingByte;
 	UA_UInt16 namespace;
 	union {
 		UA_UInt32     numeric;

+ 1 - 1
tools/generate_namespace.py

@@ -157,7 +157,7 @@ for row in rows:
 	i=i+1
     printh('#define '+name.upper()+'_NS0 '+row[1])
 
-    printc("\t{.typeId={UA_NODEIDTYPE_FOURBYTE,0,.identifier.numeric=" + row[1] + "}" + 
+    printc("\t{.typeId={.encodingByte = UA_NODEIDTYPE_TWOBYTE, .namespace = 0,.identifier.numeric=" + row[1] + "}" + 
           ",\n.name=(UA_Byte*)&\"%(name)s\"" +
           ",\n.new=(UA_Int32(*)(void **))%(name)s_new" +
           ",\n.init=(UA_Int32(*)(void *))%(name)s_init"+