-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial SD script support * Comments in script files are ignored * Added startup script option * Indent fix
- Loading branch information
Showing
9 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* HydraBus/HydraNFC | ||
* | ||
* Copyright (C) 2016 Nicolas OBERLI | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#include "ff.h" | ||
#include "microsd.h" | ||
|
||
static uint8_t inbuf[IN_OUT_BUF_SIZE+8]; | ||
|
||
int execute_script(t_hydra_console *con, char *filename) | ||
{ | ||
FRESULT err; | ||
FIL fp; | ||
int i; | ||
if (!is_fs_ready()) { | ||
err = mount(); | ||
if(err) { | ||
cprintf(con, "Mount failed: error %d.\r\n", err); | ||
return FALSE; | ||
} | ||
} | ||
|
||
err = f_open(&fp, (TCHAR *)filename, FA_READ | FA_OPEN_EXISTING); | ||
if (err != FR_OK) { | ||
cprintf(con, "Failed to open file %s: error %d.\r\n", filename, err); | ||
return FALSE; | ||
} | ||
|
||
/* Clear any input in tokenline buffer */ | ||
tl_input(con->tl, 0x03); | ||
|
||
while(!f_eof(&fp)) { | ||
f_gets((TCHAR *)inbuf, IN_OUT_BUF_SIZE, &fp); | ||
i=0; | ||
if(inbuf[0] == '#') { | ||
continue; | ||
} | ||
while(inbuf[i] != '\0') { | ||
tl_input(con->tl, inbuf[i]); | ||
i++; | ||
} | ||
} | ||
return TRUE; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* HydraBus/HydraNFC | ||
* | ||
* Copyright (C) 2016 Nicolas OBERLI | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
int execute_script(t_hydra_console *con, char *filename); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -128,6 +128,7 @@ enum { | |
T_LOW, | ||
T_HIGH, | ||
T_THREEWIRE, | ||
T_SCRIPT, | ||
|
||
/* BP-compatible commands */ | ||
T_LEFT_SQ, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters