command interpreter and epprom

This commit is contained in:
IMback
2017-05-19 09:48:19 +02:00
parent cb779f21d4
commit ecd7ad677b
9 changed files with 282 additions and 58 deletions

View File

@ -26,7 +26,7 @@ void Serial::putChar(const char c)
void Serial::putString(const char* in, const unsigned int length)
{
for(unsigned int i = 0; i < length; i++)
for(unsigned int i = 0; i < length && in[i] != '\0'; i++)
{
putChar(in[i]);
}
@ -56,17 +56,19 @@ char Serial::getChar()
else return '\0';
}
int Serial::getString(char* buffer, const int bufferLength)
unsigned int Serial::getString(char* buffer, const int bufferLength)
{
int i = 0;
for(; i <= (interruptIndex-_rxIndex) && i <= BUFFER_SIZE && rxBuffer[(_rxIndex+i) % BUFFER_SIZE] != _terminator; i++);
if( i < (interruptIndex-_rxIndex) && i > 0)
{
for(int j = 0 ; j < i && j < bufferLength ; j++)
int j = 0;
for(; j < i && j < bufferLength-1 ; j++)
{
buffer[j] = getChar();
}
buffer[j+1]='\0';
_rxIndex++;
}
else