group login/logout on Panasonic PBX

Aug 13, 2012 at 2:24 PM


I getting problems with changing status of group login/logout of an extension.

According to Panasonic TAPI documentation it's possible to do it via DeviceSpecific functions.

I've created structure according to KT-TDA TAPI Specification:

 public struct dev_specific        {

           public  uint dwTotalSize;           public uint DwNeededSize;           public uint dwUsedSize;           public uint dwMode;           public uint dwParam1;           public uint dwParam2;           public uint dwParam3;           public uint dwNameSize;           public uint dwNameOffset;           public uint A_dw_addressSize;           public uint A_dw_AddressOffset;

then I'm setting values only for dwMode (20 for login) and dwParam2 (group 601):

(line variable is a correct tapi line)


  dev_specific dane_dopbx = new dev_specific();
  dane_dopbx.dwMode = 20; // EXT_GROUPLOGIN

dane_dopbx.dwParam2 = 601;  // group numer in my PBX

 int size = Marshal.SizeOf(dane_dopbx);                   

byte[] arr = new byte[size]; 

IntPtr ptr = Marshal.AllocHGlobal(size);

Marshal.StructureToPtr(dane_dopbx, ptr, true); 

Marshal.Copy(ptr, arr, 0, size); 

byte[] wynik = new byte[300];

wynik = line.Addresses[0].DeviceSpecific(arr);                  


but I always get error.

in EndDeviceSpecific I have req.Result = -2147483576

and then it throw exception "lineDevSpecific failed [0x80000048]"


Any idea what can be wrong?


Best regards,


Aug 17, 2012 at 6:04 PM

Two things.  First, I don't see where you are setting dwTotalSize/dwUsedSize in the structure.  Those probably needs to be set.  Second, make sure to free up the global memory after the Marshal.Copy - once it's in the byte[] you don't need the IntPtr anymore.  You could alternatively just allocate a byte[] of the appropriate size and then fill it in with the correct bits if you want to avoid all the copying.

Someone should add a generic method in for this too -- something like:

byte[] DeviceSpecific<T>(T input) where T : struct

that then does the Marshal/Copy work for you :-)  I never did that because generics didn't exist when I wrote the library.. 


Aug 20, 2012 at 8:11 AM


I've solve this problem.

Code was OK, but problem was in numbering groups in Panasonic PBX. It's not possible to use groups number like '601' or '602' (this what we dialing - Floating Extension Number) but we have to use number of groups from PBX configuration (like '1', '2' - ICD Group number). Then it's working.

I've also found a problem in atapi library when reading DeviceSpecific notifications from Panasonic PBX.

In TapiManager.cs in function ProcessTapiMessage there is a code:











TapiCall call = TapiCall.FindCallByHandle(msg.hDevice);



if (call != null)

call.Line.OnDeviceSpecific(call, msg.dwParam1, msg.dwParam2, msg.dwParam3);









goto case







Problem is that DevSpecific messages came without a activa call so it was never processed because call variable was always null.

So instead of "goto case TapiEvent.LINE_CLOSE it's neccessary to write code to get TapiLine handler to process message.


Best regards,