本文整理汇总了C++中DosDevIOCtl函数的典型用法代码示例。如果您正苦于以下问题:C++ DosDevIOCtl函数的具体用法?C++ DosDevIOCtl怎么用?C++ DosDevIOCtl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DosDevIOCtl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Baud
bool Baud( int index )
{
USHORT temp;
BYTE lc[3];
APIRET rc;
BYTE command;
ULONG ulParmLen;
if( index == MIN_BAUD )
return( TRUE );
if( index == CurrentBaud )
return( TRUE );
temp = Rate[index];
command = 0;
ulParmLen = sizeof( temp );
rc = DosDevIOCtl( ComPort, IOCTL_ASYNC, ASYNC_SETBAUDRATE,
&temp, sizeof( temp ), &ulParmLen,
NULL, 0, NULL );
if( rc != 0 ) {
return( FALSE );
}
lc[ 0 ] = DATA_BITS_8;
lc[ 1 ] = PARITY_NONE;
lc[ 2 ] = STOP_BITS_1;
ulParmLen = sizeof( lc );
rc = DosDevIOCtl( ComPort, IOCTL_ASYNC, ASYNC_SETLINECTRL,
&lc, sizeof( lc ), &ulParmLen,
NULL, 0, NULL );
if( rc != 0 ) {
return( FALSE );
}
CurrentBaud = index;
return( TRUE );
}
示例2: memcpy
bool CD_drive::readTrackInfo(char track, CDTRACKINFO *trackInfo2)
{
ULONG ulParamLen;
ULONG ulDataLen;
ULONG rc;
BOOL returnBool = FALSE;
CDAUDIOTRACKINFOPARAM trackParam;
CDAUDIOTRACKINFODATA trackInfo[2];
memcpy(trackParam.signature,TAG,4);
trackParam.trackNum = track;
rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
&trackParam, sizeof(trackParam),
&ulParamLen, &trackInfo[0],
sizeof(trackInfo[0]), &ulDataLen);
if(rc)
updateError("DosDevIOCtl failed with return code 0x%x reading track %d info",rc,track);
else
{
trackParam.trackNum = track+1;
rc = 0;
if(trackParam.trackNum <= cdInfo.lastTrack)
{
rc = DosDevIOCtl(hCDDrive, IOCTL_CDROMAUDIO, CDROMAUDIO_GETAUDIOTRACK,
&trackParam, sizeof(trackParam),
&ulParamLen, &trackInfo[1],
sizeof(trackInfo[1]), &ulDataLen);
if(rc)
updateError("DosDevIOCtl failed with return code 0x%x",rc);
}
else
trackInfo[1].address = cdInfo.leadOutAddress;
if(!rc)
{
ULONG LBA[2];
MSF length;
LBA[0] = getLBA(trackInfo[0].address);
LBA[1] = getLBA(trackInfo[1].address);
/* -150 because we want length, not an address */
length = getMSF(LBA[1]-LBA[0]-150);
trackInfo2->start = trackInfo[0].address;
trackInfo2->end = trackInfo[1].address;
trackInfo2->length = length;
trackInfo2->size = (LBA[1]-LBA[0])*2352;
trackInfo2->data = (trackInfo[0].info & 0x40) ? TRUE : FALSE;
trackInfo2->channels = (trackInfo[0].info & 0x80) ? 4 : 2;
trackInfo2->number = track;
returnBool = TRUE;
}
}
return returnBool;
}
示例3: SERIAL_getextchar
int SERIAL_getextchar(COMPORT port) {
ULONG dwRead = 0; // Number of chars read
char chRead;
int retval = 0;
// receive a byte; TODO communicate failure
if (DosRead(port->porthandle, &chRead, 1, &dwRead) == NO_ERROR) {
if (dwRead) {
// check for errors; will OS/2 clear the error on reading its data?
// if yes then this is in wrong order
USHORT errors = 0, event = 0;
ULONG ulParmLen = sizeof(errors);
DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMEVENT,
0, 0, 0, &event, ulParmLen, &ulParmLen);
if (event & (64 + 128) ) { // Break (Bit 6) or Frame or Parity (Bit 7) error
Bit8u errreg = 0;
if (event & 64) retval |= SERIAL_BREAK_ERR;
if (event & 128) {
DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_GETCOMMERROR,
0, 0, 0, &errors, ulParmLen, &ulParmLen);
if (errors & 8) retval |= SERIAL_FRAMING_ERR;
if (errors & 4) retval |= SERIAL_PARITY_ERR;
}
}
retval |= (chRead & 0xff);
retval |= 0x10000;
}
}
return retval;
}
示例4: mpioctl
int mpioctl(HFILE fd, int func,struct map_ioctl* data)
{
struct xf86_pmap_param par;
struct xf86_pmap_data dta;
ULONG len;
APIRET rc;
switch (func) {
case IOCTL_MAP:
par.u.physaddr = data->a.phys;
par.size = data->size;
rc = DosDevIOCtl(fd, XFREE86_PMAP, PMAP_MAP,
(ULONG*)&par, sizeof(par), &len,
(ULONG*)&dta, sizeof(dta), &len);
if (!rc) data->a.user = (void*)dta.addr;
return rc ? -1 : 0;
case IOCTL_UMAP:
par.u.physaddr = (ULONG)data->a.user;
par.size = 0;
rc = DosDevIOCtl(fd, XFREE86_PMAP, PMAP_UNMAP,
(ULONG*)&par, sizeof(par), &len,
NULL, 0, NULL);
return rc ? -1 : 0;
default:
return -1;
}
}
示例5: sizeof
void CDirectSerial::updateModemControlLines ( /*Bit8u mcr */ ) {
bool change = false;
DCBINFO dcb;
ULONG ulParmLen = sizeof(dcb);
DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &dcb, ulParmLen, &ulParmLen);
/*** DTR ***/
if (CSerial::getDTR ()) { // DTR on
if (dcb.fbCtlHndShake && 3 == 0) { // DTR disabled
dcb.fbCtlHndShake |= 1;
change = true;
}
} else {
if (dcb.fbCtlHndShake && 3 == 1) { // DTR enabled
dcb.fbCtlHndShake &= ~3;
change = true;
}
}
/*** RTS ***/
if (CSerial::getRTS ()) { // RTS on
if (dcb.fbFlowReplace && 192 == 0) { //RTS disabled
dcb.fbFlowReplace |= 64;
change = true;
}
} else {
if (dcb.fbFlowReplace && 192 == 1) { // RTS enabled
dcb.fbFlowReplace &= ~192;
change = true;
}
}
if (change)
DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb, ulParmLen, &ulParmLen, 0, 0, 0);
}
示例6: Set_IOCTL_Bit_Rate
void Set_IOCTL_Bit_Rate(USHORT BitRate,HWND hwnd)
{
APIRET rc;
ULONG ParmPacketLen;
ParmPacketLen = 2; //size of Parmpacket
rc = DosDevIOCtl (HandleComm,
IOCTL_ASYNC,
ASYNC_SETBAUDRATE,
(PULONG) &BitRate,
sizeof(BitRate), //size input parm packet
&ParmPacketLen, // length of parm packet
NULL,
0,
NULL);
rc = DosDevIOCtl (HandleComm,
IOCTL_ASYNC,
ASYNC_SETBAUDRATE,
(PULONG) &BitRate,
sizeof(BitRate), //size input parm packet
&ParmPacketLen, // length of parm packet
NULL,
0,
NULL);
if (rc)
{
sprintf(PrintBuf,"RC=%u Line=%u\nFile: %s",rc,__LINE__,__FILE__);
WinDebugMsg(PrintBuf,hwnd);
}
}
示例7: InitLineBits
APIRET InitLineBits(HWND hwnd)
{
APIRET rc;
ULONG DataPacketLen;
rc = DosDevIOCtl (HandleComm,
IOCTL_ASYNC,
ASYNC_GETLINECTRL,
NULL, //no parameter packet
0, // = 0
NULL, // length of parm packet
(PULONG) &DataPacket,
sizeof(DataPacket),
&DataPacketLen);
rc = DosDevIOCtl (HandleComm,
IOCTL_ASYNC,
ASYNC_GETLINECTRL,
NULL, //no parameter packet
0, // = 0
NULL, // length of parm packet
(PULONG) &DataPacket,
sizeof(DataPacket),
&DataPacketLen);
if (rc)
{
sprintf(PrintBuf,"RC=%u Line=%u\nFile: %s",rc,__LINE__,__FILE__);
WinDebugMsg(PrintBuf,hwnd);
}
WinSendDlgItemMsg(hwnd,
(ULONG) IDC_DATA_BIT5 + (DataPacket.bDataBits - 5),
(ULONG) BM_SETCHECK,
MPFROM2SHORT(TRUE,0),
NULL);
WinSendDlgItemMsg(hwnd,IDC_PARITY_NO + DataPacket.bParity,
BM_SETCHECK,
MPFROM2SHORT(TRUE,0),
NULL);
WinSendDlgItemMsg(hwnd,IDC_STOP_BIT1 + DataPacket.bStopBits,
BM_SETCHECK,
MPFROM2SHORT(TRUE,0),
NULL);
WinSetFocus (HWND_DESKTOP, WinWindowFromID(hwnd,DID_OK));
return 0;
}
示例8: SERIAL_setCommParameters
bool SERIAL_setCommParameters(COMPORT port,
int baudrate, char parity, int stopbits, int length) {
// baud
struct {
ULONG baud;
BYTE fraction;
} setbaud;
setbaud.baud = baudrate;
setbaud.fraction = 0;
ULONG ulParmLen = sizeof(setbaud);
APIRET rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_EXTSETBAUDRATE,
&setbaud, ulParmLen, &ulParmLen, 0, 0, 0);
if (rc != NO_ERROR) {
return false;
}
struct {
UCHAR data;
UCHAR parity;
UCHAR stop;
} paramline;
// byte length
if(length > 8 || length < 5) {
// TODO SetLastError(ERROR_INVALID_PARAMETER);
return false;
}
paramline.data = length;
// parity
switch (parity) {
case 'n': paramline.parity = 0; break;
case 'o': paramline.parity = 1; break;
case 'e': paramline.parity = 2; break;
case 'm': paramline.parity = 3; break;
case 's': paramline.parity = 4; break;
default:
// TODO SetLastError(ERROR_INVALID_PARAMETER);
return false;
}
// stopbits
switch(stopbits) {
case SERIAL_1STOP: paramline.stop = 0; break;
case SERIAL_2STOP: paramline.stop = 2; break;
case SERIAL_15STOP: paramline.stop = 1; break;
default:
// TODO SetLastError(ERROR_INVALID_PARAMETER);
return false;
}
// set it
ulParmLen = sizeof(paramline);
rc = DosDevIOCtl(port->porthandle, IOCTL_ASYNC, ASYNC_SETLINECTRL,
¶mline, ulParmLen, &ulParmLen, 0, 0, 0);
if ( rc != NO_ERROR)
return false;
return true;
}
示例9: ClearCom
void ClearCom( void )
{
BYTE command;
command = 0;
DosDevIOCtl( 0L, &command, INPUT, FLUSH, ComPort );
command = 0;
DosDevIOCtl( 0L, &command, OUTPUT, FLUSH, ComPort );
}
示例10: InstallTimerHandler
CDirectSerial::CDirectSerial (IO_ReadHandler * rh, IO_WriteHandler * wh,
TIMER_TickHandler th, Bit16u baseAddr, Bit8u initIrq,
Bit32u initBps, Bit8u bytesize, const char *parity,
Bit8u stopbits,const char *realPort)
:CSerial (rh, wh, th,baseAddr,initIrq, initBps,
bytesize, parity,stopbits) {
InstallationSuccessful = false;
InstallTimerHandler(th);
lastChance = 0;
LOG_MSG ("OS/2 Serial port at %x: Opening %s", base, realPort);
LOG_MSG("Opening OS2 serial port");
ULONG ulAction = 0;
APIRET rc = DosOpen((unsigned char*)realPort, &hCom, &ulAction, 0L, FILE_NORMAL, FILE_OPEN,
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L);
if (rc != NO_ERROR)
{
LOG_MSG ("Serial port \"%s\" could not be opened.", realPort);
if (rc == 2) {
LOG_MSG ("The specified port does not exist.");
} else if (rc == 99) {
LOG_MSG ("The specified port is already in use.");
} else {
LOG_MSG ("OS/2 error %d occurred.", rc);
}
hCom = 0;
return;
}
DCBINFO dcb;
ULONG ulParmLen = sizeof(DCBINFO);
rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO, 0, 0, 0, &dcb, ulParmLen, &ulParmLen);
if ( rc != NO_ERROR)
{
DosClose(hCom);
hCom = 0;
return;
}
dcb.usWriteTimeout = 0;
dcb.usReadTimeout = 0; //65535;
dcb.fbTimeout |= 6;
rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO, &dcb, ulParmLen, &ulParmLen, 0, 0, 0);
if ( rc != NO_ERROR)
{
DosClose(hCom);
hCom = 0;
return;
}
CSerial::Init_Registers (initBps, bytesize, parity, stopbits);
InstallationSuccessful = true;
//LOG_MSG("InstSuccess");
}
示例11: SERIAL_open
bool SERIAL_open(const char* portname, COMPORT* port) {
// allocate COMPORT structure
COMPORT cp = (_COMPORT*)malloc(sizeof(_COMPORT));
if(cp == NULL) return false;
cp->porthandle=0;
cp->breakstatus=false;
ULONG ulAction = 0;
APIRET rc = DosOpen(portname, &cp->porthandle,
&ulAction, 0L, FILE_NORMAL, FILE_OPEN,
OPEN_ACCESS_READWRITE | OPEN_SHARE_DENYNONE | OPEN_FLAGS_SEQUENTIAL, 0L);
if (rc != NO_ERROR) {
goto cleanup_error;
}
ULONG ulParmLen = sizeof(DCBINFO);
rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETDCBINFO,
0, 0, 0, &cp->orig_dcb, ulParmLen, &ulParmLen);
if ( rc != NO_ERROR) {
goto cleanup_error;
}
// configure the port for polling
DCBINFO newdcb;
memcpy(&newdcb,&cp->orig_dcb,sizeof(DCBINFO));
newdcb.usWriteTimeout = 0;
newdcb.usReadTimeout = 0; //65535;
newdcb.fbCtlHndShake = dcb.fbFlowReplace = 0;
newdcb.fbTimeout = 6;
rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_SETDCBINFO,
&newdcb, ulParmLen, &ulParmLen, 0, 0, 0);
if ( rc != NO_ERROR) {
goto cleanup_error;
}
USHORT errors = 0;
ulParmLen = sizeof(errors);
rc = DosDevIOCtl(hCom, IOCTL_ASYNC, ASYNC_GETCOMMERROR,
0, 0, 0, &errors, ulParmLen, &ulParmLen);
if ( rc != NO_ERROR) {
goto cleanup_error;
}
*port = cp;
return true;
cleanup_error:
// TODO error string - rc value
if (cp->porthandle != 0) CloseHandle(cp->porthandle);
free(cp);
return false;
}
示例12: audio_set_volume_os2
/*!
Set the volume of an audio CD.
@param p_cdio the CD object to be acted upon.
*/
static driver_return_code_t
audio_set_volume_os2 ( void *p_user_data, cdio_audio_volume_t *p_volume)
{
_img_private_t *p_env = p_user_data;
struct {
UCHAR auch_sign[4];
} s_param = {{'C', 'D', '0', '1'}};
struct {
struct {
BYTE uc_in_ch;
BYTE uc_vol;
} as_out_ch[4];
} s_data;
ULONG ul_param_len;
ULONG ul_data_len;
ULONG rc;
int i;
/* first retrive current input ch. */
rc = DosDevIOCtl(
p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_GETCHANNEL,
&s_param, sizeof( s_param ), &ul_param_len,
&s_data, sizeof( s_data ), &ul_data_len );
if( rc )
{
cdio_warn("audio_set_volume_os2 : DosDevIOCtl(GETCHANNEL) = 0x%lx\n", rc );
return DRIVER_OP_ERROR;
}
for( i = 0; i < 4; i++ )
s_data.as_out_ch[ i ].uc_vol = p_volume->level[ i ];
/* now set volumes */
rc = DosDevIOCtl(
p_env->h_cd, IOCTL_CDROMAUDIO, CDROMAUDIO_SETCHANNELCTRL,
&s_param, sizeof( s_param ), &ul_param_len,
&s_data, sizeof( s_data ), &ul_data_len );
if( rc )
{
cdio_warn("audio_set_volume_os2 : DosDevIOCtl(SETCHANNELCTRL) = 0x%lx\n", rc );
return DRIVER_OP_ERROR;
}
return DRIVER_OP_SUCCESS;
}
示例13: _get_modem_state
static
int _get_modem_state(int fd,ULONG* state)
{
ULONG state1,len;
if (DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMOUTPUT,
NULL,0,NULL, state, sizeof(BYTE), &len) != 0 ||
DosDevIOCtl((HFILE)fd,IOCTL_ASYNC,ASYNC_GETMODEMINPUT,
NULL,0,NULL, &state1, sizeof(BYTE), &len) != 0)
return -1;
*state |= state1;
*state &= 0xff;
return 0;
}
示例14: QueryCDROMDMDInfo
static APIRET QueryCDROMDMDInfo(struct CDROMDMDInfo_t* pxInfo)
{
APIRET rc;
HFILE hfDMD;
ULONG ulDataLen;
union
{
struct DriveLetters_Data xDRIVELETTERS;
struct Features_Data xFEATURES;
} xData;
rc = DosOpen(CDROMDMD_NAME,
&hfDMD,
&ulDataLen,
(ULONG)0,
FILE_NORMAL,
OPEN_ACTION_FAIL_IF_NEW | OPEN_ACTION_OPEN_IF_EXISTS,
OPEN_FLAGS_FAIL_ON_ERROR | OPEN_FLAGS_NOINHERIT | OPEN_SHARE_DENYNONE | OPEN_ACCESS_READONLY,
(PEAOP2)NULL);
if(rc == NO_ERROR)
{
rc = DosDevIOCtl(hfDMD,
IOCTL_CDROMDISK2,
CDROMDISK2_DRIVELETTERS,
(PVOID)NULL,
(ULONG)0,
(PULONG)NULL,
(PVOID)&xData.xDRIVELETTERS,
ulDataLen = (ULONG)sizeof(xData.xDRIVELETTERS),
&ulDataLen);
if(rc == NO_ERROR)
{
pxInfo->ucDriveFirst = (UCHAR)xData.xDRIVELETTERS.first_drive + (UCHAR)'A';
pxInfo->ulDriveCount = (ULONG)xData.xDRIVELETTERS.drive_count;
pxInfo->ulFeatureFlags = (ULONG)0;
if(DosDevIOCtl(hfDMD,
IOCTL_CDROMDISK2,
CDROMDISK2_FEATURES,
(PVOID)NULL,
(ULONG)0,
(PULONG)NULL,
(PVOID)&xData.xFEATURES,
ulDataLen = (ULONG)sizeof(xData.xFEATURES),
&ulDataLen) == NO_ERROR)
pxInfo->ulFeatureFlags = xData.xFEATURES.driver_status;
}
(VOID)DosClose(hfDMD);
}
return rc;
}
示例15: nflowcontrol
void nflowcontrol( KWBoolean flow )
{
APIRET rc;
#ifdef __OS2__
ULONG ParmLengthInOut;
ULONG DataLengthInOut;
#endif
if ( flow )
com_dcbinfo.fbFlowReplace = (char)
(com_dcbinfo.fbFlowReplace |
(MODE_AUTO_TRANSMIT | MODE_AUTO_RECEIVE));
else
com_dcbinfo.fbFlowReplace = (char)
(com_dcbinfo.fbFlowReplace &
(0xff - MODE_AUTO_TRANSMIT - MODE_AUTO_RECEIVE));
#ifdef __OS2__
ParmLengthInOut = sizeof(com_dcbinfo);
DataLengthInOut = 0;
rc = DosDevIOCtl( commHandle,
IOCTL_ASYNC,
ASYNC_SETDCBINFO,
(PVOID) &com_dcbinfo,
sizeof(com_dcbinfo),
&ParmLengthInOut,
NULL,
0L,
&DataLengthInOut);
#else
rc = DosDevIOCtl( FAR_NULL,
&com_dcbinfo,
ASYNC_SETDCBINFO,
IOCTL_ASYNC,
commHandle);
#endif
if ( rc )
{
printOS2error( "ASYNC_SETDCBINFO", rc );
panic();
} /*if */
} /* nflowcontrol */