Upgrade 3CX to v18 and get it hosted free!

Zaptel Timer Interface

Author image

Purpose of interface

The Zaptel timer is used by userspace applications to ensure timing when using zaptel channels. The timer is normally tied to the hardware interrupts generated by the communication device.

How the timer is implemented in the kernel

The timer period is configured via an ioctl() call. Each time the master span calls zt_receive() to send zaptel a chunk of incoming data, zaptel decrements the timer counter by ZT_CHUNKSIZE (usually 8). For many cards, this happens for each interrupt event. When the timer counter reaches zero, it is considered to be “tripped”. Once tripped, a process polling the file descriptor will awaken.

ioctl() interface

 

ZT_TIMER_CONFIG
Set the period of the zaptel timer, in number of bytes

 

ZT_TIMERCONFIG
Set the period of the zaptel timer, in number of bytes

 

ZT_TIMERACK
Decrements the “tripped” counter by the specified value

 

ZT_GETEVENT
Get the current event state, one of:
    • ZT_EVENT_NONE: Nothing happened
    • ZT_EVENT_TIMER_EXPIRED: timer->tripped > 0, meaning the timer expired and has not been ACKed yet.
    • ZT_EVENT_TIMER_PING : timer->ping > 0

 

ZT_TIMERPING
Sets timer->ping = 1

 

ZT_TIMERPONG
Sets timer->ping = 0

select()/poll() interface

The kernel select()/poll() interface reports events based on the internal “tripped” and “ping” conditions. In other words, when the timer expires or when it is pinged via ZT_TIMERPING.

Usage

In its simplest form, you can just use the ZT_TIMERCONFIG and ZT_TIMERACK commands. You configure the period, call select() on the timer device, and ACK it when you get an event. See timertest.c included with zaptel for an example of this.

The ping/pong interface is a more recent addition to the zaptel timer. Asterisk uses this in channel.c.


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.