return -3;
printf("Clearing Buffer\n");
sendstr("c"); // clear the buffer
- buf[0]='f';
- while ( fread(buf+1, 1, 63, f) )
+ buf[0]='f';
+ size_t len;
+ while ( ( len = fread(buf+1, 1, 63, f) ) )
{
rawhid_send(0, buf, 64, 1000); //fill the buffer
- printf("Sending Buffer\n");
+ printf("Sending Buffer %d bytes\n",len);
+ for(i=0;i<len+1;i++)
+ {
+ printf("%02x ",(unsigned char) buf[i]);
+ }
+ printf("\n");
}
printf("Executing Send command\n");
sendstr("s\x10"); // send 4 times
- size_t len = rawhid_recv(0, buf, 64, 255);
+ len = rawhid_recv(0, buf, 64, 255);
for(i=0;i<len;i++)
{
printf("%02x ",(unsigned char) buf[i]);
#define CPU_PRESCALE(n) (CLKPR = 0x80, CLKPR = (n))
#define RF_SEND_BUFFER_LEN_MAX 502
+
+union multiint {
+ uint16_t u16;
+ uint8_t u8[2];
+} __attribute__((packed));
+
volatile uint16_t output_count=0;
volatile uint8_t active_buffer=0;
volatile uint16_t send_buffer=0;
volatile uint8_t capture=0;
volatile uint16_t rf_send_buf_pos=0; //count of bits in rf_send_buffer that should be sent
-volatile uint16_t rf_send_buf_len=0; //count of bits in rf_send_buffer that should be sent
+volatile union multiint rf_send_buf_len; //count of bits in rf_send_buffer that should be sent
volatile uint8_t rf_send_count=0; // number of repetitions (times rf_send gets reloaded;
uint8_t read_buffer[64]; // buffer for reading usb signals
uint8_t write_buffer[2][64]; // buffer for writing usb signals
{
int8_t buffer_pos = 1;
if(!rf_send_buf_offset) {
- rf_send_buf_len=read_buffer[2] | (read_buffer[1]<<8); //rf_send_buf_offset*8;
+ rf_send_buf_len.u8[1]=read_buffer[1];
+ rf_send_buf_len.u8[0]=read_buffer[2];
buffer_pos+=2;
}
while(buffer_pos < r && rf_send_buf_offset<RF_SEND_BUFFER_LEN_MAX)
}
else if (read_buffer[0]=='s') //send
{
+ write_buffer[0][0]=rf_send_buf_len.u8[1];
+ write_buffer[0][1]=rf_send_buf_len.u8[0];
+ usb_rawhid_send(write_buffer, 23);
capture=0;
rf_send_buf_pos=0;
rf_send_count=read_buffer[1]+1;
ISR(TIMER0_COMPA_vect)
{
PORTF^=2;
- if (rf_send_count && rf_send_buf_pos<rf_send_buf_len)
+ if (rf_send_count && rf_send_buf_pos<rf_send_buf_len.u16)
{
if ( rf_send_buffer[rf_send_buf_pos/8] & (1<< (rf_send_buf_pos%8)))
{