[[ This message was both posted and mailed: see
the "To," "Cc," and "Newsgroups" headers for details. ]]
In article <56398@palm-dev-forum>, Jim Schram <[EMAIL PROTECTED]>
wrote:
> The serCtlIrDAEnable "opcode" is only supported by the OLD serial manager,
> and by the new serial manager's compatibility "wrapper" library (i.e. the
> shared library which veneers the new serial manager calls as old serial
> manager calls). Note the "ser" prefix. When you use the SrmXXX versions of
> the serial manager APIs, the correct opcode to use is srmCtlIrDAEnable.
Yes, however that does seem to generate an error on an m505, where the
same code does not on a Vx running 3.5.x.
The below code will return a serErrNotSupported or serErrBadParam
depending on which port you pick on an m505. (I realize you recommend
using serPortIrPort, but at least *one* of the ports that are
enumerated should be the same as that one, no?)
--
Err CSerialConnection::Open(void)
{
Err err = 0;
if (fHasNewSerialMgr) {
// If none specified, pick the first one
if (fDeviceID == 0) fDeviceID = GetDeviceID(0);
// If using IR, use the OS constant for the IR port
// if (fUseIrDA) fDeviceID = serPortIrPort;
// Open the port
err = SrmOpen(
fDeviceID, // ie, serPortCradlePort
fPrefererredBaudRate, // baud rate
&fPortID);
// Handle cases where the port could not be opened
if (err) {
if (err == serErrAlreadyOpen) {
// Port in use, so close driver
Close();
}
goto out;
}
// Set up the port for doing Serial IR (SIR)
if (fUseIrDA) {
// I have to be honest and say that I have not used the New
Serial Manager
// so I have gone purely on the documentation !!!
err = SrmControl(fPortID, srmCtlIrDAEnable, 0, 0);
if (err) goto out;
err = SrmControl(fPortID, srmCtlRxEnable, 0, 0);
if (err) goto out;
}
// Allocate the buffer (if not, default is 512 bytes)
if (fPrefererredRxBufSize) {
fSerRcvQueue = MemPtrNew(fPrefererredRxBufSize);
if (fSerRcvQueue == 0)
err = memErrNotEnoughSpace;
if (err) goto out;
// Use our own buffer
err = SrmSetReceiveBuffer(fPortID, fSerRcvQueue,
MemPtrSize(fSerRcvQueue));
if (err) goto out;
}
} else {
#if EMULATION_LEVEL == EMULATION_NONE
UInt32 ftrHSVersion;
// If on a Visor, we need to disable the keyboard daemon before
opening
// library/port else we get error 775
if (!FtrGet ('hsEx', 0, &ftrHSVersion))
HsExtKeyboardEnable(false);
// Get the serial library reference
if ((fDeviceID == 1) && fHaspdQModem) {
// On a pdQ and we want the internal modem - Try and find the
pdQ library
err = SysLibFind(pdQSerLibName, &fSerLibRefNum);
} else {
// Get the palm serial library reference
err = SysLibFind("Serial Library", &fSerLibRefNum);
}
if (err) goto out;
// Open the port
err = SerOpen(
fSerLibRefNum, // Serial library
0, // 0 is the only port (a UInt16)
fPrefererredBaudRate); // baud rate
if (err) goto out;
// Set up the port for doing Serial IR (SIR)
if (fUseIrDA) {
// Code may be required to prevent this operation with the pdQ
library
err = SerControl(fSerLibRefNum, serCtlIrDAEnable, 0, 0);
if (err) goto out;
err = SerControl(fSerLibRefNum, serCtlRxEnable, 0, 0);
if (err) goto out;
}
// Allocate the buffer
if (fPrefererredRxBufSize) {
fSerRcvQueue = MemPtrNew(fPrefererredRxBufSize);
if (fSerRcvQueue == 0)
err = memErrNotEnoughSpace;
if (err) goto out;
// Use our own buffer
err = SerSetReceiveBuffer(fSerLibRefNum, fSerRcvQueue,
MemPtrSize(fSerRcvQueue));
if (err) goto out;
}
#endif
}
// If we made it here, the port is open, and we had no errors
fPortOpen = true;
out:
// If we got an error opening the port, make sure it is now closed
// (for example, open could fail, but SerControl or MemPtrNew could
fail)
if (err) {
Close();
}
return err;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/