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

Statically created object #8

Closed
wants to merge 2 commits into from
Closed

Statically created object #8

wants to merge 2 commits into from

Conversation

nqv
Copy link

@nqv nqv commented Mar 22, 2011

The patches allow using modbus_t object which created statically instead of allocating from heap.
This is done by exporting modbus initialization routines.
Usage:


#include <modbus-rtu-private.h>
static modbus_rtu_t modbus_rtu = {
       .device = MODBUS_RTU_DEV,
       .baud = MODBUS_RTU_BAUD,
       .parity = MODBUS_RTU_PARITY,
       .data_bit = MODBUS_RTU_DATA_BIT,
       .stop_bit = MODBUS_RTU_STOP_BIT,
};
static modbus_t modbus;
...
{   /* init */
    _modbus_init_rtu(&modbus, &modbus_rtu);
}

@stephane
Copy link
Owner

Your patches are interesting, I'm intend to merge this for 3.2 release

@stephane stephane closed this May 10, 2011
@stephane stephane reopened this May 10, 2011
nqv added 2 commits July 13, 2011 12:36
Allows using modbus_t object from stack. This is quite useful in
embedded systems running uClinux which may have memory fragmentation
problem by repeatly malloc.

Usage:
//#include <modbus-rtu-private.h>
static modbus_rtu_t modbus_rtu = {
  .device   = RTU_DEV,
  .baud     = RTU_BAUD,
  .parity   = RTU_PARITY,
  .data_bit = RTU_DATA_BIT,
  .stop_bit = RTU_STOP_BIT,
};
static modbus_t modbus;
...
{ /* init */
  _modbus_init_rtu(&modbus, &modbus_rtu);
}
Same reason as RTU exporting. User can use modbus_t from stack
rather than malloc.
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.

2 participants