Changed remaining length parmeters from uint32_t to size_t (Should fix Issue 32).

This commit is contained in:
Romuald Conty 2009-10-02 13:41:49 +00:00
parent 979f1fa518
commit e1a58e18d9
4 changed files with 26 additions and 26 deletions

View file

@ -187,10 +187,10 @@ bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
// Prepare and transmit the send buffer
memcpy(abtTxBuf+5,pbtTx,szTxLen);
szRxBufLen = sizeof(abtRxBuf);
#ifdef DEBUG
printf(" TX: ");
print_hex(abtTxBuf,szTxLen+5);
#endif
#ifdef DEBUG
printf(" TX: ");
print_hex(abtTxBuf,szTxLen+5);
#endif
if (pdsa->ioCard.dwProtocol == SCARD_PROTOCOL_UNDEFINED)
{
@ -213,10 +213,10 @@ bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
if (SCardTransmit(pdsa->hCard,&(pdsa->ioCard),abtRxCmd,szRxCmdLen,NULL,abtRxBuf,(void*)&szRxBufLen) != SCARD_S_SUCCESS) return false;
}
#ifdef DEBUG
printf(" RX: ");
print_hex(abtRxBuf,szRxBufLen);
#endif
#ifdef DEBUG
printf(" RX: ");
print_hex(abtRxBuf,szRxBufLen);
#endif
// When the answer should be ignored, just return a succesful result
if (pbtRx == NULL || pszRxLen == NULL) return true;
@ -224,7 +224,7 @@ bool dev_acr122_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t
// Make sure we have an emulated answer that fits the return buffer
if (szRxBufLen < 4 || (szRxBufLen-4) > *pszRxLen) return false;
// Wipe out the 4 APDU emulation bytes: D5 4B .. .. .. 90 00
*pszRxLen = ((uint32_t)szRxBufLen)-4;
*pszRxLen = ((size_t)szRxBufLen)-4;
memcpy(pbtRx,abtRxBuf+2,*pszRxLen);
// Transmission went successful

View file

@ -29,7 +29,7 @@ dev_info* dev_arygon_connect(const nfc_device_desc_t* device_desc);
void dev_arygon_disconnect(dev_info* pdi);
// Callback function used by libnfc to transmit commands to the PN53X chip
bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const uint32_t uiTxLen, byte_t* pbtRx, uint32_t* puiRxLen);
bool dev_arygon_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen);
#endif // _LIBNFC_DEV_ARYGON_H_

View file

@ -110,7 +110,7 @@ bool nfc_initiator_select_tag(const dev_info* pdi, const init_modulation im, con
* The NFC device will try to find the available target. The standards (ISO18092 and ECMA-340) describe the modulation that can be used for reader to passive communications.
* @note tag_info_dep will be returned when the target was acquired successfully.
*/
bool nfc_initiator_select_dep_target(const dev_info* pdi, const init_modulation im, const byte_t* pbtPidData, const uint32_t szPidDataLen, const byte_t* pbtNFCID3i, const uint32_t szNFCID3iDataLen, const byte_t *pbtGbData, const uint32_t szGbDataLen, tag_info* pti);
bool nfc_initiator_select_dep_target(const dev_info* pdi, const init_modulation im, const byte_t* pbtPidData, const size_t szPidDataLen, const byte_t* pbtNFCID3i, const size_t szNFCID3iDataLen, const byte_t *pbtGbData, const size_t szGbDataLen, tag_info* pti);
/**
* @fn nfc_initiator_deselect_tag(const dev_info* pdi);
* @brief Deselect a selected passive or emulated tag
@ -207,7 +207,7 @@ bool nfc_target_receive_bytes(const dev_info* pdi, byte_t* pbtRx, size_t* pszRxL
bool nfc_target_receive_dep_bytes(const dev_info* pdi, byte_t* pbtRx, size_t* pszRxLen);
/**
* @fn nfc_target_send_bits(const dev_info* pdi, const byte_t* pbtTx, const uint32_t szTxBits, const byte_t* pbtTxPar)
* @fn nfc_target_send_bits(const dev_info* pdi, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar)
* @brief Send raw bit-frames
* @return Returns true if action was successfully performed; otherwise returns false.
*
@ -216,7 +216,7 @@ bool nfc_target_receive_dep_bytes(const dev_info* pdi, byte_t* pbtRx, size_t* ps
bool nfc_target_send_bits(const dev_info* pdi, const byte_t* pbtTx, const size_t szTxBits, const byte_t* pbtTxPar);
/**
* @fn nfc_target_send_bytes(const dev_info* pdi, const byte_t* pbtTx, const uint32_t szTxLen)
* @fn nfc_target_send_bytes(const dev_info* pdi, const byte_t* pbtTx, const size_t szTxLen)
* @brief Send bytes and APDU frames
* @return Returns true if action was successfully performed; otherwise returns false.
*

View file

@ -173,7 +173,7 @@ bool rs232_cts(const serial_port sp)
return (status & TIOCM_CTS);
}
bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen)
{
int iResult;
int byteCount;
@ -187,13 +187,13 @@ bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
// Read error
if (iResult < 0) {
DBG("RX error.");
*puiRxLen = 0;
*pszRxLen = 0;
return false;
}
// Read time-out
if (iResult == 0) {
DBG("RX time-out.");
*puiRxLen = 0;
*pszRxLen = 0;
return false;
}
@ -203,20 +203,20 @@ bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
// Empty buffer
if (byteCount == 0) {
DBG("RX empty buffer.");
*puiRxLen = 0;
*pszRxLen = 0;
return false;
}
// There is something available, read the data
*puiRxLen = read(((serial_port_unix*)sp)->fd,pbtRx,byteCount);
*pszRxLen = read(((serial_port_unix*)sp)->fd,pbtRx,byteCount);
return (*puiRxLen > 0);
return (*pszRxLen > 0);
}
bool rs232_send(const serial_port sp, const byte_t* pbtTx, const uint32_t uiTxLen)
bool rs232_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
{
int iResult;
iResult = write(((serial_port_unix*)sp)->fd,pbtTx,uiTxLen);
iResult = write(((serial_port_unix*)sp)->fd,pbtTx,szTxLen);
return (iResult >= 0);
}
@ -328,16 +328,16 @@ bool rs232_cts(const serial_port sp)
return (dwStatus & MS_CTS_ON);
}
bool rs232_receive(const serial_port sp, byte_t* pbtRx, uint32_t* puiRxLen)
bool rs232_receive(const serial_port sp, byte_t* pbtRx, size_t* pszRxLen)
{
ReadFile(((serial_port_windows*)sp)->hPort,pbtRx,*puiRxLen,(LPDWORD)puiRxLen,NULL);
return (*puiRxLen != 0);
ReadFile(((serial_port_windows*)sp)->hPort,pbtRx,*pszRxLen,(LPDWORD)pszRxLen,NULL);
return (*pszRxLen != 0);
}
bool rs232_send(const serial_port sp, const byte_t* pbtTx, const uint32_t uiTxLen)
bool rs232_send(const serial_port sp, const byte_t* pbtTx, const size_t szTxLen)
{
DWORD dwTxLen = 0;
return WriteFile(((serial_port_windows*)sp)->hPort,pbtTx,uiTxLen,&dwTxLen,NULL);
return WriteFile(((serial_port_windows*)sp)->hPort,pbtTx,szTxLen,&dwTxLen,NULL);
return (dwTxLen != 0);
}