diff --git a/iomatrix/src/main_test.c b/iomatrix/src/main_test.c index 4c52015..a45a7ec 100644 --- a/iomatrix/src/main_test.c +++ b/iomatrix/src/main_test.c @@ -511,7 +511,7 @@ static int get_continuous_status_match(IOMATRIX_PARAMETER_GET_CONTINUOUS_STATUS_ -static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *ptParameter __attribute__ ((unused))) +static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *ptParameter) { int iResult; int iPrintReport; @@ -529,6 +529,9 @@ static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *p TIMER_HANDLE_T tTimer; unsigned char aucLastPinState[MAX_PINS_UNDER_TEST]; + unsigned long ulCombinedPinState; + unsigned long ulCurrentPinState; + /* Be optimistic */ iResult = 0; @@ -542,11 +545,16 @@ static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *p /* There is no cancel request yet. */ iIsRunning = 1; + ulCurrentPinState = 0; + systime_handle_start_ms(&tTimer, ulForcedUpdateInterval); ulPinMax = ulPinsUnderTest; while(iIsRunning) { + /* Get all pins and store the new state in aucLastPinState. + * Set iPrintReport to 1 if a pin changed. + */ ulPinCnt = 0; while( ulPinCntaulStates[ulCurrentPinState] ) + { + ++ulCurrentPinState; + if( ulCurrentPinState>=ptParameter->ulNumberOfStates ) + { + iIsRunning = 0; + } + } } - /* Is a cancel request waiting? */ #if 0 + /* Is a cancel request waiting? */ uiPeek = SERIAL_PEEK(); if( uiPeek!=0 ) { diff --git a/iomatrix/src/main_test.h b/iomatrix/src/main_test.h index f428ebb..31f4ec8 100644 --- a/iomatrix/src/main_test.h +++ b/iomatrix/src/main_test.h @@ -93,6 +93,8 @@ typedef struct IOMATRIX_PARAMETER_CONTINUOUS_PIN_STATUS_T typedef struct IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_STRUCT { void *pvPinDescription; /* A handle of the pin description. */ + unsigned long ulNumberOfStates; + unsigned long aulStates[MAX_PINS_UNDER_TEST/4]; } IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T; typedef struct IOMATRIX_PARAMETER_STRUCT diff --git a/iomatrix/templates/io_matrix.lua b/iomatrix/templates/io_matrix.lua index 682c5f7..6649b20 100644 --- a/iomatrix/templates/io_matrix.lua +++ b/iomatrix/templates/io_matrix.lua @@ -139,8 +139,8 @@ function IoMatrix:bget() end -function IoMatrix:getContinuousChanges(fnCallback, pvUser) - self.netx:getContinuousChanges(fnCallback, pvUser) +function IoMatrix:getContinuousChanges(astrStates, fnCallback, pvUser) + self.netx:getContinuousChanges(astrStates, fnCallback, pvUser) end diff --git a/iomatrix/templates/io_matrix/netx.lua b/iomatrix/templates/io_matrix/netx.lua index 2efa9cf..b91f549 100644 --- a/iomatrix/templates/io_matrix/netx.lua +++ b/iomatrix/templates/io_matrix/netx.lua @@ -138,9 +138,22 @@ end -function IoMatrix_netx:getContinuousChanges(fnCallback, pvUser) +function IoMatrix_netx:getContinuousChanges(astrStates, fnCallback, pvUser) + -- Convert the list of states to 32bit values. + local aulStates = {} + for _, strState in ipairs(astrStates) do + local ulState = 0 + for uiPos=string.len(strState),1,-1 do + ulState = ulState * 2 + if string.sub(strState, uiPos, uiPos)=='1' then + ulState = ulState + 1 + end + end + table.insert(aulStates, ulState) + end + for _, tDev in pairs(self.atDevices) do - tDev:getContinuousChanges(fnCallback, pvUser) + tDev:getContinuousChanges(aulStates, fnCallback, pvUser) end end diff --git a/iomatrix/templates/io_matrix/netx_base.lua b/iomatrix/templates/io_matrix/netx_base.lua index fd5d090..0ad5bb0 100644 --- a/iomatrix/templates/io_matrix/netx_base.lua +++ b/iomatrix/templates/io_matrix/netx_base.lua @@ -428,32 +428,32 @@ function IoMatrix_netx_base:parse_pins() end --- No need of passing arguments because netx_base is the base class of netx +-- No need of passing arguments because netx_base is the base class of netx function IoMatrix_netx_base:get_continuous_status_match(tStateList, ulNumberOfPatternsToTest) local strList = "" -- List with all test patterns local ulCount = 0 -- Variable to count number of table entries - + -- Here write data into one string -- Go over the table and concat all entries of test patterns for _, tValue in ipairs(tStateList) do strList = strList .. tValue end - + self.tLog.debug('strList of Testpattern: %s', strList) - + -- Last check if number if test pins and count of test patterns fit for Index, Value in pairs( tStateList ) do ulCount = ulCount + 1 end - + self.tLog.debug('ulCount: %d', ulCount) self.tLog.debug('ulNumberOfPatternsToTest: %d', ulNumberOfPatternsToTest) - + if ulCount ~= ulNumberOfPatternsToTest then - + error('Error: Pattern count of list does not fit with handover variable ulNumberOfPatternsToTest') end - + -- Collect the parameter for the header self:__write_header{ self.ulVerbose, -- Verbose mode. @@ -462,12 +462,12 @@ function IoMatrix_netx_base:get_continuous_status_match(tStateList, ulNumberOfPa ulNumberOfPatternsToTest, -- Count of Pins in List to test strList -- Sequence of pin status } - + -- Call the netX program self.tLog.debug('__/Output of get_continuous_status_match Test/________________________________') self.tPlugin:call(self.ulExecutionAddress, self.ulParameterStartAddress, self.fnCallbackMessage, 0) self.tLog.debug('______________________________________________________________________________') - + -- Get the result local ulResult = self.tPlugin:read_data32(self.ulParameterStartAddress) if ulResult~=0 then @@ -475,7 +475,7 @@ function IoMatrix_netx_base:get_continuous_status_match(tStateList, ulNumberOfPa else tResult = true end - + self.tLog.debug('Leaving netx_base get_continuous_status_match function') return tResult end @@ -625,15 +625,21 @@ end -function IoMatrix_netx_base:getContinuousChanges(fnCallback, pvUser) +function IoMatrix_netx_base:getContinuousChanges(aulStates, fnCallback, pvUser) local tResult -- Collect the parameter. - self:__write_header{ + local aulCmd = { self.ulVerbose, -- Verbose mode. self.IOMATRIX_COMMAND_Get_Continuous_Changes, -- The command code. - self.hPinDescription -- Pin description handle. + self.hPinDescription, -- Pin description handle. + #aulStates -- Number of states. } + for _, ulState in ipairs(aulStates) do + table.insert(aulCmd, ulState) + end + + self:__write_header(aulCmd) local fnDefaultCallback = self.fnCallbackMessage local function fnMessageSplitter(strData, tParamB)