Browse Source

related to #265, added another define as well as "faster" encoding functions for ARM7TDMI with "mixed" endian

FlorianPalm 9 years ago
parent
commit
0632a8363b
4 changed files with 442 additions and 286 deletions
  1. 20 0
      examples/server.c
  2. 2 0
      include/ua_config.h.in
  3. 1 0
      src/server/ua_services_attribute.c
  4. 419 286
      src/ua_types_encoding_binary.c

+ 20 - 0
examples/server.c

@@ -213,7 +213,27 @@ static UA_ByteString loadCertificate(void) {
 
     return certificate;
 }
+static UA_StatusCode UA_Double_encodeBinary(UA_Double const *src, UA_ByteString *dst,
+		size_t* offset) {
+	if ((UA_Int32) (*offset + sizeof(UA_Double)) > dst->length)
+		return UA_STATUSCODE_BADENCODINGERROR;
 
+    /* ARM7TDMI Half Little Endian Byte order for Double 3 2 1 0 7 6 5 4 */
+
+	UA_Byte srcDouble[sizeof(UA_Double)];
+	memcpy(&srcDouble,src,sizeof(UA_Double));
+
+
+	dst->data[(*offset)++] = srcDouble[4];
+	dst->data[(*offset)++] = srcDouble[5];
+	dst->data[(*offset)++] = srcDouble[6];
+	dst->data[(*offset)++] = srcDouble[7];
+	dst->data[(*offset)++] = srcDouble[0];
+	dst->data[(*offset)++] = srcDouble[1];
+	dst->data[(*offset)++] = srcDouble[2];
+	dst->data[(*offset)++] = srcDouble[3];
+	return UA_STATUSCODE_GOOD;
+}
 int main(int argc, char** argv) {
 	signal(SIGINT, stopHandler); /* catches ctrl-c */
 #ifdef UA_MULTITHREADING

+ 2 - 0
include/ua_config.h.in

@@ -51,6 +51,7 @@
 /* Mixed Endian */
 #ifdef __ARM_ARCH_4T__
 # define UA_MIXED_ENDIAN
+# define UA_NON_LITTLEENDIAN_ARCHITECTURE
 #endif
 
 /* Aligned Memory Access */
@@ -58,4 +59,5 @@
 # define UA_ALIGNED_MEMORY_ACCESS
 #endif
 
+
 #endif /* UA_CONFIG_H_ */

+ 1 - 0
src/server/ua_services_attribute.c

@@ -516,6 +516,7 @@ static UA_StatusCode writeValue(UA_Server *server, UA_WriteValue *wvalue) {
                    oldV->type->typeIndex == wvalue->value.value.type->typeIndex)
                     /* An enum was sent as an int32, or an opaque type as a bytestring. This is
                        detected with the typeIndex indicated the "true" datatype. */
+
                     wvalue->value.value.type = oldV->type;
                 else if(oldV->type == &UA_TYPES[UA_TYPES_BYTE] && !UA_Variant_isScalar(oldV) &&
                         wvalue->value.value.type == &UA_TYPES[UA_TYPES_BYTESTRING] &&

File diff suppressed because it is too large
+ 419 - 286
src/ua_types_encoding_binary.c