--- fbus.0.6.19 Thu Oct 25 22:32:22 2007 +++ fbus.c Fri Oct 25 22:56:58 2007 @@ -112,7 +112,7 @@ while (res > 0) { /* Avoid 'device temporarily unavailable' error */ usleep(50); - res = device_read(buffer, 255, state); + res = device_read(buffer, 255, state) == 255; } return res; } @@ -348,6 +348,12 @@ if (i->message_type == 0x7f) { dprintf("[Received Ack of type %02x, seq: %2x]\n", i->message_buffer[0], (unsigned char) i->message_buffer[1]); +{ + FILE*f; + f=fopen("/tmp/seq.dat","w"); + fprintf(f, "%d\n", ((unsigned char) i->message_buffer[1] + 1) & 0x07); + fclose(f); +} sm_incoming_acknowledge(state); } else if (i->message_type == 0xf1) { @@ -380,6 +386,10 @@ m->malloced = frm_num * m->message_length; m->message_buffer = (unsigned char *)malloc(m->malloced); + } else if ((seq_num & 0x80) == 0x80) { + dprintf("Possibly wrong sequence counting method.\n"); + /* FIXME - we should make sure we don't ack the rest etc */ + } else if (m->frames_to_go != frm_num) { dprintf("Missed a frame in a multiframe message.\n"); /* FIXME - we should make sure we don't ack the rest etc */ @@ -651,8 +662,15 @@ /* Start up the link */ if ((FBUSINST(state) = calloc(1, sizeof(fbus_link))) == NULL) return GN_ERR_MEMORYFULL; - - FBUSINST(state)->request_sequence_number = 0; +{ + FILE*f; + if(f=fopen("/tmp/seq.dat","r")){ + fscanf(f, "%d\n", &(FBUSINST(state)->request_sequence_number)); + fclose(f); + }else + FBUSINST(state)->request_sequence_number = 0; + dprintf("####init seq:%d\n", FBUSINST(state)->request_sequence_number); +} switch (state->config.connection_type) { case GN_CT_Infrared: