Advantech PCI-1682U Manual de usuario Pagina 67

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 104
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 66
61 PCI-1680U/1682U User Manual
Chapter 4 Software Requirements
Write code in empty source file.
#include <stdio.h>
#include <windows.h>
#include "C:\Program Files\Advantech\AdvCan\Include\AdvCan.h"
void main()
{
HANDLE hDevice = NULL;
CanStatusPar_t CanStatus;
BOOL flag;
ULONG dwReturned;
//Open Can Port "CAN1".
//You can also change "CAN1" to a port name which you have
installed.
hDevice = CreateFile("\\\\.\\can1",
GENERIC_READ | GENERIC_WRITE,
0,
NULL,OPEN_EXISTING,
0,
NULL);
if ( hDevice == INVALID_HANDLE_VALUE )
{
printf( "Open Can Port Error!" );
return;
}
// Get Can port status.
flag = DeviceIoControl( hDevice,
CAN_IOCTL_STATUS,
NULL,
0,
&CanStatus,
sizeof(CanStatusPar_t),
&dwReturned,
0
);
if ( !flag )
{
printf( "GetStatus Error!");
return;
}
printf( "Acceptance code = 0x%x\n" , CanStatus.acceptancecode
);
printf( "Acceptance mask = 0x%x\n" , CanStatus.acceptancemask
);
printf( "Baud = %u\n", CanStatus.baud );
printf( "Self reception = %u\n" , CanStatus.selfreception );
printf( "Read time out = %u\n" , CanStatus.readtimeout );
printf( "Write time out = %u\n" , CanStatus.writetimeout );
//Close port handle
flag =CloseHandle(hDevice);
if ( !flag )
{
printf( "Close Error!");
return;
}
}
Vista de pagina 66
1 2 ... 62 63 64 65 66 67 68 69 70 71 72 ... 103 104

Comentarios a estos manuales

Sin comentarios