// protocol for control SevenOcean's Machine // ////////////////////////////////////////////////////////////////////// #ifndef AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_ #define AFX_KEYENCE_Proto_H__B422904C_2CEB_495B_B7BD_B45AB30286DD__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #include "..\..\..\..\..\ThirdParty\UsbSupport\LibUsb_Win\Include\lusb0_usb.h" #include "..\Keyence\KeyenceStatus.h" #define _CMD0_0800 0x08000000 #define _CMD0_0C00 0x0c000000 // -> 0704 Reply 0800 0705 // -> 0710 Reply 0c00 0711 // -> 071a Reply 8400 071b #define _CMD0_100a 0x100a0000 // -> 0730 Reply 0c00 0731 #define _CMD0_1400 0x14000000 // ???? Send 4 bytes 1400, // then send 200 bytes // Request 40000 bytes image #define _CMD0_3000 0x30000000 // -> 0730 Reply 0c00 0731 #define _CMD0_4800 0x48000000 // -> 0730 Reply 0c00 0731 #define _CMD0_4c00 0x4c000000 // -> 0730 Reply 0c00 0731 #define _CMD1_0730 0x07300000 #define _CMD1_0731 0x07310000 #define MAX_KEYENCE_EP_01_BUFF_SIZE 0xC00 // enough for 512x512 bytes image #define MAX_KEYENCE_EP_82_BUFF_SIZE 0x40000 // enough for 512x512 bytes image #define MAX_KEYENCE_EP_BUFF_SIZE 0X40000 #define USB_ENDPOINT_TYPE_CONTROL 0 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 1 #define USB_ENDPOINT_TYPE_BULK 2 #define USB_ENDPOINT_TYPE_INTERRUPT 3 #define USB_DEVICE_DESCRIPTOR_TYPE 1 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 2 // Device configuration and interface id. #define KEYENCE_USB_CONFIG 1 #define KEYENCE_USB_INTF 0 #define EP_KEYENCE_01 0x01 #define EP_KEYENCE_82 0x82 #pragma pack(push) #pragma pack(1) #define KEYENCE_VID 0x0720 #define KEYENCE_PID 0x000A struct struct_ep { char *_buff; DWORD _cmd0; DWORD _cmd1; int _size; void *_async_context; }; //====================================================================================== class CKeyence_Proto { public: // CKeyence_Proto(); virtual ~CKeyence_Proto(); struct_ep ep_buff_ep01; union { struct_ep ep_buff_ep82; struct_ep ep_buff; }; usb_dev_handle *g_dev; int Init_Keyence(); int Exit_Keyence(); void _process_rcv_transfer_data_ep01(); void _process_rcv_transfer_data_ep82(); usb_dev_handle* _open_usb_dev(void); int _usb_reset(void); int _start_machine(); int _shutdown_machine(); int _send_usb_data(); int _send_cmd_KEYENCE_CMD_GET_LASER_DATA(); int _process_KEYENCE_CMD_GET_LASER_DATA(); int _get_image(); int _put_program(); int _read_env(); int _write_env(); int _set_config(); // sets trigger etc. int _replay_capture(CString cFileName); }; #endif