Hosting multiple clients with freemodbus

If you have a limit on the number of modbus clients then dropping old connections when a new one arrives is actually suggested in the modbus implementation guide (https://www.modbus.org/docs/Modbus_Messaging_Implementation_Guide_V1_0b.pdf) Nevertheless a mechanism must be implemented in case of exceeding the number of authorized connection. In such a case we recommend to close the oldest unused … Read more

Looking for an efficient integer square root algorithm for ARM Thumb2

Integer Square Roots by Jack W. Crenshaw could be useful as another reference. The C Snippets Archive also has an integer square root implementation. This one goes beyond just the integer result, and calculates extra fractional (fixed-point) bits of the answer. (Update: unfortunately, the C snippets archive is now defunct. The link points to the … Read more

Static allocation of opaque data types

You can use the _alloca function. I believe that it’s not exactly Standard, but as far as I know, nearly all common compilers implement it. When you use it as a default argument, it allocates off the caller’s stack. // Header typedef struct {} something; size_t get_size(); something* create_something(void* mem); // Usage something* ptr = … Read more

Embedded C++ : to use exceptions or not?

In terms of performance, my understanding is that exceptions actually reduce the size and increase the performance of the normal execution paths of code, but make the exceptional/error paths more expensive. (often a lot more expensive). So if your only concern is performance, I would say don’t worry about later. If today’s CPU can handle … Read more

How to determine maximum stack usage in embedded system with gcc?

GCC docs : -fstack-usage Makes the compiler output stack usage information for the program, on a per-function basis. The filename for the dump is made by appending .su to the auxname. auxname is generated from the name of the output file, if explicitly specified and it is not an executable, otherwise it is the basename … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)