Skip to content

Commit

Permalink
Merge branch 'develop' into feat/antora
Browse files Browse the repository at this point in the history
  • Loading branch information
hutcheb committed Nov 10, 2024
2 parents de2de19 + a6dc647 commit 4a1b4fa
Show file tree
Hide file tree
Showing 884 changed files with 77,787 additions and 23,538 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,10 @@ func (m *_${type.name}) getLengthInBits(ctx context.Context) uint16 {

return lengthInBits
}

func (m *_${type.name}) GetLengthInBits(ctx context.Context) uint16 {
return m._SubType.GetLengthInBits(ctx)
}
</#if>

func (m *_${type.name}) GetLengthInBytes(ctx context.Context) uint16 {
Expand Down
12 changes: 12 additions & 0 deletions plc4go/assets/testing/protocols/ads/DriverTestsuite.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,18 @@
</PlcResponseItem>
</hurz>
</values>
<metadata isList="true">
<hurz>
<entry>
<key dataType="string" bitLength="17" encoding="UTF-8">receive_timestamp</key>
<value dataType="string" bitLength="13" encoding="UTF-8" plc4x-skip-comparison="true">0</value>
</entry>
<entry>
<key dataType="string" bitLength="16" encoding="UTF-8">timestamp_source</key>
<value dataType="string" bitLength="10" encoding="UTF-8">ASSUMPTION</value>
</entry>
</hurz>
</metadata>
</PlcReadResponse>
</api-response>
</steps>
Expand Down
2,081 changes: 2,014 additions & 67 deletions plc4go/assets/testing/protocols/opcua/DriverTestsuite.xml

Large diffs are not rendered by default.

32 changes: 16 additions & 16 deletions plc4go/assets/testing/protocols/opcua/ParserSerializerTestsuite.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ https://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<test:testsuite xmlns:test="https://plc4x.apache.org/schemas/parser-serializer-testsuite.xsd"
byteOrder="LITTLE_ENDIAN">
Expand Down
4 changes: 2 additions & 2 deletions plc4go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ require (
github.com/subchen/go-xmldom v1.1.2
github.com/viney-shih/go-lock v1.1.2
golang.org/x/net v0.30.0
golang.org/x/text v0.19.0
golang.org/x/text v0.20.0
golang.org/x/tools v0.26.0
)

Expand All @@ -51,7 +51,7 @@ require (
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/stretchr/objx v0.5.2 // indirect
golang.org/x/mod v0.21.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sync v0.9.0 // indirect
golang.org/x/sys v0.26.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
8 changes: 4 additions & 4 deletions plc4go/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ golang.org/x/mod v0.21.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
golang.org/x/net v0.30.0 h1:AcW1SDZMkb8IpzCdQUaIq2sP4sZ4zw+55h6ynffypl4=
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.26.0 h1:KHjCJyddX0LoSTb3J+vWpupP9p0oznkqVk/IfjymZbo=
golang.org/x/sys v0.26.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.19.0 h1:kTxAhCbGbxhK0IwgSKiMO5awPoDQ0RpfiVYBfK860YM=
golang.org/x/text v0.19.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
golang.org/x/text v0.20.0 h1:gK/Kv2otX8gz+wn7Rmb3vT96ZwuoxnQlY+HlJVj7Qug=
golang.org/x/text v0.20.0/go.mod h1:D4IsuqiFMhST5bX19pQ9ikHC2GsaKyk/oF+pn3ducp4=
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
4 changes: 2 additions & 2 deletions plc4go/internal/opcua/EncryptionHandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (h *EncryptionHandler) encodeMessage(ctx context.Context, pdu readWriteMode
numberOfBlocks := preEncryptedLength / PREENCRYPTED_BLOCK_LENGTH
encryptedLength := numberOfBlocks*256 + positionFirstBlock
buf := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
if err := readWriteModel.NewOpcuaAPU(pdu, false).SerializeWithWriteBuffer(ctx, buf); err != nil {
if err := readWriteModel.NewOpcuaAPU(pdu, false, true).SerializeWithWriteBuffer(ctx, buf); err != nil {
return nil, errors.Wrap(err, "error serializing")
}
paddingByte := byte(paddingSize)
Expand Down Expand Up @@ -168,7 +168,7 @@ func (h *EncryptionHandler) decodeMessage(ctx context.Context, pdu readWriteMode
}

readBuffer := utils.NewReadBufferByteBased(buf.GetBytes(), utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
return readWriteModel.OpcuaAPUParseWithBuffer(ctx, readBuffer, true)
return readWriteModel.OpcuaAPUParseWithBuffer(ctx, readBuffer, true, true)
default:
h.log.Trace().Msg("unmapped security policy")
return pdu, nil
Expand Down
4 changes: 2 additions & 2 deletions plc4go/internal/opcua/MessageCodec.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (m *MessageCodec) Send(message spi.Message) error {
opcuaApu, ok := message.(readWriteModel.OpcuaAPU)
if !ok {
if message, ok := message.(readWriteModel.MessagePDU); ok {
opcuaApu = readWriteModel.NewOpcuaAPU(message, false)
opcuaApu = readWriteModel.NewOpcuaAPU(message, false, true)
} else {
return errors.Errorf("Invalid message type %T", message)
}
Expand Down Expand Up @@ -124,7 +124,7 @@ func (m *MessageCodec) Receive() (spi.Message, error) {
}
ctxForModel := options.GetLoggerContextForModel(context.Background(), m.log, options.WithPassLoggerToModel(m.passLogToModel))
rbbb := utils.NewReadBufferByteBased(readBytes, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian))
opcuaAPU, err := readWriteModel.OpcuaAPUParseWithBuffer(ctxForModel, rbbb, true)
opcuaAPU, err := readWriteModel.OpcuaAPUParseWithBuffer(ctxForModel, rbbb, true, true)
if err != nil {
return nil, errors.New("Could not parse pdu")
}
Expand Down
21 changes: 5 additions & 16 deletions plc4go/internal/opcua/Reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"context"
"encoding/binary"
"runtime/debug"
"strconv"

"github.com/pkg/errors"
"github.com/rs/zerolog"
Expand Down Expand Up @@ -73,7 +72,7 @@ func (m *Reader) readSync(ctx context.Context, readRequest apiModel.PlcReadReque
REQUEST_TIMEOUT_LONG,
NULL_EXTENSION_OBJECT,
)
readValueArray := make([]readWriteModel.ExtensionObjectDefinition, len(readRequest.GetTagNames()))
readValueArray := make([]readWriteModel.ReadValueId, len(readRequest.GetTagNames()))
for i, tagName := range readRequest.GetTagNames() {
tag := readRequest.GetTag(tagName).(Tag)

Expand All @@ -94,35 +93,25 @@ func (m *Reader) readSync(ctx context.Context, readRequest apiModel.PlcReadReque
requestHeader,
0.0,
readWriteModel.TimestampsToReturn_timestampsToReturnNeither,
int32(len(readValueArray)),
readValueArray)

identifier, err := strconv.ParseUint(opcuaReadRequest.GetIdentifier(), 10, 16)
if err != nil {
result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrapf(err, "error parsing identifier"))
return
}

identifier := opcuaReadRequest.GetExtensionId()
expandedNodeId := readWriteModel.NewExpandedNodeId(false, //Namespace Uri Specified
false, //Server Index Specified
readWriteModel.NewNodeIdFourByte(0, uint16(identifier)),
nil,
nil)

extObject := readWriteModel.NewExtensionObject(
expandedNodeId,
nil,
opcuaReadRequest,
false)
extObject := readWriteModel.NewExtensiblePayload(nil, readWriteModel.NewRootExtensionObject(expandedNodeId, opcuaReadRequest, identifier), 0)

buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
if err = extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil {
if err := extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil {
result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrapf(err, "Unable to serialise the ReadRequest"))
return
}

consumer := func(opcuaResponse []byte) {
reply, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false)
reply, err := readWriteModel.ExtensionObjectParseWithBuffer[readWriteModel.ExtensionObject](ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false)
if err != nil {
result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrapf(err, "Unable to read the reply"))
return
Expand Down
Loading

0 comments on commit 4a1b4fa

Please sign in to comment.