Experimental Physics and
| |||||||||||||||||
|
we run into similar problems at the SLS recently. The problem is the difference between how we think array support should work and how it is actually implemented. All EPICS records which deal with arrays always copy buffers. Manipulating pointers is not supported! That means: Do not modify pwf->bptr. It simply does not do what you would expect. Reason: The value of pwf->bptr is read by channel access on connect only. Thus reading the same record multiple times (get or monitor) from the same application always reads the same buffer. Modifications of pwf->bptr after the client has connected have no effect. Thus, touching pwf->bptr after record initialization must be considered illegal. You have to copy buffers instead of moving pointers. Pointing pwf->bptr to a local variable as in your code is even worse. long BUFFER[10000] exists on the stack only and is vanishes as soon as read_wf() finishes. Thus giving a pointer to BUFFER to the outside world is generally illegal in C, not only in EPICS. I can't see why you did this. pwf->bptr is already pointing to a buffer of NELM longs. The record has set up the buffer for you. In your case, 10000 is probably the better value for NELM. Don't forget to check NELM in your code before looping to 10000 to avoid array bounds violations. You can also get a stack overflow on embedded systems like vxWorks when you use huge local arrays variables. Never do that. A similar thing happens inside subArray. The record first copies all input into is own buffer (instead of just looking at a pointer). For that, it needs enough bufferspace for the whole input, not only for its own region of interest. Thus, MALM must be the same size as the record INP is pointing to, 5000 (or 10000?) in your case. Then, subArray copies the interesting part into yet another buffer because of the way channel access only reads the bptr when connecting. All in all a huge waste of performance, but that's how it is at the moment. Dirk Zhichu Chen wrote: Hi,
| ||||||||||||||||
ANJ, 02 Sep 2010 |
·
Home
·
News
·
About
·
Base
·
Modules
·
Extensions
·
Distributions
·
Download
·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing · |