Comments (4)
I had a simmilar requirement. Here what I added to the stack:
I replaced pf_cpm_put_buf as follows:
`
static void pf_cpm_put_buf(
pnet_t *net,
pf_iocr_t *p_iocr,
os_buf_t **pp_buf)
{
pf_cpm_t *p_cpm = &p_iocr->cpm;
pf_iodata_object_t *p_iodata;
const uint8_t *p_old_buffer;
const uint8_t *p_new_buffer;
size_t ix;
void *p;
os_mutex_lock(net->cpm_buf_lock);
p = p_cpm->p_buffer_cpm;
p_cpm->p_buffer_cpm = *pp_buf;
*pp_buf = p;
if ((net->fspm_cfg.change_cb != NULL) &&
(pp_buf != NULL))
{
/ get pointer to new data buffer /
p_new_buffer = &((uint8_t)(p_cpm->p_buffer_cpm->payload))[p_cpm->buffer_pos];
/* get pointer to old data buffer */
if ((p_cpm->new_buf == TRUE) || (p_cpm->p_buffer_app == NULL))
{
p_old_buffer = &((uint8_t*)((*pp_buf)->payload))[p_cpm->buffer_pos];
} else
{
p_old_buffer = &((uint8_t*)(p_cpm->p_buffer_app->payload))[p_cpm->buffer_pos];
}
/* compare content */
for (ix = 0u; ix < p_iocr->nbr_data_desc; ix++)
{
p_iodata = &p_iocr->data_desc[ix];
if ((p_iodata->in_use == TRUE) &&
(p_iodata->data_length > 0) &&
(memcmp (&p_new_buffer[p_iodata->data_offset],
&p_old_buffer[p_iodata->data_offset],
p_iodata->data_length) != 0))
{
/* call callback */
net->fspm_cfg.change_cb (net, net->fspm_cfg.cb_arg, p_iodata->api_id,
p_iodata->slot_nbr, p_iodata->subslot_nbr);
}
}
}
p_cpm->new_buf = TRUE;
os_mutex_unlock(net->cpm_buf_lock);
}
`
In pf_cpm_c_data_ind I call the replaced function now as follows:
pf_cpm_put_buf(net, p_iocr, &p_buf);
In pf_cpm_t I redefined p_buffer_app and p_buffer_cpm as os_buf_t* instead void*.
In pnet_cfg_t I added a new call back:
pnet_change_ind change_cb;
with
typedef int (*pnet_change_ind)( pnet_t *net, void *arg, uint32_t api, uint16_t slot, uint16_t subslot);
In my application I set a flag in the callback function that is handled later on.
from p-net.
An additional comment: Some callback functions have the parameter api defined as uint16_t, some as uint32_t. I would say, all should be uint32_t.
from p-net.
Thanks for your feedback. We will put it in the backlog.
(According to the standard 5.2.4.1 Coding of the field API = Unsigned32)
from p-net.
Thanks for your very valuable feedback, as always @Svenson12 ! Please review #113
from p-net.
Related Issues (20)
- Error class: 0xfd Real-Time Acyclic Protocol; Error code: 0x24 Not decoded
- Where to save the pf_test . folder HOT 2
- Using wlan0 as network interface doesn't work
- Sending a bunch of bytes of data to plc HOT 2
- closed
- pnet_get_station_name function need HOT 1
- Pnet port for rt-kernel by-passes lwip locking
- Feature request - IM5
- Feature request - Startup Mode Legacy
- Question - How to read/write multiple modules/submodules which have the same structure? HOT 3
- Possible issue: incorrect decoding of DCE/RPC lookup request HOT 1
- IM Data Cannot Set HOT 1
- buffer overflow bug when run `./pn_dev`
- build fail: use openwrt-22.03.3 toolchain for arm64
- Some PLCS cannot use GSD configuration
- Failing Behavior - Scenario 8 in newest ART release 2.44.1.2 Multiple AR Establishment Test HOT 3
- link in readme.md is broken HOT 3
- Question: Gathering Data From Profinet PLC's HOT 2
- MRP and Profisafe HOT 1
- Minimal C source code and Makefile
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from p-net.