Using Perimeter Detect

No apologies required. We are hear to help !

Hi,
do you have any news about some applications notes release for perimeter detect?
Thanks by advance :slight_smile:

Hi

Putting together a general use case app note always takes longer than a specific use case, so sorry for the delay. We should having something up next week.

If you have a specific use case and need answers now then please contact us here

Ok cool, I will wait!
Thx :slight_smile:

From the initial specs I read “Optional accelerometer detects shock and orientation change events”. How can I use acceleromoter? Is this one of the two perimeters loops? What means optional? I am interested in ZYMKEY 4i.
Thanks.

If you bought the Zymkey 4i, the accellerometer comes as standard.

You will find details of how to use the accellerometer in the documentation, here: API Documentation

zymkey 4i 3i feature matrix 1707

Thanks, I understand acceleremeter is device integrated and doesn’t use(occupies) any of the two perimeter loop circuits
.
From introduction I also read “Power rail monitor detects anomolies like brown-out events”. I can not find any reference in the API documentation, can you tell me where to read about? Is this the mechanism used by perimeter loop system or something I can check from the API?

Your Zymkey contains three different layers of Tamper Detection. Each operates independent of the other:

  1. Accellerometer - accessible through API
  2. Perimeter detection loops x 2 - accessible through API
  3. Power rail monitor - for internal defense only. NOT accessible through the API

While waiting for the sample app, if USB is open (nothing connected) and run a script with these commands, should event happen?:
zymkey.client.clear_perimeter_detect_info()
zymkey.client.wait_for_perimeter_event ()

I forgot to configure notification:
zymkey.client.set_perimeter_event_actions ( channel = 1, action_notify = True , action_self_destruct = False )

Happy to hear you found the solution.

Hi

it’s me again, for few questions.

I am trying to execute a periodic check of the PERIM1 circuit.
The code below works well during first rounds, but suddenly the breach action is not anymore detected.
After few minutes, it start to work well again, etc. If I reboot the pi, the code will works directly (during few rounds again).

I simply connect a USB cable with white and black wires connected, and make them touch themselves during the tests. I can’t see anything wrong in /var/log/syslog.

Is this my routine code which is not the best way to check the perimeter loop? Why is my zymkey just “stop to work” during few minutes? Should I use “zkWaitForPerimeterEvent(ctx, 0);” ?

By the way, in the code below the “num_timestamps” value is ALWAYS equal to “2”. Why 2 whereas I only set an action for the PERIM1 circuit and not PERIM2?

Thx by advance.

int num_timestamps = 0;
uint32_t *tab_event;
zkCTX ctx;

if(zkOpen(&ctx) <0)
{
	printf("Unable to setup RTC module\n");
	return 0;
}
zkSetPerimeterEventAction(ctx, 0, ZK_PERIMETER_EVENT_ACTION_NOTIFY);

while(1)
{
	/*
	 *	do_something
	 */ 

	zkGetPerimeterDetectInfo(ctx, &tab_event, &num_timestamps);
	if(num_timestamps > 0)
	{
		printf("num timestamp = %d\n", num_timestamps);
		printf("Last event = %ld\n", tab_event[0]);
		zkLEDFlash(ctx, 500, 500, 4);
		zkClearPerimeterDetectEvents(ctx);
		num_timestamps = 0;
	}

	delay(1000);
}

I just tried to test the zkWaitForPerimeterEvent function but this is quite the same: works well during the first rounds, but just “failed” suddenly: no flash anymore, not even detection of a perimeter wire breach :frowning:

Hi @Tgratier,

Sorry it took so long for me to get back to you. Unfortunately, you have come across a bug with our host side software. This bug causes the Zymkey to be unresponsive for 5 minutes after a 10 minute period. In other words, the Zymkey will respond to commands for 10 minutes, then become unresponsive for 5 minutes, and then the cycle repeats.

We releasing an update to our Zymkey repository this Friday. Sorry for the inconvenience.

To answer your other question, the total number of timestamps returned from zkGetPerimeterDetectInfo corresponds to the total number of perimeter detect circuits. Since Zymkey 4i has 2 perimeter detect circuits, zkGetPerimeterDetectInfo will always return 2 for num_timestamps, regardless of whether an action has been set for a given perimeter detect input.

Ok cool! Thx for your answer (one more time).

By the way, where can we check each time you update on the repository? Just in visiting https://s3.amazonaws.com/zk-sw-repo/ ?

@Tgratier The latest is up there now.

ok thx.

I just made the update with:
sudo apt-get update
then
sudo apt-get install libzk libzymkeyssl zkbootrtc zkifc zkapputilslib
and it well upgraded the 5 items, then I reboot the pi.

I am sorry to tell you that I still have a strange behavior.
It still works during the first rounds, like just during 30seconds of tests (by the way the led of the Zymkey doesn’t work anymore too during this period). If I reboot the pi it will works properly immediately after I executed the code.

I know in “real life” that my “security routine” should be to quit my software at the first breach detection. But I must proceed to a lot of tests, so that’s why I am trying to use the zkClearPerimeterDetectEvents function.

@Tgratier,

I’m not sure what is going on here. We have not seen this issue in our validation testing. However, we will run through some test code that looks similar to yours early next week.

In the meantime, I think the best way to check the perimeter detect would look something like this:

int num_timestamps = 0;
uint32_t *tab_event;
zkCTX ctx;

if(zkOpen(&ctx) <0)
{
	printf("Unable to setup RTC module\n");
	return 0;
}
zkSetPerimeterEventAction(ctx, 0, ZK_PERIMETER_EVENT_ACTION_NOTIFY);

while(1)
{
	/*
	 *	do_something
	 */ 

	int res = zkWaitForPerimeterEvent(ctx, 1000);
	if (!res)
	{
		zkGetPerimeterDetectInfo(ctx, &tab_event, &num_timestamps);
		if (tab_event[0])
		{
			printf("num timestamp = %d\n", num_timestamps);
			printf("Last event = %ld\n", tab_event[0]);
			zkLEDFlash(ctx, 500, 500, 4);
			zkClearPerimeterDetectEvents(ctx);
		}
	}
}

Could you please try this code and see if it works better for you?