Teledyne D series Installation And Operation Manual page 166

Table of Contents

Advertisement

D Series Syringe Pumps
Section 8 Serial Interface
Table 8-5 Example of a Visual C++ program to demonstrate conversion
of pump commands to DASNET frames (Continued)
int count=0;
n=strlen(out);
// start of packet
if(!WriteFile(hCom, "\r", 1, &dwBytesRead, NULL))
{
//error occurred. Report to user.
}
// data
if(!WriteFile(hCom, out, n, &dwBytesRead, NULL))
{
//error occurred. Report to user.
}
//end of packet
if(!WriteFile(hCom, "\r", 1, &dwBytesRead, NULL))
{
//error occurred. Report to user.
}
}
void commOpen(int port, long speed)
{
TCHAR szComPort[20];
if (port < 10)
wsprintf(szComPort, _T("COM%d"), port);
else
wsprintf(szComPort, _T("\\\\.\\COM%d"),port);
hCom = CreateFile(szComPort,
GENERIC_READ|GENERIC_WRITE, // desired access should be read&write
0,
NULL,
OPEN_EXISTING,
0,
NULL);
if (INVALID_HANDLE_VALUE == hCom)
{
printf("\nComm %d port not available",port);
//Sleep(2000);
//exit(1);
Sleep(1000);
return;
}
else
{
printf("\nComm %d port available ",port);
dcbSerialParams.DCBlength=sizeof(dcbSerialParams);
if (!GetCommState(hCom, &dcbSerialParams))
{
//error getting state
printf("Error getting Comm Port state");
8-12
// COM port must be opened in non-sharing mode
// don't care about the security
// IMPORTANT: must use OPEN_EXISTING for a COM port
// usually overlapped but non-overlapped for existance test
// always NULL for a general purpose COM port

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

30d100dx65d260d500d1000d ... Show all

Table of Contents