Hello,
I'm currently trying to access a installed virtual driver
from my own application (written in gcc), but somehow I
have not really success.
I've attached a snippet from my code to explain what I'm
currently doing. The thing is that I want to send data over
serial port through cable connecton to a mobile phone using
an existing vdrv.
I hope somebody can help me.
static void TestPort()
{
UInt16 openPort = 0;
UInt32 portID = 0;
UInt32 baud = 0;
LocalID theDBID = 0;
UInt theCardNo = 0;
ULong result = 0;
Err syserror;
Err err;
UInt iCardCur;
LocalID idCur;
ULong idAppCur;
ULong value;
UInt16 newPortIdP;
UInt32 newPortValue;
DeviceInfoType devTypeInfo;
UInt16 i,x,y,z;
Byte command[40];
char text[300];
DmSearchStateType theSearchState;
UInt32 valueBits;
UInt16 valueBitsLen;
err = FtrGet(sysFileCSerialMgr, sysFtrNewSerialPresent, &value);
if (err)
{
FrmCustomAlert ( Alertbox001, "FtrGet failed!", "" , "");
return;
}
//Get the list from the Connection Manager
/* err = CncGetProfileList(&globalProfileList, &globalProfileCount);
if (!err)
{
sprintf(text, "Number of profiles: %u", globalProfileCount);
FrmCustomAlert ( Alertbox001, text, "" , "");
//Deallocate the connection list
for(i = 0; i < globalProfileCount; i++)
{
//sprintf(text, "Profile: %s", globalProfileList[ i ]);
//FrmCustomAlert ( Alertbox001, text, "" , "");
MemPtrFree(globalProfileList[ i ]);
}
MemPtrFree(globalProfileList);
} */
// get port id
err = CncGetProfileInfo("TDK/Nokia Manager", &portID, &baud, NULL, NULL,
NULL, NULL, NULL, NULL);
if(!err)
{
sprintf(text, "PortID: %lu Baud: %lu ", portID, baud);
FrmCustomAlert ( Alertbox001, text, "" , "");
// open the port
err = SrmOpen(portID, baud, &openPort);
switch (err)
{
case serErrAlreadyOpen :
FrmCustomAlert ( Alertbox001, "SrmOpen failed -
serErrAlreadyOpen!", "" , "");
break;
case serErrBadPort :
FrmCustomAlert ( Alertbox001, "SrmOpen failed! - serErrBadPort",
"" , "");
break;
case memErrNotEnoughSpace :
FrmCustomAlert ( Alertbox001, "SrmOpen failed! -
memErrNotEnoughSpace", "" , "");
break;
case 0:
sprintf(text, "Internal Port ID: %u", openPort);
FrmCustomAlert ( Alertbox001, text, "" , "");
SrmClearErr(openPort) ;
err = SrmGetDeviceInfo(openPort, &devTypeInfo);
sprintf(text, "%s %lu %lu %lu %lu",
devTypeInfo.serDevPortInfoStr,
devTypeInfo.serDevMaxBaudRate,
devTypeInfo.serDevCreator,
devTypeInfo.serDevFtrInfo,
devTypeInfo.serDevHandshakeBaud );
FrmCustomAlert ( Alertbox001, text, "" , "");
command[0] = 'A';
command[1] = 'T';
command[2] = 'D';
command[3] = ',';
command[4] = '0';
command[5] = '1';
command[6] = '7';
command[7] = '0';
command[8] = '9';
command[9] = '9';
command[10] = '3';
command[11] = '6';
command[12] = '3';
command[13] = '9';
command[14] = '9';
command[15] = ';';
command[16] = 0;
SrmSendFlush(openPort) ;
newPortValue = SrmSend (openPort, (void*)command, 16, &err);
if (err) FrmCustomAlert ( Alertbox001, "SrmSend failed!", "" ,
"");
sprintf(text, "%lu Bytes sent!", newPortValue);
FrmCustomAlert ( Alertbox001, text, "" , "");
err = SrmSendWait(openPort);
if (err) FrmCustomAlert ( Alertbox001, "SrmSendWait failed!", "" ,
"");
err = SrmReceiveCheck (openPort, &newPortValue);
if (err) FrmCustomAlert ( Alertbox001, "SrmReceiveCheck failed!",
"" , "");
else
{
sprintf(text, "Port: %u Bytes: %lu", openPort, newPortValue);
FrmCustomAlert ( Alertbox001, text, "" , "");
SrmReceive(openPort, command, newPortValue, 10, &err) ;
if(!err)
{
sprintf(text, "Received: %s", command);
FrmCustomAlert ( Alertbox001, text, "" , "");
}
}
SrmClose(openPort);
}
}
else
FrmCustomAlert ( Alertbox001, "GobalPulse not installed!", "" , "");
}
Kind regards,
Armin Mendle
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/