Exemplo n.º 1
0
CDeviceCAN::~CDeviceCAN()
{
	 HINSTANCE CANDll = NULL;
	 CloseCAN();
	CANDll = GetModuleHandle(TEXT("ControlCAN"));
	if(CANDll != NULL)
		FreeLibrary(CANDll);//释放动态库句柄
	 CANDll = GetModuleHandle(TEXT("PCAN_USB"));
	if(CANDll != NULL)
		FreeLibrary(CANDll);//释放动态库句柄
}
Exemplo n.º 2
0
/////////////////////////////////////////////////////////////////////////////////////////
// Program main
int _tmain(int argc, _TCHAR* argv[])
{
	PrintInstruction();

	memset(controlWord, 0, LEG_COUNT*LEG_JDOF*sizeof(controlWord[0][0]));
	memset(statusWord, 0, LEG_COUNT*LEG_JDOF*sizeof(statusWord[0][0]));
	memset(homingStatus, 0, LEG_COUNT*LEG_JDOF*sizeof(homingStatus[0][0]));
	for (int ch = 0; ch < CAN_Ch_COUNT; ch++) {
		for (int node = 0; node < NODE_COUNT; node++)  {
			if (node == 0) homingStatus[ch][node] = HOMING_DONE;
			else homingStatus[ch][node] = HOMING_NONE;
		}
	}

	// open CAN channel:
	if (!OpenCAN())
		return -1;

	DriveReset();
	DriveInit();

	// start periodic communication:
//	printf("start periodic communication...\n");
//	StartCANListenThread();

	/*SetModeOfOperation();
	Sleep(50);
	ReadyToSwitchOn();
	Sleep(50);
	SwitchedOn();
	Sleep(50);
	OperationEnable();
	Sleep(50);*/
	/*Shutdown();
	Sleep(50);*/

	// loop wait user input:
	printf("main loop...\n");
	MainLoop();

	// stop periodic communication:
//	printf("stop periodic communication...\n");
//	StopCANListenThread();
	
	DriveOff();

	// close CAN channel:
	CloseCAN();

	return 0;
}