Skip to content

Commit

Permalink
Improve SADLP-Serial for Arduino
Browse files Browse the repository at this point in the history
  • Loading branch information
ivankravets committed Jun 20, 2015
1 parent 84fbed5 commit ac09a30
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions firmware/src/hal/platforms/arduino/sa-commlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ uint8_t hal_wait_for( waiting_for* wf )
}
}

return WAIT_RESULTED_IN_FAILURE;
return WAIT_RESULTED_IN_FAILURE;
}

uint8_t try_get_message( MEMORY_HANDLE mem_h )
Expand All @@ -47,24 +47,27 @@ uint8_t try_get_message( MEMORY_HANDLE mem_h )
memory_object_response_to_request( mem_h );
uint8_t* buff = memory_object_append( mem_h, MAX_PACKET_SIZE );

uint8_t index = 0, byte;
uint8_t i = 0, byte;
while (Serial.available()) {
byte = Serial.read();
if (byte == END_OF_TRANSMISSION)
{
ZEPTO_DEBUG_ASSERT( i && i <= MAX_PACKET_SIZE );
memory_object_response_to_request( mem_h );
memory_object_cut_and_make_response( mem_h, 0, i );
return COMMLAYER_RET_OK;
}

buff[index++] = byte;
buff[i++] = byte;
}

return COMMLAYER_RET_FAILED;
}

bool communication_initialize()
{
ZEPTO_DEBUG_ASSERT(0);
return false;
Serial.begin(9600);
return true;
}

uint8_t send_message( MEMORY_HANDLE mem_h )
Expand Down

0 comments on commit ac09a30

Please sign in to comment.