Hello I want to send something trough IR port to a printer but I have a problem .... Just take a look please....
I have a class "Cir" /*************************************************************/ bool CIr::Open(int nSpeed, int nTimeOut) { UInt32 valueP; UInt16 valueLenP; m_nPortID = 0; m_nTimeOut = nTimeOut; Err nError = 0; if( !CPalmApp::IsVisor() ) { FrmCustomAlert(CustomErrorAlert, "No Visor", NULL, NULL); nError = SrmOpen(/*sysFileCVirtIrComm*/ serPortIrPort, nSpeed, &m_nPortID); } else { HsExtKeyboardEnable( false ); nError = SrmOpen(serPortCradlePort, nSpeed, &m_nPortID); } if( nError ) { FrmCustomAlert(CustomErrorAlert, "ERROR", NULL, NULL); m_nPortID = 0; if( serErrAlreadyOpen == nError ) { nError = Close(); if( nError==serErrStillOpen) { FrmCustomAlert(CustomErrorAlert, "Serial port open by other application!\nReset the device!", NULL, NULL); return false; } if( !CPalmApp::IsVisor() ) { nError = SrmOpen(serPortIrPort, nSpeed, &m_nPortID); } else { HsExtKeyboardEnable( false ); nError = SrmOpen(serPortCradlePort, nSpeed, &m_nPortID); } if( nError ) { m_nPortID = 0; FrmCustomAlert(CustomErrorAlert, "Serial port already open ", NULL, NULL); return(false); } } else { FrmCustomAlert(CustomErrorAlert, "Cannot open the serial port", NULL, NULL); return(false); } } else { valueLenP = sizeof(UInt32); valueP = srmSettingsFlagStopBits1 & srmSettingsFlagBitsPerChar8; nError = SrmControl(m_nPortID,srmCtlSetFlags, (void *)&valueP, &valueLenP); if (nError == serErrBadPort) { FrmCustomAlert(CustomErrorAlert, "This port doesn't exist", NULL, NULL); } if (nError == serErrBadParam ) { FrmCustomAlert(CustomErrorAlert, "An invalid op code was specified", NULL, NULL); } if (nError == serErrNotOpen ) { FrmCustomAlert(CustomErrorAlert, "The serial port is not open. ", NULL, NULL); } if (nError == serErrNoDevicesAvail) { FrmCustomAlert(CustomErrorAlert, "No serial devices could be found.", NULL, NULL); } if (nError == serErrNotSupported ) { FrmCustomAlert(CustomErrorAlert, "The specified op code is not supported in the current configuration", NULL, NULL); } if (!nError) { FrmCustomAlert(CustomErrorAlert, "OK srmCtlSetFlags", NULL, NULL); } } return(true); } /*************************************************************/ // // Close() : close the port if it's opened // int CIr::Close() { Err error = 0; if (0 != m_nPortID) { error = SrmClose(m_nPortID); m_nPortID = 0; } return error; } /*************************************************************/ // // Write() : writes nLength bytes on the serial port // : returns the number of bytes that was actually written or -1 // int CIr::Write(char* pData, int nLength) { TRACE("%s", pData); Err nError; int nBytesSent; nBytesSent = SrmSend(m_nPortID, (void*)pData, nLength, &nError); if(nError==0) return nBytesSent; else { return -1; } } /*************************************************************/ And a simple form whith a button: (Cir m_serial) /*************************************************************/ bool CMain::OnP1Button() { m_serial.Open(9600, 60); char szSmallFonts[] = {0x1B, 0x0F, 0}; m_serial.Write( szSmallFonts, strlen(szSmallFonts)); char szHighSpeedDraft[4] = {0x1B,0x73,0x30,0}; m_serial.Write( szSmallFonts, strlen(szHighSpeedDraft)); CString szPrinterLine = "28356349027623498582582346589723456234856823465823450834657893468562348 5689238974365893489"; long lb = m_serial.Write( (char*)szPrinterLine, szPrinterLine.GetLength() ); if (lb==-1) { MSG_INFO("NOTHING"); } else { char szbuff[100]; strcpy(szbuff, "bytes: "); strcat(szbuff, ftoa(lb,false,0)); MSG_INFO(szbuff); } while(m_serial.CheckSendBuffer()!=0){} m_serial.Close(); return true; } What is wrong? Thanck's in advance -- For information on using the Palm Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/