Vrekrer_scpi_parser icon indicating copy to clipboard operation
Vrekrer_scpi_parser copied to clipboard

overflow errors

Open Steffen-W opened this issue 1 year ago • 8 comments

Hi @Vrekrer, i have been searching for a very long time for an error that was due to an overflow. Can you perhaps issue a message when an overflow occurs? That would be extremely useful.

Steffen-W avatar Jan 16 '25 11:01 Steffen-W

It would at least be extremely helpful to have a function that can be used to check whether one of the following variables is true.

  struct internal_errors {
    //Command storage overflow error
    bool command_overflow = false;
    //Token storage overflow error
    bool token_overflow = false;
    //Branch (SCPI_Commands) storage overflow error
    bool branch_overflow = false;
    //Special command storage overflow error
    bool special_command_overflow = false;
  } setup_errors;

Steffen-W avatar Jan 16 '25 11:01 Steffen-W

Hi Steffen

Have you tried the error handling example?

You can access that variables using my_instrument.last_error this property will return a SCPI_Parser::ErrorCode enum with the last error.

You can also set a special function my_instrument.SetErrorHandler(&myErrorHandler) that will be called every time a communication error is detected.

Vrekrer avatar Jan 16 '25 11:01 Vrekrer

I think your project is great. No, I somehow overlooked it. Many thanks for the quick reply. That helps me.

Steffen-W avatar Jan 16 '25 12:01 Steffen-W

Hi, the example is great. Unfortunately, it didn't help in my case. My problem was that I had loaded more commands into the class than there was room for. This resulted in a bad run, which is also handled internally. Unfortunately, I wondered for a long time why some commands didn't work.

Apart from that, I think your code is really great!

Steffen-W avatar Jan 16 '25 12:01 Steffen-W

Hi.

You can increase the number of commands. Look at the Configuration options example.

The default number of commands is for low-RAM processors, such as Arduino.

Vrekrer avatar Jan 16 '25 14:01 Vrekrer

Hi,

I did that but only after I had found the problem. That's why I would have liked it if I could have simply called up the overflow in a function. According to the motto there is an error or not.

Steffen-W avatar Jan 16 '25 15:01 Steffen-W

That is a good idea. I will add an status to the library class and try to report class errors there.

Vrekrer avatar Jan 16 '25 15:01 Vrekrer

Something along the lines of buffer_ok() which then outputs true if there is no overflow, you could very well check this once after initialization, then you won't be surprised if there are errors.

Steffen-W avatar Jan 16 '25 17:01 Steffen-W