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

LJM_ErrorToString is not consistent #4

Open
Jkillelea opened this issue Apr 14, 2023 · 1 comment
Open

LJM_ErrorToString is not consistent #4

Jkillelea opened this issue Apr 14, 2023 · 1 comment

Comments

@Jkillelea
Copy link

Hi there, I don't know if this is the best place to raise this issue, but the LJM library doesn't have available source so I'm putting this here.

The LJM_ErrorToString function does not consistently return the names of the LJME_* errors. For example, calling LJM_ErrorToString with LJME_NOERROR as an argument returns the string "LJ_SUCCESS", not the string "LJME_NOERROR". In addition, LJME_U3_NOT_SUPPORTED_BY_LJM, as well as _U6 and _U9, return strings including a description of the issue, while no other error codes do this.

@sjarman28
Copy link
Contributor

sjarman28 commented Apr 20, 2023

LJ_SUCCESS is returned because it is the error string for code 0 defined in ljm_constants. LJM_ErrorToString reads ljm_constants.json to get the error messages. You can see the ljm_constants codes in the LJM User's Guide, installed on your local machine, or in our ljm_constants repo.

I am not sure if there is a particular reason why we define 0 as LJME_NO_ERROR in the header file and not ljm_constants, but it might be most useful to say that it happened because LabJackM.h is not generating error codes using ljm_constants. We have known about this limitation, I believe we are planning to do something with it, but we do not have a solid timeline for relevant changes.

It is intentional that only some error codes display the error message. The API will only return messages for the most common or important error codes. In the past, LabJack decided to define the maximum string size LJM_MAX_NAME_SIZE as 256 characters. Some error messages could potentially exceed this size, so our options are to clip messages if they exceed the max name size, change the API to increase the maximum name size, limit all error messages to 255 characters, or do what we do now with providing a limited set of messages. We will investigate these options, but right now it is a low priority for us.

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