markjulmar / atapi.net Goto Github PK
View Code? Open in Web Editor NEWManaged library for TAPI development with .NET
Home Page: http://www.julmar.com
License: MIT License
Managed library for TAPI development with .NET
Home Page: http://www.julmar.com
License: MIT License
Hi, I am working using the atapi 64 bit dll and using it to query the CUCM 11.5 system for lines. However, I only see the lines associated with Cisco devices, not SIP devices. Any ideas why this maybe?
My configuration settings in the CUCM admin part is exactly the same for all 3 devices and my SIP Device can "talk" and "call" the other devices OK. I have associated a line, device and unique user to the SIP device, similar to the other ones.
_tapiManager = new TapiManager("Hills.CiscoCallManager");
_tapiManager.LineAdded += this._tapiManager_LineAdded;
_tapiManager.LineRemoved += this._tapiManager_LineRemoved;
Logger.Info("Initialising Tapi Manager..");
var pass = _tapiManager.Initialize();
// now when I query the Lines Property, I do not see the SIP Device in there.
thanks,
Randeep
... ...
int numLines = InitializeLineDevices();
int numPhones = InitializePhoneDevices();
... ...
above, one line has more than one phone.
But the "numPhones = 0" , why?
I'd like to know the reason. And when incoming call, the called id is line's id.
I wanna know the exact phone number, not line id.
I wish your help. Thank you!
Hi all,
It rather a question than an issue, I've just wanted to understand what issues can be faced if I compile and use the library in AnyCPU configuration? I tried, and there is no any compilation issues. I used the compiled assembly in both 32 and 64 bit applications to query USB modems, and didn't noticed any issues either...
I didn't found any other place to post this question, so sorry if it is not a right place.
Hello,
unfortunately the NuGet version is out of date.
Can you update it please?
Shutdown
wants to join the _workerThread
, but this thread has never been started, if there are no lines and no phones.
Maybe _workerThread.ThreadState
should be tested on ThreadState.Unstarted
. Otherwise there is a ThreadStateException
in Dispose
or if I explicitly Shutdown
the TapiManager
on app-shutdown.
Originally reported as CodePlex issue #13316 and still relevant for the new version:
TapiLine.NegotiatedVersion
returns 0x20002 for me, which should be present in the TapiVersion
enum as V22
.
More information: https://msdn.microsoft.com/en-us/library/ms737251(v=vs.85).aspx
hi men.
as you told me in past issues i install tsp and connected it to my panasonic kx-ns500 pbx.
its seems connected succesfully and have send and recieve data in tsp monitor.
but when i run your test projects (Tcmon and phone) tapiManager.Initialize() is allwayse false.
i cant find any part of your code that you set ip and port of pbx. how can i config your test project to run on my pbx?
thank you.
Error code is 0xFFFFFFFF80000049
This happens if I try to generate a custom tone. Is this a limitation of the modem, or a problem with how I'm using the function? I can dial a number normally when placing a call, but can't dial numbers once the call is running.
EDIT: Same for lineGenerateDigits! I need to be able to send DTMF tones during a call (e.g. "press 1 to..." continue in menus), so how am I supposed to do this?
The modem reports "InteractiveVoice | DataModem" as its capabilities. Are more capabilities needed to produce custom tones?
This is when leveraging the DLL in other code (sample code seems to work fine):
Neither the TapiManager nor the open line will fire off their Ringing events. If I manually pick up the call, it will connect, but I'm unable to rely on being told when the line is ringing.
I can place calls and dial, so everything is initialized correctly to my knowledge.
On starting a new call, the used SafeHandle might be already closed on calling GatherCallStatus. This might have happened in the GatherCallInfo method, which is called in TapiCall ctor before GatherCallStatus. In a certain case, the handle is deallocated in that method.
System.ObjectDisposedException: Safe handle has been closed
bei System.Runtime.InteropServices.SafeHandle.DangerousAddRef(Boolean& success)
bei System.StubHelpers.StubHelpers.SafeHandleAddRef(SafeHandle pHandle, Boolean& success)
bei JulMar.Atapi.Interop.NativeMethods.lineGetCallStatus(HTCALL hCall, IntPtr lpCallStatus)
bei JulMar.Atapi.TapiCall.GatherCallStatus()
bei JulMar.Atapi.TapiCall..ctor(TapiAddress addrOwner, UInt32 hCall)
bei JulMar.Atapi.TapiAddress.MakeCall(String address, Int32 countryCode, MakeCallParams param)
Hi @markjulmar,
We are using ATAPI to monitor Cisco phones. During a conference scenario we are sporadically getting an issue where ATAPI reported zero calls on monitored line although there was a call on physical phone. After adding logs in ATAPI source we found a race condition for updating the TapiCall::CallsMap dictionary. Log file : ATAPI_Logs_Log4net.txt
Below is the scenario:
From the logs/source code of GetRelatedConferenceCalls, we can see that this function created a new TapiCall and added to CallsMap. Soon, the LineCallback recceived TapiEvent.LINE_APPNEWCALL which also tried to add a new TapiCall to CallsMap but got exception "An item with the same key has already been added." As a result of this exception, TapiAddress::HandleNewCall was not called and there was no entry made in TapiAddress::_calls. So in the logs we still see the total call count =2 instead of 3 after call is added to conference: Log snippet : "hCall-66515 On LineId-515-TotalCallCount-2".
When the conferencing party drops out, the ATAPI library reported zero calls on line 515 as it missed this new call due to the exception.
Proposed changes:
These changes are in our local repo. I'm not able to create a branch on markjulmar/atapi.net to post the changes for your review.
Could you please share the information on submitting a pull-request to this repo ?
Best Regards,
Adinath
After getting the latest release of ATAPI.dll
I have increased number of UI thread deadlocks because of this line
switch (WaitHandle.WaitAny(arrWait))
in ProcessTapiMessages()
(.net framework 4.8 win form application in a STA thread)
We have a problem with our network and Panasonic tapi service provider status become disconnected is there a way to detect that and re register the lines?
Hi, This issue was originally submitted on Codeplex, but I see it is still an issue in the latest version on GitHub. This issue had me scratching my head for a while back in 2016. The suggested change below is now part of my standard ATAPI build and running live with a number of different phone systems - although we have only found it to be a major issue on Cisco CUCM (tested with CUCM 9.x, 10.x and 11.x) with extension mobility.
Original Codeplex Issue Text below:-
Lines added after the initial ATAPI initialisation do not fire any call events, although the lines are controllable.
The fix for this issue is a code change to register the TapiManager event handlers immediately following creation of the new TAPILine in TapiManager.ProcessTapiMessage.
This is tested against CUCM 9.1 where lines are removed and added when mobility users log-out and log-in to handsets.
TapiManager.cs:
case TapiEvent.LINE_CREATE:
{
var newLine = new TapiLine(this, msg.dwParam1.ToInt32());
// Change to add event handler registration
newLine.NewCall += HandleNewCall;
newLine.CallStateChanged += HandleCallStateChanged;
newLine.CallInfoChanged += HandleCallInfoChanged;
newLine.AddressChanged += HandleAddressChanged;
newLine.Changed += HandleLineChanged;
newLine.Ringing += HandleLineRinging;
// End of change
lock (_lineArray)
{
_lineArray.Add(newLine);
}
if (LineAdded != null)
LineAdded(this, new LineAddedEventArgs(newLine));
}
break;
Hello.
I'm trying to update ATAPI from v. 2013.1.4 to last stable 2018.3.9 but I get an error about the target .NET framework (in my project, I'm still using .NET 4.0). Following is the error:
Could not install package 'ATAPI 2018.3.9'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
I see that currently you're targeting .NET 4.6. Please can you confirm me that ATAPI requires at least .NET 4.6? If not, is it possible to target also previous versions (and .NET 4.0 in particular)?
Thank you.
The result will be an ArgumentOutOfRangeException:
Exception in user work item (PID=3244): System.ArgumentOutOfRangeException:
Requested range extends past the end of the array.
at System.Runtime.InteropServices.Marshal.CopyToNative(Object source, Int32 startIndex, IntPtr destination, Int32 length)
at JulMar.Atapi.AddressStatus.get_ForwardingInformation()
TAPI LINEFORWARD structure has changed since version 3.1, adding two new fields (dwCallerAddressType
and dwDestAddressType
).
Anyway, if the negotiated version is < 3.1, those two fields will not be in the TAPI message:
12:11:01.642 | TSPI_lineGetAddressStatus()
TSPI_lineGetAddressStatus returns = 0x00000000
lpAddressStatus->dwNumInUse = 1
lpAddressStatus->dwNumActiveCalls = 0
lpAddressStatus->dwNumOnHoldCalls = 0
lpAddressStatus->dwNumOnHoldPendCalls = 0
lpAddressStatus->dwAddressFeatures = 0x00001003
lpAddressStatus->dwNumRingsNoAnswer = 0
lpAddressStatus->dwForwardNumEntries = 1
lpAddressStatus->dwForwardSize = 0x0000001E
lpAddressStatus->dwForwardOffset = 0x00000040
lpAddressStatus->dwTerminalModesSize = 0x00000000
lpAddressStatus->dwTerminalModesOffset = 0x00000000
lpAddressStatus->dwDevSpecificSize = 0x00000000
lpAddressStatus->dwDevSpecificOffset = 0x00000000
12:11:01.642 | TSPI_lineGetAddressStatus()
LINEFORWARD[0] structure
dwForwardMode = 0x00000001
dwCallerAddressSize = 0x00000000
dwCallerAddressOffset = 0x00000000
dwDestCountryCode = 0
dwDestAddressSize = 0x00000006
dwDestAddressOffset = 0x00000058
12:11:01.642 | TSPI_lineGetAddressStatus()
Dest Address = 55
12:11:01.642 | TSPI_lineGetAddressStatus() TSPI_lineGetAddressStatus returns = 0x00000000
12:11:01.643 |<--TSPI_lineGetAddressStatus()
Regardless of this, ATAPI is trying to read the whole LINEFORWARD
structure from the message (with any TAPI version), resulting in two possible outcomes:
Hi, we have been using our TAPI driver on Windows 2012 server - no problems whatsoever. Recently we upgraded to Windows 2019 OS, and ever since we have been getting the following error at random times , we are struggling to determine the cause of this.
Does anyone have a suggestion at to what this error code relates to?
Opening line Exception: lineOpen failed [0xFFFFFFFF8000004B] A resource needed to fulfill the request is not available
Hi! nice library!
Just a remark, in the codeplex site, the url to the moved github is pointing to https://github.com/markjulmar/atapi/ and this site is the C/C++ wrapper.
Do you accept pull request? I my current project we add some minor features:
I can send you a pull request if you want.
Regards.
I have already clone the repo, and using SharpDevelop to test the Phone.Net app, but I got an error about the sign. Is there a change about it or Am I missing something to compile the Atapi.dll?
Hope you can help me, I want to test it. Thanks
I can make a call...BUT I get an exception:
Note: the call continues in the background while this exception has stopped execution of the program
Looks like if I want to use .NET Core, I have to change how the async calls are done:
https://devblogs.microsoft.com/dotnet/migrating-delegate-begininvoke-calls-for-net-core/
The fix appears to be relatively simple. Here are the necessary changes:
async public Task<bool> Initialize()
{
...
/*
_workerThread = new Thread(ProcessTapiMessages)
{
Name = "Tapi Message Processor",
IsBackground = true,
};
_workerThread.Start();
*/
var _workerTask = new Task(async () =>
{
await ProcessTapiMessages();
});
_workerTask.Start();
...
}
async private Task ProcessTapiMessages()
{
...
/*
ptmCb.BeginInvoke(msg, ar =>
{
try
{
ptmCb.EndInvoke(ar);
}
catch (Exception ex)
{
Trace.WriteLine("TAPI message exception: " + ex.Message);
}
}, null);
*/
// invoke and await delegate
await Task.Run(() =>
{
try
{
ptmCb.Invoke(msg);
}
catch (Exception ex)
{
Trace.WriteLine("TAPI message exception: {0}", ex.Message);
}
});
...
}
in TapiManager.cs
Now I no longer get the exception, and the call continues normally. Both the async changes were required, or else the UI would hang.
This fix should be compatible with existing applications, and now it supports .NET Core!
Originally reported as CodePlex issue #13315 and still relevant for the new version:
The Thread
that is created and started in the TapiManager.Initialize
method doesn't have the IsBackground
property set to true and therefore prevents the closing of applications if the TapiManager.Shutdown
method is never called.
Any Plans to deploy a nuget-Package for .NET 8?
The sample apps work fine, but in my own app (Win 10, .NET Core 3.1 -> referencing ATAPI project source), the line fails to open:
lineOpen failed [0xFFFFFFFF80000048] The operation failed for unspecified reasons
The error code is LINEERR_OPERATIONFAILED
I'm explicitly targeting x86 (32-bit) for hardware reasons. I can initialized TapiManager fine and get my lines. I'm following the examples and passing in the available media modes when opening the line:
line.Open(line.Capabilities.MediaModes);
When I follow into the open call, it fails at Line 1157 in TapiLine.cs:
int rc = NativeMethods.lineOpen(_mgr.LineHandle, _deviceId, out hLine, _negotiatedVersion, _negotiatedExtVersion,
Marshal.GetFunctionPointerForDelegate(_lcb), privilege, (int) mediaMode, ref lcp);
returns
-2147483576
which is obviously a bad pointer. Everything being passed into the native call is valid and not null, so it's failing somewhere during the interop part. It looks like Interop.cs explicitly points to TAPI32.dll:
[DllImport("Tapi32.dll", EntryPoint = "lineOpenW", CharSet = CharSet.Auto)]
internal static extern int lineOpen(HTLINEAPP hLineApp, int dwDeviceID, out uint hLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, ref LINECALLPARAMS lpCallParams);
I do have the TAPI32 dll in System32. I've tried two different modems, and tried explicitly setting the media mode, but it errors out the same way. It's probably something dumb I'm doing, but I can't figure it out.
We use our monitor functionality program in several computers. Sometime we have got next situation with incomming call in OnCallStateChanged -
We have no event with final CallState.
But we have got Call with Id+1(maybe 2 or 3) and CallOrigin =Unknown and CallState = Connected.
D:\src\atapi.net\src\src\Events.cs(374,20,374,29): error CS0266: Cannot implicitly convert type 'JulMar.Atapi.ITapiLine' to 'JulMar.Atapi.TapiLine'. An explicit conversion exists (are you missing a cast?)
D:\src\atapi.net\src\src\TapiManager.cs(547,39,547,55): error CS1061: 'ITapiLine' does not contain a definition for 'OnDeviceSpecific' and no extension method 'OnDeviceSpecific' accepting a first argument of type 'ITapiLine' could be found (are you missing a using directive or an assembly reference?)
There are different ways to resolve them:
ITapiLine
and adding OnDeviceSpecific
to the interfaceTapiLine
I don't know which way is preferred. I will post diffs for both possibilities.
Hello,
Please suggest how I can retrieve IP address of Cisco phone associated with any Line.
hi men
i have a panasonic ns500 pbx device .
i searching in internet for a while and now know i need a tapi application to connect to my pbx to manage phone and calls.
but it still confusing for me!
can you please tell me how i can connect to my pbx and programing for it? can i use your library for it?
i just need some clear road map and knowlege.
Thank you a lot!
Hello,
We have got a requirement where we would like to monitor the incoming call and from fin the related user from that phone number and display the user details on the screen. Also want to create a phone link where user can call the that number directly from the link.
WE have got similar functionality in our older version but it uses the Vbscript. We have got TAPi installed. i just need a way to way to monitor this in our new system. (front end is Ember and backend is web API in C#)
Kind Regards
Start TcMon test in VS2017.
When a new call occurs, UI becomes frozen.
It is not possible to close the running app by a cross.
I've modified private void TapiMonitorForm_Load(object sender, EventArgs e)
to monitor only OnNewCall
for one given line:
foreach (TapiLine line in tapiManager.Lines)
{
try
{
if (line.ToString().Contains("1240171"))
{
line.NewCall += OnNewCall;
line.Monitor();
}
}
Can you please give me a hint?
I assume this shall work, so a problem must me on my side.
Thanks.
An error may occur during initialization of TapiManager on creating a new TapiLine object and gathering the line capabilities.
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parametername: startIndex
at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
at System.BitConverter.ToChar(Byte[] value, Int32 startIndex)
at JulMar.Atapi.LineCapabilities..ctor(LINEDEVCAPS ldc, Byte[] buff)
at JulMar.Atapi.TapiLine.GatherDevCaps()
at JulMar.Atapi.TapiLine..ctor(TapiManager mgr, Int32 deviceId)
at JulMar.Atapi.TapiManager.InitializeLineDevices()
at JulMar.Atapi.TapiManager.Initialize()
Hi again!
Do you have any plan to publish the latest changes made with the PRs via Nuget to allow us to update the library?
Regards!
Hello,
I have trouble using the GetDeviceConfig function. From within my app I would like the user to permanently change settings for a specific tapi line without going to the control panel an searching for the tsp provider.
I have a sub with the following:
Public Shared Sub OpenConfigDialog()
' Get the current active tapi line
Dim ActiveTapiLine As TapiLine = GetActiveTapiLine()
' Open the config dialog for the line
ActiveTapiLine.Config(Nothing, "tapi/line")
' Get the config as byteArray
Dim LineConfigByteArray As Byte() = ActiveTapiLine.GetDeviceConfig("tapi/line")
' Store updated config as byteArray
ActiveTapiLine.SetDeviceConfig("tapi/line", LineConfigByteArray)
End Sub
The problem is that the GetDeviceConfig returns {Length=0}. However, I expect that to return an updated config so it can be used again with the SetDeviceConfig function.
Am I doing something wrong? Hope you can help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.