Commit ce2e50c6 authored by Terry Ellison's avatar Terry Ellison Committed by Marcel Stör
Browse files

Updates following JM review

parent 50b69d84
...@@ -165,31 +165,7 @@ uart_tx_one_char(uint8 uart, uint8 TxChar) ...@@ -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
......
...@@ -6,6 +6,5 @@ extern void input_setup(int bufsize, const char *prompt); ...@@ -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 */
...@@ -121,7 +121,7 @@ static char *flashSetPosition(uint32_t offset){ ...@@ -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) { ...@@ -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
......
...@@ -22,12 +22,6 @@ ...@@ -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) { ...@@ -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);
......
...@@ -271,7 +271,7 @@ static int node_output( lua_State* L ) ...@@ -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 */
......
...@@ -31,7 +31,7 @@ static int l_uart_on( lua_State* L ) ...@@ -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))
......
...@@ -27,10 +27,11 @@ concatenated into a 2nd level FIFO entry of upto 256 bytes, and the 1st level FI ...@@ -27,10 +27,11 @@ 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 function telnet_listener(socket) local node, tmr, wifi, uwrite = node, tmr, wifi, uart.write
local function telnet_listener(socket)
local queueLine = (require "fifosock").wrap(socket) local queueLine = (require "fifosock").wrap(socket)
local function receiveLine(s, line) local function receiveLine(s, line)
......
--[[ A telnet server T. Ellison, June 2019 --[[ A telnet server T. Ellison, June 2019
This version of the telnet server demonstrates the use of the new stdin and stout This version of the telnet server demonstrates the use of the new stdin and stout
pipes, which is a C implementation of the Lua fifosock concept moved into the 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
...@@ -31,8 +32,8 @@ local function telnet_session(socket) ...@@ -31,8 +32,8 @@ local function telnet_session(socket)
node.output(output_CB, 0) node.output(output_CB, 0)
socket:on("receive", function(_,rec) node.input(rec) end) socket:on("receive", function(_,rec) node.input(rec) end)
socket:on("sent", onsent_CB) socket:on("sent", onsent_CB)
socket:on("disconnection", disconnect_CB) socket:on("disconnection", disconnect_CB)
print(("Welcome to NodeMCU world (%d mem free, %s)"):format( print(("Welcome to NodeMCU world (%d mem free, %s)"):format(
node.heap(), wifi.sta.getip())) node.heap(), wifi.sta.getip()))
end end
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment