Skip to content

Commit

Permalink
Remove dirty hack to stop the netX in getContinuosChanges mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
docbacardi committed Sep 23, 2022
1 parent ae90b5c commit f478de9
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 20 deletions.
27 changes: 25 additions & 2 deletions iomatrix/src/main_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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( ulPinCnt<ulPinMax )
{
Expand Down Expand Up @@ -590,28 +598,43 @@ static int get_continuous_changes(IOMATRIX_PARAMETER_GET_CONTINUOUS_CHANGES_T *p
if( iPrintReport!=0 )
{
ulPinCnt = 0;
ulCombinedPinState = 0;
while( ulPinCnt<ulPinMax )
{
/* Convert the pin value to ASCII.
* A value of 0x00 is printed as "0", everything else is a "1".
*/
cPinValue = '0';
ucPinValue = 0U;
if( aucLastPinState[ulPinCnt]!=0 )
{
cPinValue = '1';
ucPinValue = 1U;
}
uprintf("%c", cPinValue);
ulCombinedPinState |= (((unsigned long)ucPinValue) << ulPinCnt);

++ulPinCnt;
}
uprintf("\n");

/* The report was printed. */
iPrintReport = 0;
systime_handle_start_ms(&tTimer, ulForcedUpdateInterval);

/* Does this match the current state? */
if( ulCombinedPinState==ptParameter->aulStates[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 )
{
Expand Down
2 changes: 2 additions & 0 deletions iomatrix/src/main_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions iomatrix/templates/io_matrix.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
17 changes: 15 additions & 2 deletions iomatrix/templates/io_matrix/netx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 20 additions & 14 deletions iomatrix/templates/io_matrix/netx_base.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -462,20 +462,20 @@ 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
error('Error: Failed to get continous status match')
else
tResult = true
end

self.tLog.debug('Leaving netx_base get_continuous_status_match function')
return tResult
end
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit f478de9

Please sign in to comment.