mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
CHG: pm3 device will be identified on win10 automatic without drivers. Sadly no com port...
This commit is contained in:
parent
6cebcb4b0a
commit
480c0d0ba0
2 changed files with 59 additions and 63 deletions
|
@ -169,7 +169,7 @@ static const char cfgDescriptor[] = {
|
||||||
_EP03_IN, // EndpointAddress, Endpoint 03-IN
|
_EP03_IN, // EndpointAddress, Endpoint 03-IN
|
||||||
_INTERRUPT, // Attributes
|
_INTERRUPT, // Attributes
|
||||||
0x40, 0x00, // MaxPacket Size (ice 0x200, pm3 0x08)
|
0x40, 0x00, // MaxPacket Size (ice 0x200, pm3 0x08)
|
||||||
0x02, // Interval polling (rfidler 0x02, pm3 0xff)
|
0xFF, // Interval polling (rfidler 0x02, pm3 0xff)
|
||||||
|
|
||||||
/* Data Class Interface Descriptor Requirement */
|
/* Data Class Interface Descriptor Requirement */
|
||||||
0x09, // Length
|
0x09, // Length
|
||||||
|
@ -188,7 +188,7 @@ static const char cfgDescriptor[] = {
|
||||||
_EP01_OUT, // Endpoint Address, Endpoint 01-OUT
|
_EP01_OUT, // Endpoint Address, Endpoint 01-OUT
|
||||||
_BULK, // Attributes BULK
|
_BULK, // Attributes BULK
|
||||||
0x40, 0x00, // MaxPacket Size
|
0x40, 0x00, // MaxPacket Size
|
||||||
0x00, // Interval
|
0x00, // Interval (ignored for bulk)
|
||||||
|
|
||||||
/* Endpoint descriptor */
|
/* Endpoint descriptor */
|
||||||
0x07, // Length
|
0x07, // Length
|
||||||
|
@ -196,7 +196,7 @@ static const char cfgDescriptor[] = {
|
||||||
_EP02_IN, // Endpoint Address, Endpoint 02-IN
|
_EP02_IN, // Endpoint Address, Endpoint 02-IN
|
||||||
_BULK, // Attributes BULK
|
_BULK, // Attributes BULK
|
||||||
0x40, 0x00, // MaxPacket Size
|
0x40, 0x00, // MaxPacket Size
|
||||||
0x00 // Interval
|
0x00 // Interval (ignored for bulk)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Microsoft OS Extended Configuration Compatible ID Descriptor
|
// Microsoft OS Extended Configuration Compatible ID Descriptor
|
||||||
|
@ -744,22 +744,17 @@ void AT91F_CDC_Enumerate() {
|
||||||
|
|
||||||
if ( bRequest == MS_VENDOR_CODE) {
|
if ( bRequest == MS_VENDOR_CODE) {
|
||||||
if ( bmRequestType == MS_WCID_GET_DESCRIPTOR ) { // C0
|
if ( bmRequestType == MS_WCID_GET_DESCRIPTOR ) { // C0
|
||||||
|
|
||||||
if ( wIndex == MS_EXTENDED_COMPAT_ID ) { // 4
|
if ( wIndex == MS_EXTENDED_COMPAT_ID ) { // 4
|
||||||
AT91F_USB_SendData(pUdp, CompatIDFeatureDescriptor, MIN(sizeof(CompatIDFeatureDescriptor), wLength));
|
AT91F_USB_SendData(pUdp, CompatIDFeatureDescriptor, MIN(sizeof(CompatIDFeatureDescriptor), wLength));
|
||||||
} else {
|
return;
|
||||||
AT91F_USB_SendStall(pUdp);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if ( bmRequestType == MS_WCID_GET_FEATURE_DESCRIPTOR ) { //C1
|
if ( bmRequestType == MS_WCID_GET_FEATURE_DESCRIPTOR ) { //C1
|
||||||
if ( wIndex == MS_EXTENDED_PROPERTIES ) { // 5
|
if ( wIndex == MS_EXTENDED_PROPERTIES ) { // 5
|
||||||
AT91F_USB_SendData(pUdp, (char *)&OSPropertyDescriptor, MIN(sizeof(OSPropertyDescriptor), wLength));
|
AT91F_USB_SendData(pUdp, (char *)&OSPropertyDescriptor, MIN(sizeof(OSPropertyDescriptor), wLength));
|
||||||
AT91F_USB_SendData(pUdp, OSprop, MIN(sizeof(OSprop), wLength));
|
//AT91F_USB_SendData(pUdp, OSprop, MIN(sizeof(OSprop), wLength));
|
||||||
} else {
|
return;
|
||||||
AT91F_USB_SendStall(pUdp);
|
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Handle supported standard device request Cf Table 9-3 in USB specification Rev 1.1
|
// Handle supported standard device request Cf Table 9-3 in USB specification Rev 1.1
|
||||||
|
|
|
@ -58,71 +58,71 @@ void upcase(char *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
serial_port uart_open(const char* pcPortName) {
|
serial_port uart_open(const char* pcPortName) {
|
||||||
char acPortName[255];
|
char acPortName[255];
|
||||||
serial_port_windows* sp = malloc(sizeof(serial_port_windows));
|
serial_port_windows* sp = malloc(sizeof(serial_port_windows));
|
||||||
|
|
||||||
if (sp == 0)
|
if (sp == 0)
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
|
|
||||||
// Copy the input "com?" to "\\.\COM?" format
|
// Copy the input "com?" to "\\.\COM?" format
|
||||||
sprintf(acPortName,"\\\\.\\%s", pcPortName);
|
sprintf(acPortName,"\\\\.\\%s", pcPortName);
|
||||||
upcase(acPortName);
|
upcase(acPortName);
|
||||||
|
|
||||||
// Try to open the serial port
|
// Try to open the serial port
|
||||||
sp->hPort = CreateFileA(acPortName, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
sp->hPort = CreateFileA(acPortName, GENERIC_READ|GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);
|
||||||
if (sp->hPort == INVALID_HANDLE_VALUE) {
|
if (sp->hPort == INVALID_HANDLE_VALUE) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Prepare the device control
|
// Prepare the device control
|
||||||
memset(&sp->dcb, 0, sizeof(DCB));
|
memset(&sp->dcb, 0, sizeof(DCB));
|
||||||
sp->dcb.DCBlength = sizeof(DCB);
|
sp->dcb.DCBlength = sizeof(DCB);
|
||||||
if (!BuildCommDCBA("baud=115200 parity=N data=8 stop=1",&sp->dcb)) {
|
if (!BuildCommDCBA("baud=115200 parity=N data=8 stop=1",&sp->dcb)) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the active serial port
|
// Update the active serial port
|
||||||
if (!SetCommState(sp->hPort, &sp->dcb)) {
|
if (!SetCommState(sp->hPort, &sp->dcb)) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
// all zero's configure: no timeout for read/write used.
|
// all zero's configure: no timeout for read/write used.
|
||||||
// took settings from libnfc/buses/uart.c
|
// took settings from libnfc/buses/uart.c
|
||||||
sp->ct.ReadIntervalTimeout = 0;//1;
|
sp->ct.ReadIntervalTimeout = 0;//1;
|
||||||
sp->ct.ReadTotalTimeoutMultiplier = 0;//1;
|
sp->ct.ReadTotalTimeoutMultiplier = 0;//1;
|
||||||
sp->ct.ReadTotalTimeoutConstant = 30;
|
sp->ct.ReadTotalTimeoutConstant = 30;
|
||||||
sp->ct.WriteTotalTimeoutMultiplier = 0;//1;
|
sp->ct.WriteTotalTimeoutMultiplier = 0;//1;
|
||||||
sp->ct.WriteTotalTimeoutConstant = 30;
|
sp->ct.WriteTotalTimeoutConstant = 30;
|
||||||
|
|
||||||
if (!SetCommTimeouts(sp->hPort, &sp->ct)) {
|
if (!SetCommTimeouts(sp->hPort, &sp->ct)) {
|
||||||
uart_close(sp);
|
uart_close(sp);
|
||||||
return INVALID_SERIAL_PORT;
|
return INVALID_SERIAL_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
PurgeComm(sp->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
PurgeComm(sp->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
|
||||||
|
|
||||||
bool success = uart_set_speed(sp, 460800);
|
bool success = uart_set_speed(sp, 460800);
|
||||||
if (!success)
|
if (!success)
|
||||||
uart_set_speed(sp, 115200);
|
uart_set_speed(sp, 115200);
|
||||||
|
|
||||||
return sp;
|
return sp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void uart_close(const serial_port sp) {
|
void uart_close(const serial_port sp) {
|
||||||
if (!sp) return;
|
// if (!sp) return;
|
||||||
if (sp == INVALID_SERIAL_PORT) return;
|
// if (sp == INVALID_SERIAL_PORT) return;
|
||||||
if (sp == CLAIMED_SERIAL_PORT) return;
|
// if (sp == CLAIMED_SERIAL_PORT) return;
|
||||||
if (((serial_port_windows*)sp)->hPort != INVALID_HANDLE_VALUE )
|
if (((serial_port_windows*)sp)->hPort != INVALID_HANDLE_VALUE )
|
||||||
CloseHandle(((serial_port_windows*)sp)->hPort);
|
CloseHandle(((serial_port_windows*)sp)->hPort);
|
||||||
free(sp);
|
free(sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_t* pszRxLen) {
|
bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_t* pszRxLen) {
|
||||||
//ReadFile(((serial_port_windows*)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
ReadFile(((serial_port_windows*)sp)->hPort, pbtRx, pszMaxRxLen, (LPDWORD)pszRxLen, NULL);
|
||||||
//return (*pszRxLen != 0);
|
return (*pszRxLen != 0);
|
||||||
|
/*
|
||||||
DWORD dwBytesToGet = (DWORD)pszMaxRxLen;
|
DWORD dwBytesToGet = (DWORD)pszMaxRxLen;
|
||||||
DWORD dwBytesReceived = 0;
|
DWORD dwBytesReceived = 0;
|
||||||
DWORD dwTotalBytesReceived = 0;
|
DWORD dwTotalBytesReceived = 0;
|
||||||
|
@ -144,6 +144,7 @@ bool uart_receive(const serial_port sp, byte_t* pbtRx, size_t pszMaxRxLen, size_
|
||||||
} while (((DWORD)pszMaxRxLen) > dwTotalBytesReceived);
|
} while (((DWORD)pszMaxRxLen) > dwTotalBytesReceived);
|
||||||
|
|
||||||
return (dwTotalBytesReceived == (DWORD) pszMaxRxLen);
|
return (dwTotalBytesReceived == (DWORD) pszMaxRxLen);
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) {
|
bool uart_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue