int SC_HID_APIManager::open_device( int vendor, int product, char* serial_number ){ // struct hid_dev_desc * newdevdesc; if ( serial_number != NULL ){ wchar_t * serialW = char_to_wchar( serial_number ); newdevdesc = hid_open_device( vendor, product, serialW ); free(serialW); } else { newdevdesc = hid_open_device( vendor, product, NULL ); } if (!newdevdesc){ post( "HIDAPI: Unable to open device %d, %d %s\n", vendor, product, serial_number ); return -1; } else { hiddevices.insert( std::pair<int,hid_dev_desc*>(number_of_hids, newdevdesc) ); newdevdesc->index = number_of_hids; hid_set_descriptor_callback( newdevdesc, (hid_descriptor_callback) hid_descriptor_cb, &newdevdesc->index ); hid_set_readerror_callback( newdevdesc, (hid_device_readerror_callback) hid_readerror_cb, &newdevdesc->index ); hid_set_element_callback( newdevdesc, (hid_element_callback) hid_element_cb, &newdevdesc->index ); number_of_hids++; mThreads.openDevice(newdevdesc, mShouldBeRunning); return newdevdesc->index; } }
void printStatus(char* expId, char* format, const wchar_t* ip, int type, int port, int isConnected ){ JSONObject root_out; wchar_t expId_t[256]; char_to_wchar(expId_t, expId); wchar_t format_t[256]; char_to_wchar(format_t, format); root_out[L"expId"] = new JSONValue(expId_t); root_out[L"isConnected"] = new JSONValue((double)isConnected); root_out[L"format"] = new JSONValue(format_t); root_out[L"type"] = new JSONValue((double)type); root_out[L"ip"] = new JSONValue(ip); root_out[L"port"] = new JSONValue((double)port); JSONValue *value = new JSONValue(root_out); std::wcout << value->Stringify().c_str() << std::endl; }
int main(int argc, char *argv[]) { (void) argc; wchar_t *wargv0 = char_to_wchar(argv[0]); PyImport_AppendInittab("nfc", PyInit_nfc); Py_SetProgramName(wargv0); free(wargv0); Py_Initialize(); return 0; }
FRESULT f_chdrive_char(const char* path) { if (!char_to_wchar(path)) return FR_INVALID_NAME; return f_chdrive(tmpwchar.u16); }
FRESULT f_mount_char(FATFS* fs, const char* path, BYTE opt) { if (!char_to_wchar(path)) return FR_INVALID_NAME; return f_mount(fs, tmpwchar.u16, opt); }
FRESULT f_open_char(FIL* fp, const char* path, BYTE mode) { if (!char_to_wchar(path)) return FR_INVALID_NAME; return f_open(fp, tmpwchar.u16, mode); }
FRESULT f_opendir_char(DIR* dp, const char* path) { if (!char_to_wchar(path)) return FR_INVALID_NAME; return f_opendir(dp, tmpwchar.u16); }