diff --git a/clients/opal/models/send_receive/include/msg_format.h b/clients/opal/models/send_receive/include/msg_format.h index 7de407a73..4ba4dc41c 100644 --- a/clients/opal/models/send_receive/include/msg_format.h +++ b/clients/opal/models/send_receive/include/msg_format.h @@ -57,10 +57,17 @@ **/ struct msg { +#if BYTE_ORDER == BIG_ENDIAN unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */ unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */ unsigned endian : 1; /**< Specifies the byteorder of the message (see MSG_ENDIAN_*) */ unsigned : 1; /**< Reserved padding bits */ +#elif BYTE_ORDER == LITTLE_ENDIAN + unsigned : 1; /**< Reserved padding bits */ + unsigned endian : 1; /**< Specifies the byteorder of the message (see MSG_ENDIAN_*) */ + unsigned type : 2; /**< Data or control message (see MSG_TYPE_*) */ + unsigned version: 4; /**< Specifies the format of the remaining message (see MGS_VERSION) */ +#endif /** Number of valid dword values in msg::data[] */ uint8_t length; diff --git a/clients/opal/models/send_receive/include/sched.h b/clients/opal/models/send_receive/include/utils.h similarity index 100% rename from clients/opal/models/send_receive/include/sched.h rename to clients/opal/models/send_receive/include/utils.h diff --git a/clients/opal/models/send_receive/s2ss.mk b/clients/opal/models/send_receive/s2ss.mk index 3e97f6e63..e31b9726c 100644 --- a/clients/opal/models/send_receive/s2ss.mk +++ b/clients/opal/models/send_receive/s2ss.mk @@ -51,7 +51,7 @@ INCLUDES = -I. LIBPATH = -L. CC_OPTS = LD_OPTS = -OBJS = s2ss.o msg.o sched.o socket.o +OBJS = s2ss.o msg.o utils.o socket.o ADDLIB = -lOpalCore -lOpalUtils LIBS = -lOpalAsyncApiCore $(ADDLIB) $(TARGET_LIB) diff --git a/clients/opal/models/send_receive/send_receive.llm b/clients/opal/models/send_receive/send_receive.llm index 76b894153..7d15302aa 100644 --- a/clients/opal/models/send_receive/send_receive.llm +++ b/clients/opal/models/send_receive/send_receive.llm @@ -21,7 +21,7 @@ MONITORING=ON MONITORING_BLOCK=OFF MONITORING_DISPLAY=NEVER MSG_PRECISION_FACTOR=0 -MaxDynamicSignals=2/0/100/24/100/ +MaxDynamicSignals=2/0/100/24/42/ NB_STEP_WITHOUT_OVERRUNS=10 OPAL_DEBUG=OFF OP_MATLABR2011B=1 @@ -37,32 +37,30 @@ INTERNAL_IGN_SOURCE_FILE=sfun_gen_async_ctrl.c sfun_recv_async.c sfun_send_async INTERNAL_LIBRARY2=-lOpalAsyncApiR2011b INTERNAL_LIBRARY3=-lOpalAsyncApiCore [ExtraPutFilesComp] -s2ss.mk=Ascii include\config.h=Ascii -include\interface.h=Ascii include\msg.h=Ascii include\msg_format.h=Ascii -include\sched.h=Ascii include\socket.h=Ascii -src\s2ss.c=Ascii -src\interface.c=Ascii +include\utils.h=Ascii +s2ss.mk=Ascii src\msg.c=Ascii -src\sched.c=Ascii +src\s2ss.c=Ascii src\socket.c=Ascii +src\utils.c=Ascii [ExtraPutFilesComp_1_RT_LAB] C:\OPAL-RT\RT-LAB\v10.5.9.356\common\lib\redhawk\libOpalAsyncApiCore.a=Binary [General] -ATT_CHECKSUM1=3292912416 -ATT_CHECKSUM2=2957866115 -ATT_CHECKSUM3=2922744635 -ATT_CHECKSUM4=170288900 +ATT_CHECKSUM1=1072878433 +ATT_CHECKSUM2=1369345764 +ATT_CHECKSUM3=1918599754 +ATT_CHECKSUM4=4207979685 ATT_CREATED_BY=jwu ATT_CREATED_ON=Thu Apr 15 08:21:54 1999 ATT_ENABLE_PTA=OFF ATT_HANDLE_CONSOLE=ON ATT_LAST_SAVED_BY=ACS -ATT_LAST_SAVED_ON=Mon Jul 14 21:00:08 2014 -ATT_REVISION=1.435 +ATT_LAST_SAVED_ON=Thu Sep 04 11:03:30 2014 +ATT_REVISION=1.443 AutoRetrieveFiles=ON AutoRetrieveRtlab=ON CompilerVersion=AUTOMATIC @@ -88,7 +86,7 @@ RetrieveRootDir= SimulationMode=2 TLC=Automatic TMF=Automatic -TRANSFERFILE_AT_LOAD=OFF +TRANSFERFILE_AT_LOAD=ON TargetCompileCmd=/usr/bin/make -f /usr/opalrt/common/bin/opalmodelmk TargetPlatform=REDHAWK TimeFactor=1.000000000000000 diff --git a/clients/opal/models/send_receive/send_receive.mdl b/clients/opal/models/send_receive/send_receive.mdl index 7451d0b8c..0aaffdb74 100644 --- a/clients/opal/models/send_receive/send_receive.mdl +++ b/clients/opal/models/send_receive/send_receive.mdl @@ -7,7 +7,7 @@ Model { NumRootInports 0 NumRootOutports 0 ParameterArgumentNames "" - ComputedModelVersion "1.435" + ComputedModelVersion "1.443" NumModelReferences 0 NumTestPointedSignals 0 } @@ -28,9 +28,9 @@ Model { ModifiedByFormat "%" LastModifiedBy "ACS" ModifiedDateFormat "%" - LastModifiedDate "Mon Jul 14 21:00:08 2014" - RTWModifiedTimeStamp 327272401 - ModelVersionFormat "1.%" + LastModifiedDate "Thu Sep 04 11:03:30 2014" + RTWModifiedTimeStamp 331729408 + ModelVersionFormat "1.%" ConfigurationManager "none" SampleTimeColors off SampleTimeAnnotations off @@ -795,7 +795,7 @@ Model { System { Name "sc_console" Location [-17, 82, 1626, 997] - Open on + Open off ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" @@ -868,7 +868,7 @@ Model { Name "Mux" SID "34" Ports [2, 1] - Position [465, 246, 470, 284] + Position [465, 236, 470, 274] ShowName off Inputs "2" DisplayOption "bar" @@ -878,7 +878,7 @@ Model { Name "OpComm" SID "9" Ports [3, 3] - Position [225, 138, 265, 212] + Position [225, 135, 255, 215] LibraryVersion "1.348" SourceBlock "rtlab/OpComm" SourceType "RT-LAB OpComm" @@ -915,7 +915,7 @@ Model { Name "errors" SID "10" Ports [1] - Position [385, 82, 455, 128] + Position [385, 72, 455, 118] BackgroundColor "yellow" FontName "Arial" FontSize 8 @@ -927,7 +927,7 @@ Model { Name "message 1" SID "40" Ports [1] - Position [590, 169, 620, 201] + Position [590, 159, 620, 191] BackgroundColor "yellow" Floating off Location [826, 517, 1334, 952] @@ -958,7 +958,7 @@ Model { Name "message 2" SID "33" Ports [1] - Position [590, 249, 620, 281] + Position [590, 239, 620, 271] BackgroundColor "yellow" Floating off Location [826, 517, 1334, 952] @@ -1050,7 +1050,7 @@ Model { Name "reception status" SID "12" Ports [1] - Position [390, 148, 450, 172] + Position [390, 133, 450, 157] BackgroundColor "yellow" FontName "Arial" FontSize 8 @@ -1067,14 +1067,14 @@ Model { Line { SrcBlock "OpComm" SrcPort 2 - Points [35, 0; 0, 80] + Points [45, 0; 0, 80] Branch { Labels [1, 0] DstBlock "Demux1" DstPort 1 } Branch { - Points [0, -70] + Points [0, -80] DstBlock "message 1" DstPort 1 } @@ -1088,20 +1088,20 @@ Model { Line { SrcBlock "OpComm" SrcPort 1 + Points [10, 0] DstBlock "Demux" DstPort 1 } Line { SrcBlock "Demux" SrcPort 1 - Points [45, 0; 0, -20] + Points [45, 0; 0, -30] DstBlock "errors" DstPort 1 } Line { SrcBlock "Demux" SrcPort 2 - Points [45, 0; 0, 15] DstBlock "reception status" DstPort 1 } @@ -1122,7 +1122,7 @@ Model { Line { SrcBlock "OpComm" SrcPort 3 - Points [15, 0; 0, 150] + Points [25, 0; 0, 150] Branch { Points [0, 0] DstBlock "Demux2" @@ -1141,37 +1141,37 @@ Model { DstPort 1 } Line { - Labels [1, 0] - SrcBlock "Demux1" + SrcBlock "Demux2" SrcPort 5 - Points [20, 0; 0, -30] + Points [40, 0; 0, -45] Branch { + Points [0, -70] DstBlock "Mux" - DstPort 1 + DstPort 2 } Branch { - Points [0, 65] DstBlock "Subtract" - DstPort 1 + DstPort 2 } } Line { - SrcBlock "Demux2" + SrcBlock "Demux1" SrcPort 5 - Points [35, 0; 0, -45] + Points [25, 0] Branch { - Points [0, -60] + Points [0, -40] DstBlock "Mux" - DstPort 2 + DstPort 1 } Branch { + Points [0, 35] DstBlock "Subtract" - DstPort 2 + DstPort 1 } } Annotation { Name "Simple analysis of round trip time" - Position [293, 52] + Position [273, 42] FontName "Verdana" FontSize 14 FontWeight "bold" @@ -1195,7 +1195,7 @@ Model { System { Name "sm_model" Location [2, 82, 1662, 980] - Open off + Open on ModelBrowserVisibility off ModelBrowserWidth 200 ScreenColor "white" @@ -1239,9 +1239,9 @@ Model { SourceType "OpAsyncIPCtrl" ctl_id "1" proto "UDP/IP" - ip_addr_remote "134.130.169.31" - ip_port_remote "10200" - ip_port_local "10201" + ip_addr_remote "10.10.10.1" + ip_port_remote "12000" + ip_port_local "12001" ip_addr_mcast "0.0.0.0" exe_name "AsyncIP" } @@ -1269,12 +1269,13 @@ Model { } Block { BlockType DiscretePulseGenerator - Name "data ready 1 kHz" + Name "data ready ? kHz" SID "20" Ports [0, 1] Position [290, 131, 335, 149] NamePlacement "alternate" - SampleTime "0.001" + Period "10" + SampleTime "0.1" } Block { BlockType Reference @@ -1429,7 +1430,7 @@ Model { } } Line { - SrcBlock "data ready 1 kHz" + SrcBlock "data ready ? kHz" SrcPort 1 DstBlock "send message 1" DstPort 1 diff --git a/clients/opal/models/send_receive/src/msg.c b/clients/opal/models/send_receive/src/msg.c index fac5e43d9..f948076d1 100644 --- a/clients/opal/models/send_receive/src/msg.c +++ b/clients/opal/models/send_receive/src/msg.c @@ -14,11 +14,12 @@ void msg_swap(struct msg *m) { - for (int i = 0; i < m->length; i++) { + int i; + for (i = 0; i < m->length; i++) { #ifdef __linux__ - data[i] = bswap_32(m->data[i].i); + m->data[i].i = bswap_32(m->data[i].i); #elif defined(__powerpc__) - data[i] = Xil_EndianSwap32(m->data[i].i); + m->data[i].i = Xil_EndianSwap32(m->data[i].i); #endif } diff --git a/clients/opal/models/send_receive/src/s2ss.c b/clients/opal/models/send_receive/src/s2ss.c index fc2e22a3a..fcd5a86e6 100644 --- a/clients/opal/models/send_receive/src/s2ss.c +++ b/clients/opal/models/send_receive/src/s2ss.c @@ -101,7 +101,7 @@ static void *SendToIPPort(void *arg) msg.length = mdldata_size / sizeof(double); for (i = 0; i < msg.length; i++) - msg.data[i] = (float) mdldata[i].f; + msg.data[i].f = (float) mdldata[i]; msg_size = MSG_LEN(msg.length); /**********************************************************************/ @@ -156,8 +156,7 @@ static void *RecvFromIPPort(void *arg) do { /******* FORMAT TO SPECIFIC PROTOCOL HERE ******************************/ - msg_size = sizeof(msg); - n = RecvPacket((char *) &msg, msg_size, 1.0); + n = RecvPacket((char *) &msg, sizeof(msg), 1.0); /** @todo: Check and ntohs() sequence number! */ @@ -172,6 +171,11 @@ static void *RecvFromIPPort(void *arg) } msg_size = MSG_LEN(msg.length); + + msg.sequence = ntohs(msg.sequence); + + if (msg.endian != MSG_ENDIAN_HOST) + msg_swap(&msg); /***********************************************************************/ if (n < 1) { @@ -210,9 +214,6 @@ static void *RecvFromIPPort(void *arg) PROGNAME, RecvID, mdldata_size / sizeof(double), msg.length); } - if (msg.endian != MSG_ENDIAN_HOST) - msg_swap(&msg); - for (i = 0; i < msg.length; i++) mdldata[i] = (double) msg.data[i].f; /************************************************************************/ diff --git a/clients/opal/models/send_receive/src/sched.c b/clients/opal/models/send_receive/src/utils.c similarity index 98% rename from clients/opal/models/send_receive/src/sched.c rename to clients/opal/models/send_receive/src/utils.c index 42e5a89b1..a22e0f838 100644 --- a/clients/opal/models/send_receive/src/sched.c +++ b/clients/opal/models/send_receive/src/utils.c @@ -15,7 +15,7 @@ #include "OpalPrint.h" #include "config.h" -#include "sched.h" +#include "utils.h" #if defined(__QNXNTO__) # include