Skip to content

Commit db14222

Browse files
Release 2.1.1
# Release 2.1.1 ## Bugfix - Error if writing of process data and parameters (fix needs CSK_ModuleIODDInterpreter version >= 2.1.1)
1 parent 2915e76 commit db14222

6 files changed

Lines changed: 46 additions & 124 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## Release 2.1.1
5+
6+
### Bugfixes
7+
writing of process data and parameters is available again
8+
49
## Release 2.1.0
510

611
### New features

CSK_Module_MultiIOLinkSMI/project.mf.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ Provide IOLink data via event.</desc>
10561056
</crown>
10571057
</crown>
10581058
<meta key="author">SICK AG</meta>
1059-
<meta key="version">2.1.0</meta>
1059+
<meta key="version">2.1.1</meta>
10601060
<meta key="priority">low</meta>
10611061
<meta key="copy-protected">false</meta>
10621062
<meta key="read-protected">false</meta>

CSK_Module_MultiIOLinkSMI/scripts/CSK_MultiIOLinkSMI_Processing.lua

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ end
107107
---@param jsonDataPointInfo string JSON table containing process data info from IODD file
108108
---@return string? convertedResult JSON table with interpted read data
109109
local function readProcessDataIODD(jsonDataPointInfo)
110-
local dataPointInfo = converter.renameDatatype(json.decode(jsonDataPointInfo))
110+
local dataPointInfo = json.decode(jsonDataPointInfo)
111111
local success, readData = readProcessData(dataPointInfo)
112112
if not success then
113113
return nil
@@ -179,7 +179,7 @@ end
179179
---@return bool success Success of writing.
180180
---@return string? details Detailed error if writing is not successful.
181181
local function writeProcessDataIODD(jsonDataPointInfo, jsonData)
182-
local dataPointInfo = converter.renameDatatype(json.decode(jsonDataPointInfo))
182+
local dataPointInfo = json.decode(jsonDataPointInfo)
183183
return writeProcessData(dataPointInfo, json.decode(jsonData))
184184
end
185185
Script.serveFunction('CSK_MultiIOLinkSMI.writeProcessDataIODD_' .. multiIOLinkSMIInstanceNumberString, writeProcessDataIODD, 'string:1:,string:1:', 'bool:1:,string:?:')
@@ -246,7 +246,7 @@ end
246246
---@param jsonDataPointInfo string JSON table containing parameter info from IODD file.
247247
---@return string? jsonData JSON table with interpted parameter value.
248248
local function readParameterIODD(index, subindex, jsonDataPointInfo)
249-
local dataPointInfo = converter.renameDatatype(json.decode(jsonDataPointInfo))
249+
local dataPointInfo = json.decode(jsonDataPointInfo)
250250
dataPointInfo.index = index
251251
dataPointInfo.subindex = subindex
252252
local success, readData = readParameter(dataPointInfo)
@@ -316,7 +316,11 @@ local function writeParameter(dataPointInfo, dataToWrite)
316316
_G.logger:warning(nameOfModule..': failed to convert parameter for writing on port ' .. tostring(processingParams.port) .. ' instancenumber ' .. multiIOLinkSMIInstanceNumberString ..'; datapoint info: ' .. tostring(json.encode(dataPointInfo)) .. '; data: ' .. tostring(json.encode(dataToWrite)))
317317
return false, 'failed to convert data'
318318
end
319-
return writeBinaryServiceData(tonumber(dataPointInfo.index), tonumber(dataPointInfo.subindex), binDataToWrite)
319+
if not dataPointInfo.info.subindex then
320+
return writeBinaryServiceData(tonumber(dataPointInfo.info.index), 0, binDataToWrite)
321+
else
322+
return writeBinaryServiceData(tonumber(dataPointInfo.info.index), tonumber(dataPointInfo.subindex), binDataToWrite)
323+
end
320324
end
321325

322326
--Write parameter with provided info from IODD interpreter and data to write (as JSON tables).
@@ -327,7 +331,7 @@ end
327331
---@return bool success Success of writing.
328332
---@return string? details Detailed error if writing is not successful.
329333
local function writeParameterIODD(index, subindex, jsonDataPointInfo, jsonDataToWrite)
330-
local dataPointInfo = converter.renameDatatype(json.decode(jsonDataPointInfo))
334+
local dataPointInfo = json.decode(jsonDataPointInfo)
331335
dataPointInfo.index = index
332336
dataPointInfo.subindex = subindex
333337
return writeParameter(dataPointInfo, json.decode(jsonDataToWrite))
@@ -610,19 +614,6 @@ Script.serveFunction('CSK_MultiIOLinkSMI.writeIODDMessage' .. multiIOLinkSMIInst
610614
local function updateIODDWriteMessages()
611615
ioddWriteMessagesResults = {}
612616
ioddLatesWriteMessages = {}
613-
for messageName, messageInfo in pairs(ioddWriteMessages) do
614-
if helperFuncs.getTableSize(messageInfo.dataInfo) == 0 then
615-
goto nextMessage
616-
end
617-
for dataMode, dataModeInfo in pairs(messageInfo.dataInfo) do
618-
if dataMode == "ProcessData" or dataMode == "Parameters" then
619-
for dataPointID, dataPointInfo in pairs(dataModeInfo) do
620-
ioddWriteMessages[messageName].dataInfo[dataMode][dataPointID] = converter.renameDatatype(dataPointInfo)
621-
end
622-
end
623-
end
624-
::nextMessage::
625-
end
626617
local queueFunctions = {}
627618
for messageName, messageInfo in pairs(ioddWriteMessages) do
628619
local function writeDestinations(jsonDataToWrite)

CSK_Module_MultiIOLinkSMI/scripts/Communication/MultiIOLinkSMI/helper/DataConverter.lua

Lines changed: 25 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,15 @@ converter.getParameterReadFunctions = getParameterReadFunctions
237237
-- Convert a raw binary data from IO-Link device to a meaningful Lua table
238238
local function getReadServiceDataResult(binData, parameterInfo)
239239
local Result = {}
240-
if parameterInfo.Datatype.type == 'ArrayT' then
241-
local simpleDataBitLength = getDatatypeBitlength(parameterInfo.Datatype.Datatype)
242-
local bitIndexer = 0
243-
for i = 1, parameterInfo.Datatype.count do
244-
local simpleBinaryData = disassembleData(binData, bitIndexer, simpleDataBitLength)
245-
bitIndexer = bitIndexer + simpleDataBitLength
246-
Result["element_" .. tostring(i)] = {
247-
value = toDataType(simpleBinaryData, parameterInfo.Datatype.Datatype.type)
248-
}
249-
end
250-
elseif parameterInfo.Datatype.type == 'RecordT' then
251-
for _, SingleItem in ipairs(parameterInfo.Datatype.RecordItem) do
252-
local binaryData = disassembleData(binData, tonumber(SingleItem.bitOffset), getDatatypeBitlength(SingleItem.Datatype))
253-
254-
Result[SingleItem.Name] = {
255-
value = toDataType(binaryData, SingleItem.Datatype.type)
240+
if parameterInfo.info.type == 'ArrayT' or parameterInfo.info.type == 'RecordT' then
241+
for _, SingleItem in pairs(parameterInfo.subindeces) do
242+
local binaryData = disassembleData(binData, tonumber(SingleItem.info.bitOffset), getDatatypeBitlength(SingleItem.info))
243+
Result[SingleItem.info.Name] = {
244+
value = toDataType(binaryData, SingleItem.info.type)
256245
}
257246
end
258-
elseif parameterInfo.Datatype then
259-
Result.value = toDataType(binData, parameterInfo.Datatype.type)
247+
elseif parameterInfo.info then
248+
Result.value = toDataType(binData, parameterInfo.info.type)
260249
end
261250
return Result
262251
end
@@ -267,11 +256,11 @@ converter.getReadServiceDataResult = getReadServiceDataResult
267256
local function getReadProcessDataResult(binData, processDataInfo)
268257
local resultData = {}
269258
for dataPointID, dataPointInfo in pairs(processDataInfo) do
270-
if dataPointInfo.Datatype.type == 'RecordT' or dataPointInfo.Datatype.type == 'ArrayT' then
259+
if dataPointInfo.info.type == 'RecordT' or dataPointInfo.info.type == 'ArrayT' then
271260
resultData[dataPointID] = getReadServiceDataResult(binData, dataPointInfo)
272261
else
273-
local offsetData = disassembleData(binData, tonumber(dataPointInfo.bitOffset), getDatatypeBitlength(dataPointInfo.Datatype))
274-
resultData[dataPointID] = {value = toDataType(offsetData, dataPointInfo.Datatype.type)}
262+
local offsetData = disassembleData(binData, tonumber(dataPointInfo.info.bitOffset), getDatatypeBitlength(dataPointInfo.info))
263+
resultData[dataPointID] = {value = toDataType(offsetData, dataPointInfo.info.type)}
275264
end
276265
end
277266
return resultData
@@ -281,15 +270,9 @@ converter.getReadProcessDataResult = getReadProcessDataResult
281270
--Return a JSON payload of expacted format filled with null values in case reading of a Parameter has failed
282271
local function getFailedReadServiceDataResult(parameterInfo)
283272
local Result = {}
284-
if parameterInfo.Datatype.type == 'ArrayT' then
285-
for i = 1, parameterInfo.Datatype.count do
286-
Result["element_" .. tostring(i)] = {
287-
value = "null"
288-
}
289-
end
290-
elseif parameterInfo.Datatype.type == 'RecordT' then
291-
for _, SingleItem in ipairs(parameterInfo.Datatype.RecordItem) do
292-
Result[SingleItem.Name] = {
273+
if parameterInfo.info.type == 'ArrayT' or parameterInfo.info.type == 'RecordT' then
274+
for _, SingleItem in pairs(parameterInfo.subindeces) do
275+
Result[SingleItem.info.Name] = {
293276
value = "null"
294277
}
295278
end
@@ -384,34 +367,18 @@ end
384367
-- Conver Lua table of a complex type (array or record) to a binary data for writing to IO-Link device
385368
local function getComplexServiceDataToWrite(parameterInfo, data)
386369
local bitArray
387-
local byteLength = math.ceil(getDatatypeBitlength(parameterInfo.Datatype) / 8)
388-
if parameterInfo.Datatype.type == 'ArrayT' then
389-
bitArray = makeEmptyBitArray(getDatatypeBitlength(parameterInfo.Datatype))
390-
391-
local simpleDataBitLength = getDatatypeBitlength(parameterInfo.Datatype.Datatype)
392-
local bitIndexer = 0
393-
for i = 1, tonumber(parameterInfo.Datatype.count) do
394-
insertIntoBitArray(
395-
bitArray,
396-
data[i].value,
397-
parameterInfo.Datatype.Datatype.type,
398-
bitIndexer*simpleDataBitLength,
399-
simpleDataBitLength
400-
)
401-
bitIndexer = bitIndexer + 1
402-
end
403-
elseif parameterInfo.Datatype.type == 'RecordT' then
404-
bitArray = makeEmptyBitArray(getDatatypeBitlength(parameterInfo.Datatype))
405-
for _, SingleItem in ipairs(parameterInfo.Datatype.RecordItem) do
370+
local byteLength = math.ceil(getDatatypeBitlength(parameterInfo.info) / 8)
371+
if parameterInfo.info.type == 'ArrayT' or parameterInfo.info.type == 'RecordT' then
372+
bitArray = makeEmptyBitArray(getDatatypeBitlength(parameterInfo.info))
373+
for _, SingleItem in pairs(parameterInfo.subindeces) do
406374
insertIntoBitArray(
407375
bitArray,
408-
data[SingleItem.Name].value,
409-
SingleItem.Datatype.type,
410-
tonumber(SingleItem.bitOffset),
411-
getDatatypeBitlength(SingleItem.Datatype)
376+
data[SingleItem.info.Name].value,
377+
SingleItem.info.type,
378+
tonumber(SingleItem.info.bitOffset),
379+
getDatatypeBitlength(SingleItem.info)
412380
)
413381
end
414-
415382
end
416383
local bin = ''
417384
for i = 1, byteLength do
@@ -422,58 +389,16 @@ local function getComplexServiceDataToWrite(parameterInfo, data)
422389
end
423390
converter.getComplexServiceDataToWrite = getComplexServiceDataToWrite
424391

425-
426-
427392
-------------------------------------------------------------------------------------
428-
-- Conver Lua table to a binary data for writing to IO-Link device
393+
-- Convert Lua table to a binary data for writing to IO-Link device
429394
local function getBinaryDataToWrite(dataPointInfoInfo, data)
430-
if dataPointInfoInfo.Datatype.type == 'ArrayT' or dataPointInfoInfo.Datatype.type == 'RecordT' then
395+
if dataPointInfoInfo.info.type == 'ArrayT' or dataPointInfoInfo.info.type == 'RecordT' then
431396
return getComplexServiceDataToWrite(dataPointInfoInfo, data)
432397
else
433-
return toBinaryData(dataPointInfoInfo.Datatype.type, math.ceil(getDatatypeBitlength(dataPointInfoInfo.Datatype)/8), data.value)
398+
local test = toBinaryData(dataPointInfoInfo.info.type, math.ceil(getDatatypeBitlength(dataPointInfoInfo.info)/8), data.value)
399+
return test
434400
end
435401
end
436402
converter.getBinaryDataToWrite = getBinaryDataToWrite
437403

438-
--changing ["xsi:type"] to more convenient .type key
439-
local function renameDatatype(dataPointInfo)
440-
if dataPointInfo.SimpleDatatype then
441-
dataPointInfo.Datatype = helperFuncs.copy(dataPointInfo.SimpleDatatype)
442-
dataPointInfo.SimpleDatatype = nil
443-
elseif dataPointInfo.Datatype.SimpleDatatype then
444-
dataPointInfo.Datatype.Datatype = helperFuncs.copy(dataPointInfo.Datatype.SimpleDatatype)
445-
dataPointInfo.Datatype.SimpleDatatype = nil
446-
if dataPointInfo.Datatype.Datatype["xsi:type"] then
447-
dataPointInfo.Datatype.Datatype.type = dataPointInfo.Datatype.Datatype["xsi:type"]
448-
dataPointInfo.Datatype.Datatype["xsi:type"] = nil
449-
end
450-
elseif dataPointInfo.Datatype.RecordItem then
451-
for recordItemID, recordItemInfo in ipairs(dataPointInfo.Datatype.RecordItem) do
452-
if recordItemInfo.SimpleDatatype then
453-
dataPointInfo.Datatype.RecordItem[recordItemID].Datatype = helperFuncs.copy(recordItemInfo.SimpleDatatype)
454-
dataPointInfo.Datatype.RecordItem[recordItemID].SimpleDatatype = nil
455-
if recordItemInfo.Datatype["xsi:type"] then
456-
dataPointInfo.Datatype.RecordItem[recordItemID].Datatype.type = recordItemInfo.Datatype["xsi:type"]
457-
dataPointInfo.Datatype.RecordItem[recordItemID].Datatype["xsi:type"] = nil
458-
end
459-
end
460-
end
461-
end
462-
if dataPointInfo.Datatype["xsi:type"] then
463-
dataPointInfo.Datatype.type = dataPointInfo.Datatype["xsi:type"]
464-
dataPointInfo.Datatype["xsi:type"] = nil
465-
end
466-
return dataPointInfo
467-
end
468-
converter.renameDatatype = renameDatatype
469-
470-
--changing ["xsi:type"] to more convenient .type key
471-
local function renameDatamode(dataModeTable)
472-
for dataPointID, dataPointInfo in ipairs(dataModeTable) do
473-
dataModeTable[dataPointID] = renameDatatype(dataPointInfo)
474-
end
475-
return dataModeTable
476-
end
477-
converter.renameDatamode = renameDatamode
478-
479404
return converter

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ Tested on
5959

6060
|Device|Firmware version|Module version|
6161
|--|--|--|
62+
|SIM1012|V2.4.2|V2.1.1|
6263
|SIM1012|V2.4.2|V2.1.0|
6364
|SIM1012|V2.4.2|V2.0.0|
6465
|SICK AppEngine|V1.7.0|V2.0.0|

docu/CSK_Module_MultiIOLinkSMI.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0">
77
<meta name="generator" content="Asciidoctor 2.0.12">
88
<meta name="author" content="SICK AG">
9-
<title>Documentation - CSK_Module_MultiIOLinkSMI 2.1.0</title>
9+
<title>Documentation - CSK_Module_MultiIOLinkSMI 2.1.1</title>
1010
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
1111
<style>
1212
/* Stylesheet for CodeRay to match GitHub theme | MIT License | http://foundation.zurb.com */
@@ -615,10 +615,10 @@
615615
</head>
616616
<body class="article toc2 toc-left">
617617
<div id="header">
618-
<h1>Documentation - CSK_Module_MultiIOLinkSMI 2.1.0</h1>
618+
<h1>Documentation - CSK_Module_MultiIOLinkSMI 2.1.1</h1>
619619
<div class="details">
620620
<span id="author" class="author">SICK AG</span><br>
621-
<span id="revnumber">version 2.1.0,</span>
621+
<span id="revnumber">version 2.1.1,</span>
622622
<span id="revdate">2025-01-22</span>
623623
</div>
624624
<div id="toc" class="toc2">
@@ -860,7 +860,7 @@ <h2 id="_document_metadata">Document metadata</h2>
860860
</tr>
861861
<tr>
862862
<th class="tableblock halign-left valign-top"><p class="tableblock">Version</p></th>
863-
<td class="tableblock halign-left valign-top"><p class="tableblock">2.1.0</p></td>
863+
<td class="tableblock halign-left valign-top"><p class="tableblock">2.1.1</p></td>
864864
</tr>
865865
<tr>
866866
<th class="tableblock halign-left valign-top"><p class="tableblock">Date</p></th>
@@ -10048,7 +10048,7 @@ <h6 id="_sample_auto_generated_172">Sample (auto-generated)</h6>
1004810048
</div>
1004910049
<div id="footer">
1005010050
<div id="footer-text">
10051-
Version 2.1.0<br>
10051+
Version 2.1.1<br>
1005210052
Last updated 2025-01-22 12:19:50 +0100
1005310053
</div>
1005410054
</div>

0 commit comments

Comments
 (0)