Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 61ac71f953ed
Choose a base ref
...
head repository: azonenberg/starshipraider
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d7ad1ce2da4d
Choose a head ref
  • 1 commit
  • 2 files changed
  • 1 contributor

Commits on Apr 23, 2020

  1. Removed echoing and escape sequence handling from SCPI parser since i…

    …t's now intended to be accessed via line-buffered sockets and not as an interactive shell
    azonenberg committed Apr 23, 2020
    Copy the full SHA
    d7ad1ce View commit details
Showing with 4 additions and 61 deletions.
  1. +4 −58 firmware/BLONDEL/afe-characterization/SCPIParser.cpp
  2. +0 −3 firmware/BLONDEL/afe-characterization/SCPIParser.h
62 changes: 4 additions & 58 deletions firmware/BLONDEL/afe-characterization/SCPIParser.cpp
Original file line number Diff line number Diff line change
@@ -82,75 +82,21 @@ void SCPIParser::OnInputReady()
//End of line means the command is ready to execute
if( (c == '\r') || (c == '\n') )
{
m_uart->PrintString("\n");
//m_uart->PrintString("\n");
m_state = STATE_PARSE;
return;
}

//Backspace
else if(c == 0x7f)
OnBackspace();

//Escape sequences
else if(c == 0x1b)
{
//TODO: don't stall if there's nothing in the fifo

//Next char should be a [
if(m_uart->BlockingRead() != '[')
{
//malformed escape sequence, ignore it
return;
}

//and the actual escape code
char code = m_uart->BlockingRead();
switch(code)
{
//B = down, A = up

case 'C':
//OnRightArrow();
break;

case 'D':
//OnLeftArrow();
break;

default:
break;
}
}

//TODO: tab completion?
else if(c == '\t')
{
}

//Ignore other non-printable characters
//Ignore non-printable characters
else if(!isprint(c))
{
}

//Echo characters as typed
//Process characters
else
OnKey(c);
}

void SCPIParser::OnBackspace()
{
//for now assume we're at end of line

//can't go left of cursor
if(m_cursorPosition == 0)
return;

//Delete the character
//move left, space over the deleted character, move left for good this time
m_uart->Printf("%s %s", CURSOR_LEFT, CURSOR_LEFT);
m_line[m_cursorPosition --] = '\0';
}

void SCPIParser::OnKey(char c)
{
//Don't run off end of buffer
@@ -159,7 +105,7 @@ void SCPIParser::OnKey(char c)

//Append it
m_line[m_cursorPosition ++] = c;
m_uart->PrintBinary(c);
//m_uart->PrintBinary(c);
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 changes: 0 additions & 3 deletions firmware/BLONDEL/afe-characterization/SCPIParser.h
Original file line number Diff line number Diff line change
@@ -70,10 +70,7 @@ class SCPIParser
void OnSet(int channel, const char* field, const char* args);

//Keyboard event handlers
void OnBackspace();
void OnKey(char c);
//void OnLeftArrow();
//void OnRightArrow();

void PrintFloat(float f);
float ParseFloat(const char* str);