Attempt to implement working simcard emulator

The BUFLEN is fixed 5 bytes now, which has to be increased.
A timeout has to be implemented, which is smaller than max_waittime.
If the timeout is triggered, the data received in the buffer so far
should be sent to the host computer which is responsible for generating
a response. Without the timeout the max_waittime of the phone would
expire and it would repeat sending the command, so that we do not
have atomary messages anymore.
This commit is contained in:
Christina Quast
2015-03-18 18:41:19 +01:00
parent 69734e9ad9
commit ce296b9def
3 changed files with 84 additions and 37 deletions

View File

@@ -53,9 +53,9 @@ ring_buffer buf = { {0}, 0 };
void buf_push(uint8_t item)
{
buf.buf[buf.idx % (BUFLEN*2)] = item;
buf.buf[buf.idx % (BUFLEN)] = item;
PR("----- Push: %x %x\n\r", buf.idx, buf.buf[buf.idx]);
buf.idx = (buf.idx+1) % (BUFLEN*2);
buf.idx = (buf.idx+1) % (BUFLEN);
}
uint8_t get_buf_start(uint8_t *buf_start)
@@ -144,7 +144,7 @@ void USART1_IrqHandler( void )
PR("%x\n\r", (USART_PHONE->US_RHR) & 0xFF);
} /* else: error occured */
if ((buf.idx % BUFLEN) == 0) {
if ((buf.idx % BUFLEN) == BUFLEN-1) {
rcvdChar = 1;
}