Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(plc4go): Implementing the correct reading of BOOL types #545

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

hongjinlin
Copy link
Contributor

Implemented according to Cleanup of how we handle all the bit-related fields

Thanks for reviewing the code.

@sruehl sruehl requested a review from chrisdutz October 13, 2022 07:41
Copy link
Contributor

@chrisdutz chrisdutz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing: A coil is a single value boolean ... not sure how an offset makes sense here?

@chrisdutz
Copy link
Contributor

Guess I'll have to fully review this next week (Currently travelling) ... also would I like to continue the discussion on the list on if my proposal even makes sense ... cause I think we never finished that discussion. I probably should have marked that document as Work In Progress.
Thing is ... I think the general notation used in many places would have more been something like BOOL[5..10] or so ...

@chrisdutz
Copy link
Contributor

Hi,
sorry for coming late to the party ... was insanely busy on my side and I just came back from a holiday break, going through the open Pull Requests.

Could you please update your PR? I'd love to finialize it and merge it as soon as possible.

Chris

@hongjinlin
Copy link
Contributor Author

Hi Chris, welcome back.
Did you mean to let me update PR for being merged smoothly or update for other things?
But whatever update is needed will be a few days away, as I'm on day two of Covid-19.

@hongjinlin
Copy link
Contributor Author

hongjinlin commented Jan 7, 2023

@chrisdutz
Hi Chris,

I have updated it, and have a commit(17d7f76) about it, please review it when you have time.

Jinlin

@@ -31,7 +31,7 @@ func main() {
drivers.RegisterModbusTcpDriver(driverManager)

// Get a connection to a remote PLC
crc := driverManager.GetConnection("modbus-tcp://192.168.23.30")
crc := driverManager.GetConnection("modbus-tcp://192.168.10.180")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably externalize this because every one is probably going to have the device at a different IP

value, _valueErr := readBuffer.ReadBit("value")
if _valueErr != nil {
return nil, errors.Wrap(_valueErr, "Error parsing 'value' field")
_numberOfValues := uint16(math.Ceil(float64((offset + numberOfValues)) / float64(16)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this branch "numberOfValues" is always 1

@@ -24,30 +24,48 @@ import (
"github.com/apache/plc4x/plc4go/spi/utils"
"github.com/apache/plc4x/plc4go/spi/values"
"github.com/pkg/errors"
"math"
)

// Code generated by code-generation. DO NOT EDIT.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope you read this line and didn't manually edit this file ... because the next time you'll run the full maven build these changes are going to be replaced with the old values.

@@ -40,7 +40,7 @@ func (m ModbusParserHelper) Parse(typeName string, arguments []string, io utils.
if err != nil {
return nil, errors.Wrap(err, "Error parsing")
}
return model.DataItemParse(io, dataType, numberOfValues)
return model.DataItemParse(io, dataType, numberOfValues, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generated file and will be replaced by an updated version, effectively reverting your changes the next time "mvn install" is executed in the parent.

@@ -51,7 +51,7 @@ func (m ModbusXmlParserHelper) Parse(typeName string, xmlString string, parserAr
return nil, err
}
numberOfValues := uint16(parsedUint1)
return model.DataItemParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), dataType, numberOfValues)
return model.DataItemParse(utils.NewXmlReadBuffer(strings.NewReader(xmlString)), dataType, numberOfValues, 0)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generated file and will be replaced by an updated version, effectively reverting your changes the next time "mvn install" is executed in the parent.

@chrisdutz
Copy link
Contributor

In general, the changes look good, however you manually seem to have edited generated code, so the changes will get lost the next time the maven build is executed.

@hongjinlin
Copy link
Contributor Author

In general, the changes look good, however you manually seem to have edited generated code, so the changes will get lost the next time the maven build is executed.

Hi Chris,

Thank you very much for reviewing the code. I have a revert commit(8a793e2) of this commit(17d7f76) after Ben remind me that the Golang build failed after my push, sorry for that. The reason the Golang build failed is just what you said I edited generated file directly.
But don’t worry I will be familiar with the code generation and have a PR for that as soon as possible.

Jinlin

@chrisdutz
Copy link
Contributor

Always happy to help educate :-)

@sruehl
Copy link
Contributor

sruehl commented Sep 25, 2023

@chrisdutz @hongjinlin as far as I can see this PR was ready to be merged? Seems then only a merge/rebase might be necessary.

@chrisdutz
Copy link
Contributor

No objections to merging

@sruehl
Copy link
Contributor

sruehl commented Sep 25, 2023

@hongjinlin can you merge main into this branch or rebase?

@ottlukas ottlukas added the go Pull requests that update Go code label Apr 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
go Pull requests that update Go code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants