# Reading ChunkEncoderValue from AT C5

**URL:** https://forum.commonvisionblox.com/t/reading-chunkencodervalue-from-at-c5/1398
**Category:** .Net API
**Created:** [April 26, 2021, 10:11am UTC](https://forum.commonvisionblox.com/t/reading-chunkencodervalue-from-at-c5/1398 "2021-04-26T10:11:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![kokostek](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@kokostek](https://forum.commonvisionblox.com/u/kokostek)
#### Post date: [April 26, 2021, 10:11am UTC](https://forum.commonvisionblox.com/t/reading-chunkencodervalue-from-at-c5/1398/1 "2021-04-26T10:11:57Z")

</div>

Hi! I’m trying to read `ChunkEncoderValue` node from AT C5-1280 using .NET API:

```auto
var device = DeviceFactory.Open("GenICam.vin");

var deviceModeMap = device.NodeMaps[NodeMapNames.Device];

CvbStream stream = device.Stream;
stream.Start();
try
{
    using (StreamImage image = stream.Wait())
    {
        var encoderValues = new List<long>();
        var scanLineSelector = deviceModeMap["ChunkScanLineSelector"] as IntegerNode;
        for (var scanLine = scanLineSelector.Min; scanLine <= scanLineSelector.Max; scanLine += scanLineSelector.Increment)
        {
            scanLineSelector.Value = scanLine;
            var encoderValueNode = deviceModeMap["ChunkEncoderValue"] as IntegerNode;
            encoderValues.Add(encoderValueNode.Value);
        }
    }
}
finally
{
    stream.Stop();
}

```

But accessing property `encoderValueNode.Value` throws error:

```auto
System.IO.IOException: 'IntegerNode[Std::ChunkEncoderValue]: Node is not readable.'

```

Why this node is not readable?

I can read this node using AT’s examples from `cxSupportPackage` with exactly the same camera settings.

I can read encoder value from chunk payload ([Using Chunk Mode Data with CVB.NET](https://forum.commonvisionblox.com/t/using-chunk-mode-data-with-cvb-net/333)). But I wanted to use vendor independed GenICam SFNC.

GenICam Browser is reading encoder values just fine. Seems like I’m missing something…  
 ![2021-04-26 13_22_57-GenICam Browser](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/7e6f2d3ebae5f9c8dd076af7046251df84bc7a59.png)

---

<div class="post-metadata">

### Author: ![Simon](https://yyz1.discourse-cdn.com/flex027/user_avatar/forum.commonvisionblox.com/simon/32/847_2.png) [@Simon](https://forum.commonvisionblox.com/u/Simon)
#### Post date: [April 29, 2021, 1:32pm UTC](https://forum.commonvisionblox.com/t/reading-chunkencodervalue-from-at-c5/1398/2 "2021-04-29T13:32:42Z")

</div>

Hi kokostek,

the transmission of chunk data needs to be enabled inside the GenICam.vin-driver to be available over the api.

 ![ActivatingChunkData](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/adfce60c874aabb87894bae01f3725bdeddb1628.png)

Also the “Chunk Mode” needs to be activated over the camera NodeMap:  
 ![activateChunkMode](https://canada1.discourse-cdn.com/flex027/uploads/commonvisionblox/original/1X/e448f53ce3bbe51cd243573d4c4cffee19cd6d08.png)

Than your code should be working.  
Note that transmitting chunk data might have a negative inpact on the performance.

---

<div class="post-metadata">

### Author: ![kokostek](https://avatars.discourse-cdn.com/v4/letter/k/f04885/32.png) [@kokostek](https://forum.commonvisionblox.com/u/kokostek)
#### Post date: [April 29, 2021, 2:15pm UTC](https://forum.commonvisionblox.com/t/reading-chunkencodervalue-from-at-c5/1398/3 "2021-04-29T14:15:19Z")

</div>

Hi Simon,

thanks a lot for your solution. It works fine (I didn’t test performance yet though).

I just want to add my two cents regarding using GenICam.vin driver. One can also set `AttachChunk` programmatically if she opens device using `Discover`. I myself prefer `Discover` option as it permits to select device using info like IP address, etc. (not just CVB channel number). Here is the example:

```auto
// Select device by serial number, IP address, etc...
// Selecting first device here to be short.
DiscoveryInformationList foundDevices = DeviceFactory.Discover();
var selectedDevice = foundDevices[0];

// Set CVB color format to "Raw".
// I suppose we need this when working with chunks.
selectedDevice.SetParameter("PixelFormat", "0");

// Turn on "Attach chunk" parameter, so that chunk
// nodes become readable.
selectedDevice.SetParameter("AttachChunk", "1");

// Open device and configure chunk mode.
var device = DeviceFactory.Open(selectedDevice);
var deviceNodeMap = device.NodeMaps[NodeMapNames.Device];
var chunkModeActive = deviceNodeMap["ChunkModeActive"] as IBooleanNode;
chunkModeActive.Value = true;

// Read encoder value(s) along with image.
CvbStream stream = device.Stream;
stream.Start();
try
{
    using (StreamImage image = stream.Wait())
    {
        var encoderValues = new List<long>();
        var scanLineSelector = deviceNodeMap["ChunkScanLineSelector"] as IntegerNode;
        for (var scanLine = scanLineSelector.Min; scanLine <= scanLineSelector.Max; scanLine += scanLineSelector.Increment)
        {
            scanLineSelector.Value = scanLine;
            var encoderValueNode = deviceNodeMap["ChunkEncoderValue"] as IntegerNode;
            encoderValues.Add(encoderValueNode.Value);
        }
    }
}
finally
{
    stream.Stop();
}

```

Credit to [this post](https://forum.commonvisionblox.com/t/how-to-get-cvb-color-format-programatically/767) for example of setting driver parameters.
