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

Wrong packet_duration calculation #27

Open
Larsvn opened this issue Aug 20, 2022 · 1 comment
Open

Wrong packet_duration calculation #27

Larsvn opened this issue Aug 20, 2022 · 1 comment

Comments

@Larsvn
Copy link

Larsvn commented Aug 20, 2022

Code
Consider this code fragment in your version v0.2.2:

uint8_t MSB = (Duration & 0xFF) >> 8;
uint8_t LSB = Duration & 0xFF;
// 1st bit, set 3D or Dual
if(mode == eRunMode::Mode3D) MSB |= (1 << 4);
// 2nd bit, set Auto or Fixed
if(setAutoDuration == false) MSB |= (1 << 3);

Problems

  • uint8_t MSB = (Duration & 0xFF) >> 8;
    Results in MSB = 0 at all times. So the higher part of the duration is lost.

  • bit adjustment for different modes is on wrong bits with wrong values

Suggested fixes

`
// Reset the highest two bits of Duration and mask out the lower byte,
// then shift right.
uint8_t MSB = (Duration & 0x3F00) >> 8;
uint8_t LSB = Duration & 0xFF;

// 1st bit, set 3D or Dual
if(mode == eRunMode::ModeDual) MSB |= (1 << 7);
// 2nd bit, set Auto or Fixed
if(setAutoDuration == false) MSB |= (1 << 6);
`

Referenced manual
Screenshot from this manual:
Set_3D_Pulse_Duration

@madgrizzle
Copy link

Using your method I get the correct values for duration. However, I think the param for auto is wrong (you're implementation is fine, just the documentation is wrong). They said that 0 is auto and 1 is manual when you examine the launch file, but if you set it to 0, then setAutDuration is false (conversion from 0 dec to binary is false) and therefore the bit gets set to 1.. which means fixed. Once you figured the above out and I figured out the fixed/auto, I could set the duration to a lower number (3500) and it got rid of all my floor reflections. Thank you! I didn't want to give up on this like cygbot seems to have :)

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