EasyManua.ls Logo

ABLE Ap1400 - Page 37

ABLE Ap1400
42 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Ref: "Ap1400ProgGuide1_2.docx" Page 37 of 42
Document Revision: “1.2”
Document Date: “9 Apr. 2013”
SendData
Send data to a device
Prototype
int WINAPI SendData(int iHandle,
LPCTSTR pData,
LPINT pDataLen,
int iTimeout);
Description.
Sends data to a device with flow control. There is no practical limit on the amount of
data that can be sent, but the call is synchronous and will not return until either the
data send is completed, a timeout occurs, or an error occurs. Data is sent over a
bulk endpoint which has a buffer size of 64 bytes. Data longer than this is
transmitted in full 64 byte packets and flow control is checked between each
packet. Where the receiver buffer is full the function will wait for a CTS signal for a
period not exceeding the value in iTimeout. When CTS is set then the timeout value
is reset to zero.
Arguments
ihandle – The handle of an open device. This handle must have been issued by a
previous call to OpenDevice.
pData - Pointer to a buffer containing the data to transmit. All data in the buffer up
to pDataLen is transmitted including any NULL characters.
pDataLen-
Pointer to an integer containing the length of the data to transmit.
This value is modified to show the actual amount of data that was
successfully transmitted. If a timeout(or other error) occurs during
transmission, this value can be used to establish a restart point.
iTimeout-
The timeout value in milliseconds. The timeout countdown will only start
when a buffer full, or other blocking condition occurs. Should this condition
clear during the timeout period, then the period is reset.
Returns
ERROR_SUCCESS if successful, otherwise the value is set to the system error
code.
Example
CString m_csData=_T(“This is a data packet”);
TRACE(_T("Sending %d bytes of data.\n"),m_csData.GetLength());
int iLen=m_csData.GetLength();
DWORD m_dwStatusCode=SendData(m_iPrinterHandle,
m_csData,&iLen,1000);
//Check return
if(m_dwStatusCode!=ERROR_SUCCESS)
{
CString csError;
csError.Format(_T("SendData Failed - Reason=%d."),
m_dwStatusCode));
AfxMessageBox(csError,MB_ICONSTOP|MB_OK);
}

Related product manuals