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

New Phoenix Contact modbus UPS models #2856

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

RikyPlaza
Copy link
Contributor

Management of new Phoenix Contact UPS models.

…and updated upsdrv_initinfo function.

Signed-off-by: RikyPlaza <[email protected]>
…or OB, OL, CHRG and LB flags.

Signed-off-by: RikyPlaza <[email protected]>
…s for TRIO and TRIO-2G models.

Signed-off-by: RikyPlaza <[email protected]>
@AppVeyorBot
Copy link

@RikyPlaza
Copy link
Contributor Author

No idea why these errors are coming up now :(
On last PR this code was already present and no errors were raised by the compiler.

mrir(modbus_ctx, 0x0006, 1, &PartNumber2);
mrir(modbus_ctx, 0x0007, 1, &PartNumber3);
mrir(modbus_ctx, 0x0008, 1, &PartNumber4);
mrir(modbus_ctx, 0x0005, 4, &tab_reg);
Copy link
Member

Choose a reason for hiding this comment

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

Previously you were sending address of uint16_t to mrir() and now you send address of array, but the method signature seems not changed. Did you mean to read the register into just the zero'th element? Or did you drop the other 4 mrir lines by mistake?

PartNumber = (PartNumber * 65536) + PartNumber1;
PartNumber = (tab_reg[3] * 65536) + tab_reg[2];
PartNumber = (PartNumber * 65536) + tab_reg[1];
PartNumber = (PartNumber * 65536) + tab_reg[0];
Copy link
Member

Choose a reason for hiding this comment

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

Sanity check: are you sure maths are not truncated here by a 16-bit number?

What does this multiplication achieve? (A bit shift would be more idiomatic)

@AppVeyorBot
Copy link

@jimklimov
Copy link
Member

  CC       phoenixcontact_modbus.o
phoenixcontact_modbus.c: In function ‘upsdrv_updateinfo’:
phoenixcontact_modbus.c:31:28: error: overflow in conversion from ‘int’ to ‘uint16_t’ {aka ‘short unsigned int’} changes value from ‘(int)actual_code_functions2 & 262144’ to ‘0’ [-Werror=overflow]
   31 | #define CHECK_BIT(var,pos) ((var) & (1<<(pos)))
      |                            ^
phoenixcontact_modbus.c:248:30: note: in expansion of macro ‘CHECK_BIT’
  248 |                 tab_reg[1] = CHECK_BIT(actual_code_functions2, 18);
      |                              ^~~~~~~~~
  GENERATE-HEADER	nut_version.h

What is the expected value of tab_reg[1] after this - 0-or-1, or the selected bit as such?
As coded, you ask for 18th bit and save it as such into a 16-bit word...

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

Successfully merging this pull request may close these issues.

3 participants