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

Attempting read from D registers elicits Invalid reading area #23

Open
Oskee-Wow-Wow opened this issue May 29, 2024 · 2 comments
Open

Comments

@Oskee-Wow-Wow
Copy link

Hello,
Using libfins to read registers from an Omron CJ2m-CPU31.
When I attempt to read any Data registers (Dnnnnn) I get an invalid read area returned... e.g.

uint16_t arr[2048];
int num = 16;
int read_ret;

memset(&arr, 0, sizeof(arr));
read_ret = finslib_memory_area_read_uint16(sys, "D00100", arr, num);

Perhaps something is not initialized correctly? Or I don't fully understand the D registers...

Rgds.

@Oskee-Wow-Wow
Copy link
Author

Oskee-Wow-Wow commented Jun 1, 2024

Let me answer my own question in case someone else comes across this --

in fins_search.c the "D"ata registers are expected to be labeled "DM" (Data Memory).
so, for my part as the end-users will follow the vendors documentation to enter the register addresses, I copied the three "DM" lines and updated to allow "D" registers -- that is:

`

    { FINS_MODE_CS, "DM",  1,    1,      0x02,      0,   32767, 0x000000, 0x7FFF0F,  FI_RD | FI_WR           | FI_MRD,                            false },

    { FINS_MODE_CS, "DM",  16,   2,      0x82,      0,   32767, 0x000000, 0x7FFF00,  FI_RD | FI_WR | FI_FILL | FI_MRD | FI_TRS | FI_TRD,          false },

    { FINS_MODE_CS, "D",   1,    1,      0x02,      0,   32767, 0x000000, 0x7FFF0F,  FI_RD | FI_WR           | FI_MRD,                            false },

    { FINS_MODE_CS, "D",   16,   2,      0x82,      0,   32767, 0x000000, 0x7FFF00,  FI_RD | FI_WR | FI_FILL | FI_MRD | FI_TRS | FI_TRD,          false },

    { FINS_MODE_CV, "DM",  16,   2,      0x82,      0,   32767, 0x000000, 0x7FFF00,  FI_RD | FI_WR | FI_FILL | FI_MRD | FI_TRS | FI_TRD,          false },

    { FINS_MODE_CV, "D",   16,   2,      0x82,      0,   32767, 0x000000, 0x7FFF00,  FI_RD | FI_WR | FI_FILL | FI_MRD | FI_TRS | FI_TRD,          false },

`

@lammertb
Copy link
Owner

lammertb commented Jun 1, 2024

Copy code around by making redundant multiple lines to reference the same memory areas is not a fix, nor helpful to others, but rather an attempt to make a mess of the code.
Creating a pull request with proper documentation might have been more helpful.

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

No branches or pull requests

2 participants