Updates following JM review

This commit is contained in:
Terry Ellison 2019-07-20 00:45:08 +01:00 committed by Marcel Stör
parent 50b69d8487
commit ce2e50c651
8 changed files with 21 additions and 47 deletions

View File

@ -165,31 +165,7 @@ uart_tx_one_char(uint8 uart, uint8 TxChar)
WRITE_PERI_REG(UART_FIFO(uart) , TxChar); WRITE_PERI_REG(UART_FIFO(uart) , TxChar);
return OK; return OK;
} }
#if 0
/******************************************************************************
* FunctionName : uart1_write_char
* Description : Internal used function
* Do some special deal while tx char is '\r' or '\n'
* Parameters : char c - character to tx
* Returns : NONE
*******************************************************************************/
LOCAL void ICACHE_FLASH_ATTR
uart1_write_char(char c)
{
if (c == '\n')
{
uart_tx_one_char(UART1, '\r');
uart_tx_one_char(UART1, '\n');
}
else if (c == '\r')
{
}
else
{
uart_tx_one_char(UART1, c);
}
}
#endif
/****************************************************************************** /******************************************************************************
* FunctionName : uart0_tx_buffer * FunctionName : uart0_tx_buffer
* Description : use uart0 to transfer buffer * Description : use uart0 to transfer buffer

View File

@ -6,6 +6,5 @@ extern void input_setup(int bufsize, const char *prompt);
extern void input_setup_receive(uart_cb_t uart_on_data_cb, int data_len, char end_char, bool run_input); extern void input_setup_receive(uart_cb_t uart_on_data_cb, int data_len, char end_char, bool run_input);
extern void input_setecho (bool flag); extern void input_setecho (bool flag);
extern void input_setprompt (const char *prompt); extern void input_setprompt (const char *prompt);
extern void input_process_arm(void);
#endif /* READLINE_APP_H */ #endif /* READLINE_APP_H */

View File

@ -121,7 +121,7 @@ static char *flashSetPosition(uint32_t offset){
static char *flashBlock(const void* b, size_t size) { static char *flashBlock(const void* b, size_t size) {
void *cur = flashPosition(); void *cur = flashPosition();
NODE_DBG("flashBlock((%04x),%08x,%04x)\n", curOffset,b,size); NODE_DBG("flashBlock((%04x),%p,%04x)\n", curOffset,b,size);
lua_assert(ALIGN_BITS(b) == 0 && ALIGN_BITS(size) == 0); lua_assert(ALIGN_BITS(b) == 0 && ALIGN_BITS(size) == 0);
platform_flash_write(b, flashAddrPhys+curOffset, size); platform_flash_write(b, flashAddrPhys+curOffset, size);
curOffset += size; curOffset += size;
@ -451,7 +451,8 @@ void procSecondPass (void) {
int i, len = (out->ndx > out->flashLen) ? int i, len = (out->ndx > out->flashLen) ?
(out->flashLen % WRITE_BLOCKSIZE) / WORDSIZE : (out->flashLen % WRITE_BLOCKSIZE) / WORDSIZE :
WRITE_BLOCKSIZE / WORDSIZE; WRITE_BLOCKSIZE / WORDSIZE;
uint32_t *buf = (uint32_t *) out->buffer.byte, flags = 0; uint32_t *buf = (uint32_t *) out->buffer.byte;
uint32_t flags = 0;
/* /*
* Relocate all the addresses tagged in out->flags. This can't be done in * Relocate all the addresses tagged in out->flags. This can't be done in
* place because the out->blocks are still in use as dictionary content so * place because the out->blocks are still in use as dictionary content so

View File

@ -22,12 +22,6 @@
#include "platform.h" #include "platform.h"
extern int debug_errorfb (lua_State *L); extern int debug_errorfb (lua_State *L);
#if 0
extern int pipe_create(lua_State *L);
extern int pipe_read(lua_State *L);
extern int pipe_unread(lua_State *L);
extern int pipe_write(lua_State *L);
#endif
/* /*
** Error Reporting Task. We can't pass a string parameter to the error reporter ** Error Reporting Task. We can't pass a string parameter to the error reporter
** directly through the task interface the call is wrapped in a C closure with ** directly through the task interface the call is wrapped in a C closure with
@ -62,13 +56,15 @@ int luaN_traceback (lua_State *L) {
** an error handler which will catch any error and then post this to the ** an error handler which will catch any error and then post this to the
** registered reporter function as a separate follow-on task. ** registered reporter function as a separate follow-on task.
*/ */
int luaN_call (lua_State *L, int narg, int res, int doGC) { // [-narg, +0, v] int luaN_call (lua_State *L, int narg, int nres, int doGC) { // [-narg, +0, v]
int status; int status;
int base = lua_gettop(L) - narg; int base = lua_gettop(L) - narg;
lua_pushcfunction(L, luaN_traceback); lua_pushcfunction(L, luaN_traceback);
lua_insert(L, base); /* put under args */ lua_insert(L, base); /* put under args */
status = lua_pcall(L, narg, (res < 0 ? LUA_MULTRET : res), base); status = lua_pcall(L, narg, (nres < 0 ? LUA_MULTRET : nres), base);
lua_remove(L, base); /* remove traceback function */ lua_remove(L, base); /* remove traceback function */
if (status && nres >=0)
lua_settop(L, base + nres); /* balance the stack on error */
/* force a complete garbage collection if requested */ /* force a complete garbage collection if requested */
if (doGC) if (doGC)
lua_gc(L, LUA_GCCOLLECT, 0); lua_gc(L, LUA_GCCOLLECT, 0);

View File

@ -271,7 +271,7 @@ static int node_output( lua_State* L )
lua_pushlightfunction(L, &pipe_create); lua_pushlightfunction(L, &pipe_create);
lua_insert(L, 1); lua_insert(L, 1);
lua_pushinteger(L, LUA_TASK_MEDIUM); lua_pushinteger(L, LUA_TASK_MEDIUM);
lua_call(L, 2, 1); /* T[1] = pipe.create(dojob, low_priority) */ lua_call(L, 2, 1); /* T[1] = pipe.create(CB, medium_priority) */
} else { // remove the stdout pipe } else { // remove the stdout pipe
lua_pop(L,1); lua_pop(L,1);
lua_pushnil(L); /* T[1] = nil */ lua_pushnil(L); /* T[1] = nil */

View File

@ -31,7 +31,7 @@ static int l_uart_on( lua_State* L )
if (lua_type( L, stack ) == LUA_TNUMBER) if (lua_type( L, stack ) == LUA_TNUMBER)
{ {
data_len = luaL_checkinteger( L, stack ); data_len = luaL_checkinteger( L, stack );
luaL_argcheck(L, data_len >= 0 && data_len <= LUA_MAXINPUT, stack, "wrong arg range"); luaL_argcheck(L, data_len >= 0 && data_len < LUA_MAXINPUT, stack, "wrong arg range");
stack++; stack++;
} }
else if (lua_isstring(L, stack)) else if (lua_isstring(L, stack))

View File

@ -27,8 +27,9 @@ concatenated into a 2nd level FIFO entry of upto 256 bytes, and the 1st level FI
cleared down to any residue. cleared down to any residue.
]] ]]
local node, table, tmr, wifi, uwrite, tostring = --luacheck: no unused args
node, table, tmr, wifi, uart.write, tostring
local node, tmr, wifi, uwrite = node, tmr, wifi, uart.write
local function telnet_listener(socket) local function telnet_listener(socket)
local queueLine = (require "fifosock").wrap(socket) local queueLine = (require "fifosock").wrap(socket)

View File

@ -5,12 +5,13 @@ pipes, which is a C implementation of the Lua fifosock concept moved into the
Lua core. These two pipes are referenced in the Lua registry. Lua core. These two pipes are referenced in the Lua registry.
]] ]]
--luacheck: no unused args
local M = {} local M = {}
local modname = ... local modname = ...
local function telnet_session(socket) local function telnet_session(socket)
local node = node local node = node
local stdout, sending local stdout
local function output_CB(opipe) -- upval: socket local function output_CB(opipe) -- upval: socket
stdout = opipe stdout = opipe