Sniffer with ringbuf, works SOMETIMES

* Sniffer uses phone endpoints for communication and the ringbuffer
    routines the phone communication uses
* Most times the Usart1 interrupt is not triggered, and therefore
    no values are recorded
This commit is contained in:
Christina Quast
2015-04-12 09:31:36 +02:00
parent 5c6a299c71
commit 2b8a18bf3a
11 changed files with 80 additions and 72 deletions

View File

@@ -124,7 +124,6 @@ static const Pin pinPhoneRST = PIN_ISO7816_RST_PHONE;
/** Variable for state of send and receive froom USART */
static uint8_t StateUsartGlobal = USART_RCV;
static bool write_to_host_in_progress = false;
static uint8_t host_to_sim_buf[BUFLEN];
/*-----------------------------------------------------------------------------
@@ -306,42 +305,6 @@ void Phone_init( void ) {
}
void USB_write_callback(uint8_t *pArg, uint8_t status, uint32_t transferred, uint32_t remaining)
{
if (status != USBD_STATUS_SUCCESS) {
TRACE_ERROR("USB err status: %d (%s)\n", __FUNCTION__, status);
}
write_to_host_in_progress = false;
}
int send_to_host()
{
static uint8_t msg[RING_BUFLEN];
int ret = 0;
int i;
for(i = 0; !rbuf_is_empty(&sim_rcv_buf); i++) {
msg[i] = rbuf_read(&sim_rcv_buf);
}
write_to_host_in_progress = true;
ret = USBD_Write( PHONE_DATAIN, msg, i, (TransferCallback)&USB_write_callback, 0 );
return ret;
}
int check_data_from_phone()
{
int ret = 0;
while (rbuf_is_empty(&sim_rcv_buf) || write_to_host_in_progress == true)
__WFI();
ret = send_to_host();
if (ret != USBD_STATUS_SUCCESS) {
TRACE_ERROR("Error sending to host (%x)", ret);
return ret;
}
return ret;
}
// Sniffed Phone to SIM card communication:
// phone > sim : RST
// phone < sim : ATR