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

Writable Measurement Typed As OTT_MEASURE #8

Open
gr1pcoding opened this issue Aug 10, 2024 · 5 comments
Open

Writable Measurement Typed As OTT_MEASURE #8

gr1pcoding opened this issue Aug 10, 2024 · 5 comments

Comments

@gr1pcoding
Copy link

Thanks for the great library, super easy to use and got all the features I was interested in up and running pretty quickly.

The below if block is causing me trouble... My a2l has some writable measurement channels. I need to be able to write these via the Calibration class. When I comment out this if block, I’m able to get it working. On my setup for some reason writable measurements are showing as OTT_MEASURE, and not OTT_CALIBRATE like the API documentation says.

def _write_calibration_object_value(self, cov: TCalibrationObjectValue) -> None: if self.object_type != ObjectType.OTT_CALIBRATE: err_msg = "Cannot set value to a Measurement Object." raise TypeError(err_msg)

I am not sure if others have this same problem or if it is unique to the CANape V16 version I'm running. In any case, commenting out the if block is my only remedy at the moment so looking for a more permanent fix. To see if it would hurt anything to remove the if block for all users, I tried calibrating some read-only measurements channels and it still errors out albeit with a different exception so in my mind it still works as intended:

File "C:\bin\tool_lib\site-packages\pycanape\cnp_api\cnp_prototype.py", line 2631, in _get_last_error raise CANapeError(error_code, error_msg, function.__name__) pycanape.utils.CANapeError: Asap3WriteCalibrationObject failed (AEC_NOT_WRITE_ACCESS: Object has not write access)

Below is the a2l screenshot of the writable measurement that is showing up as OTT_MEASURE if helpful:

image

@zariiii9003
Copy link
Owner

Hi, if the object is writable, then it is a calibration object and your a2l is incorrect.
There is an ASAP2 editor in CANape, where you can convert your measurement object to a calibration object.

@gr1pcoding
Copy link
Author

gr1pcoding commented Aug 10, 2024

CANape has the option to make measurements read/write per the a2l screenshot. I don't have the capability to change them due to the auto-generation process merging a2l's from other sources outside of my control. Of course I could manually intervene to change them to calibrations every time it get re-generated I'd prefer not to have to do so!

@zariiii9003
Copy link
Owner

I checked the ASAP2 spec, you're right. Writable Measurement objects exist.
image

But the CANape documentation says this:
image
So this seems like a CANape bug...

@gr1pcoding
Copy link
Author

Yep I saw the same thing. Let me try it on a newer version of CANape first and see if it resolves. If not I can patch it myself if you're not interested in my proposed change of removing the if block

@zariiii9003
Copy link
Owner

Yep I saw the same thing. Let me try it on a newer version of CANape first and see if it resolves. If not I can patch it myself if you're not interested in my proposed change of removing the if block

Sounds good, if newer versions still behave like this, we could replace that object_type check with try-except 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants