원격 모뎀을 호출하고 데이터 전송 (바이트 배열 형식의 사용자 지정 데이터)을 수행하는 응용 프로그램을 만들려고합니다.ITAPI3 데이터 보내기 및 받기
저는 JulMar의 ITapi3 랩퍼와 Windows 7 64Bit OS (x86으로 컴파일)에서 실행중인 C# 4.0을 사용하고 있습니다.
응용 프로그램에서 전화를 걸고 예상대로 연결을 끊지 만 실제로 전화를 통해 데이터를 전송하는 데 문제가 있습니다. 통화 상태가이 실제로 데이터를 전송 또는 원격 사이트에서 유효한 데이터를 잡하지 않는 것
var handleArray = callForData.GetID("comm/datamodem");
var byteContents = BitConverter.ToInt64(handleArray, 0);
////temporary Handle array
IntPtr myPointer =new IntPtr(byteContents);
////var pinnedArray = GCHandle.Alloc(handleArray, GCHandleType.Pinned);
////var pointer = pinnedArray.AddrOfPinnedObject();
var commHandle = new SafeFileHandle(myPointer, true);
try
{
//now init filestream
_dataTransferOutFileStream = new FileStream(commHandle, FileAccess.ReadWrite, 2048, true);
//start by writing the login message to the modem
var buffer = CreatePasswordMessage();
IAsyncResult result= _dataTransferOutFileStream.BeginWrite(buffer, 0, buffer.Length,null,null);
while (!result.IsCompleted)
{
//wait for completion of sending login message.
Thread.Sleep(10);
}
//now we are done with sending login message
_dataTransferOutFileStream.EndWrite(result);
//wait 5 seconds
Thread.Sleep(5000);
//do the same type of thing for the read or whether it was sucessful.
var readBuffer = new byte[2048];
IAsyncResult readResult = _dataTransferOutFileStream.BeginRead(readBuffer, 0, 2048,null,null);
while (!readResult.IsCompleted)
{
Thread.Sleep(10);
}
//read is complete.
int readCount = _dataTransferOutFileStream.EndRead(readResult);
Debug.WriteLine("Read Complete Count of Bytes Read: {0} Content of First Byte: {1} ",new object[]{readCount,readBuffer[0]});
}
catch (Exception ex)
{
Debug.WriteLine(ex.ToString());
return false;
}
finally
{
commHandle.Close();
}
return true;
를 연결했을 때 현재 나는 CallStateChanged 이벤트에 다음 코드가 있습니다. 제가 누락 된 것이 있습니까? SafeFileHandle이 실제로 모뎀 포트에 대한 참조인지 확인하는 방법이 있습니까?
에는 연결하지만 문제의 포트가 다른 프로세스 (I는 TAPI가에 잠금이있는 가정입니다.)에서 사용하고 있다는 오류가 발생 후 나는 .NET 용 내장하여 SerialPort 클래스를 사용하여 시도
나는 모든 제안에 개방적이다.
아직 답변이 없습니까? 지금은 어떻게 든 SerialPort 개체를 설립 통화에서 만든 점점 찾고 있습니다. 통신 포트 이름을 가져 와서 SerialPort 객체를 만들 수 있지만 열려고 할 때 물론 닫힙니다. 물론 다른 프로세스 TAPI에서 사용 중이라는 오류가 발생합니다. – Chris