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

mysterious code #4705

Closed
Mondeo20 opened this issue Dec 21, 2018 · 3 comments
Closed

mysterious code #4705

Mondeo20 opened this issue Dec 21, 2018 · 3 comments
Labels
invalid Result - Issue not related to Tasmota

Comments

@Mondeo20
Copy link

Sorry if I'm back again, but I asked for 3 code mysteries which one is solved now. The other are still open from my point of view:

  1. in xdrv_19_ps16dz_dimmer.ino
    if (ps16dz_byte_counter || (!ps16dz_byte_counter && serial_in_byte == 'A')); <------
    ps16dz_rx_buffer[ps16dz_byte_counter++] = serial_in_byte;

The semicolon after the id statement lead to the situation that the if statement will never used means the next line will always executed. If this is true I would propose to comment out the if statement to have clean code!

  1. in xsns_05_ds18x20.ino
    for (ds18x20_sensors = 0; ds18x20_sensors < DS18X20_MAX_SENSORS; ds18x20_sensors) {
    ^----------
    Loop counter are never changed which can led to a endless loop!
@arendst
Copy link
Owner

arendst commented Dec 21, 2018

I'm not the owner of the ps16dz dimmer driver but he may think you're right ;-)

Regarding xsns_05_ds18x20 I was wondering too until you start to search for somethin like

      ds18x20_sensors++;

which happen to be present at line 278.

The break at 266 will stop the loop.

@ascillato2 ascillato2 added the invalid Result - Issue not related to Tasmota label Dec 21, 2018
Repository owner locked as spam and limited conversation to collaborators Dec 21, 2018
Repository owner deleted a comment from ascillato Dec 21, 2018
Repository owner unlocked this conversation Dec 21, 2018
@Mondeo20
Copy link
Author

Yes could be, but is from my point of view a not good style. But anyhow, I removed the module from the software because I only need a basic version for my sockets and there was only the wireless code bug important to me which you have already fixed now.

@chaosmaster
Copy link
Contributor

chaosmaster commented Dec 23, 2018

@Mondeo20

1. in  xdrv_19_ps16dz_dimmer.ino
   if (ps16dz_byte_counter || (!ps16dz_byte_counter && serial_in_byte == 'A')); <------
   ps16dz_rx_buffer[ps16dz_byte_counter++] = serial_in_byte;

The semicolon after the id statement lead to the situation that the if statement will never used means the next line will always executed. If this is true I would propose to comment out the if statement to have clean code!

Good catch!
That statement is supposed to make sure commands always start with "A"
The PS-16-DZ uses "AT+"-style commands.
I created a PR with a fix (#4720).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Result - Issue not related to Tasmota
Projects
None yet
Development

No branches or pull requests

4 participants