Use ABRM (Agnostic BootStrap Register Map) for timestamp latch - C-Style

Dear CVB team
I was looking for a solution to use TimeStamp features with a JAI GO-5100C-USB (the customer camera, I have with me a GO-5000C-USB).

JAI support advised me to use ABRM.

I first test with GenICam Browser “Device → Register Access” and it looks like we can read and write some parameters.
But the timestamp value is still empty. May be the GO-5000 in’t capable of it. I asked it to the JAI support.

I’d appreciated some help to implement the timestamp latch and timestamp read in C-Style.
Is there any code example to deal with the ABRM?
Many thanks
Jordan

Dear @jordanmoly,

please note that the context of this forum is related to Common Vision Blox. Hardware specific questions might be out of scope. For hardware related questions please contact de.support@stemmer-imaging.com.
From the manual of the GO-5000C-USB and (different manual) GO-5100C-USB you can see that there is ChunkTimestamp available only for the 5100 version. How to read chunk data there are plenty of entries in this forum for that, for example this one.
Otherwise you should be able to read the timestamp for each frame. The best option to get the correct timestamp from the camera would be using the StreamImage Class for image acquisition which will contain the camera timestamp as using “DCBinaryCommand DC_BUFFER_INFO_TIMESTAMP”.

Hello @Simon
OK, I have been advised to use the forum, sorry.
Anyway, even if I wrote my camera model, the question is about the ABRM and CVB.
We want to compare the timestamp of the image with a timestamp generated by a timestamp latch command. So the chunk data is usefull but not enought.
The timestamp latch command is available in the ABRM and it can be accessed from GenICam Browser throw Device → Register access.
My CVB question is : How I can read/write in the ABRM with the C-API of CVB.
Since I wrote the first post I think found a solution :

        // Write command, trigger timestamp latch
        __int64 adressTimeStampLatch = 0x001F8;
        __int32 command = 1;
        void * commandPtr = &command;
        cvbres_t write_res = RPWriteMem(hImg, adressTimeStampLatch, commandPtr, sizeof(__int32));

        // Read timestamp
        __int64 adressTimeStamp = 0x001F0;
        void* valuePtr = malloc(sizeof(__int64));
        cvbres_t read_res = RPReadMem(hImg, adressTimeStamp, valuePtr, sizeof(__int64));
        __int64 timestamp = *reinterpret_cast<__int64*>(valuePtr);
        free(valuePtr);

Regards,
Jordan

I know you are specifically asked for a C-API implementation, but for completeness sake here is C++ implementation using the current CVB API.

The general idea is to use the GenAPI NodeMap and CVB’s NodeMap interface for more convenient and safe (in regard to possible memory leak, access violations etc.) way of accessing these two camera registers.

First you want to get the unmodified XML from the camera. You can use the CVB tool EditBindings from %CVB%Hardware\StemmerImaging\Utilities. You can list all commands buy calling the exe with

.\EditBindings.exe --help

First use

.\EditBindings.exe --listlinks

This should show you the link ID for the camera.

You can then save the original camera XML by using

.\EditBindings.exe --exportlinkxml "8,JAIGO_original.xml"

for instance. I keep a copy of the original XML.

I raised the version number of the XML to make sure the camera will use my modified XML instead of the original one if in doubt. The version is at the beginning of the XML, line 19 in my case. The original version of my camera XML is 5. I increased it by 1.

MinorVersion="6"

You have to add the two nodes for TimeStamp and TimeStampLatch to the XML. First add them to a category as a pFeature. I’ve chosen the AcquisitionControl category here.

	<Group Comment="AcquisitionControl">
		<Category Name="AcquisitionControl" NameSpace="Standard">
			<ToolTip>Acquisition and trigger control features</ToolTip>
			<Description>Category for the acquisition and trigger control features.</Description>
			<DisplayName>Acquisition Control</DisplayName>
			<pFeature>AcquisitionMode</pFeature>
                        ...		
			<pFeature>TimeStamp</pFeature>	
			<pFeature>TimeStampLatch</pFeature>
		</Category>
    </Group>

Then add the nodes with their features. You need one command node and one integer node. Every node also has a corresponding register node.

	<Command Name="TimeStampLatch" NameSpace="Standard">
		<ToolTip>Toggles the TimestampLatch</ToolTip>
		<Description>Toggles the TimestampLatch</Description>
		<DisplayName>TimeStampLatch</DisplayName>
		<Visibility>Guru</Visibility>
		<pValue>pTimeStampLatchReg</pValue>
		<CommandValue>1</CommandValue>
	</Command>
	<IntReg Name="pTimeStampLatchReg">
		<ToolTip>Toggles the TimestampLatch</ToolTip>
		<Address>0x001F8</Address>
		<Length>2</Length>
		<AccessMode>WO</AccessMode>
		<pPort>Device</pPort>
		<Sign>Unsigned</Sign>
		<Endianess>LittleEndian</Endianess>
	</IntReg>

	<Integer Name="TimeStamp" NameSpace="Standard">
		<ToolTip>TimeStamp</ToolTip>
		<Description>TimeStamp</Description>
		<DisplayName>TimeStamp</DisplayName>
		<Visibility>Guru</Visibility>
		<pValue>pTimeStampReg</pValue>
	</Integer>
	<IntReg Name="pTimeStampReg">
		<Address>0x001F0</Address>
		<Length>4</Length>
		<AccessMode>RO</AccessMode>
		<pPort>Device</pPort>
		<pInvalidator>pTimeStampLatchReg</pInvalidator>
		<Sign>Unsigned</Sign>
		<Endianess>LittleEndian</Endianess>
	</IntReg>

After you have saved the changes to the XML you have to link it to the camera by using the EditBindings tool again.

.\EditBindings.exe --addlink "U500601,GO5000CUSB_addedTimeStampNodes.xml"

You can check if the binding has been linked by using –listlinks again. It now should show a link to the original XML that CVB has stored automatically and the new, modified XML. Since the version number of the modified XML is higher than the original one the modified XML should be used if both XML are present.

Please note that that version shown in the screenshot is the version of the firmware, not the XML file version. The version 050 is in the default name of the XML file though.

If you then access the camera via GenICam Browser for instance, you see the new nodes in the grid.

2023-07-03 15_38_14-GenICam Browser

You can then access these nodes programmatically using the C++ API. Here is a code snippet for Windows, using CVB’s 3rd gen acquisition stack.

#include <cvb/device_factory.hpp>

using namespace Cvb;


int main()
{
	const auto flags = DiscoverFlags::IgnoreGevFD | DiscoverFlags::IgnoreVins | DiscoverFlags::IgnoreGevSD;
	auto discoveryInformation = DeviceFactory::Discover(flags);
	auto& deviceInfo = discoveryInformation[0]; // The JAI GO is the only, and thus first, camera connected to my system
	auto token = deviceInfo.AccessToken();
	auto device = DeviceFactory::Open<GenICamDevice>(token, Cvb::AcquisitionStack::GenTL);
	
	auto myNodeMap = device->NodeMap("Device");
	
	myNodeMap->Node<Cvb::CommandNode>("TimeStampLatch")->Execute();
	auto timeStamp = myNodeMap->Node<Cvb::IntegerNode>("TimeStamp")->Value();
}
2 Likes

Thanks for your answer, looks great! I didn’t know it could be added to the XML this way.
I’ll test it as soon as possible.
May be an other question : Will a firmware update erase the custom xml file?

A firmware update might update the XML as well. It might also increase the XML version and CVB will then might use the newer one. Just to be sure I would download the XML from the camera again after the firmware update and add my custom nodes and increase the version.

You could check the downloaded, original XML before and after the firmware update and compare it with WinMerge or similar tools to check if there really are any changes.