Updates following JM review
This commit is contained in:
parent
50b69d8487
commit
ce2e50c651
|
@ -165,31 +165,7 @@ uart_tx_one_char(uint8 uart, uint8 TxChar)
|
|||
WRITE_PERI_REG(UART_FIFO(uart) , TxChar);
|
||||
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
|
||||
* Description : use uart0 to transfer buffer
|
||||
|
|
|
@ -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_setecho (bool flag);
|
||||
extern void input_setprompt (const char *prompt);
|
||||
extern void input_process_arm(void);
|
||||
|
||||
#endif /* READLINE_APP_H */
|
||||
|
|
|
@ -121,7 +121,7 @@ static char *flashSetPosition(uint32_t offset){
|
|||
|
||||
static char *flashBlock(const void* b, size_t size) {
|
||||
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);
|
||||
platform_flash_write(b, flashAddrPhys+curOffset, size);
|
||||
curOffset += size;
|
||||
|
@ -451,7 +451,8 @@ void procSecondPass (void) {
|
|||
int i, len = (out->ndx > out->flashLen) ?
|
||||
(out->flashLen % 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
|
||||
* place because the out->blocks are still in use as dictionary content so
|
||||
|
|
|
@ -22,12 +22,6 @@
|
|||
#include "platform.h"
|
||||
|
||||
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
|
||||
** 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
|
||||
** 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 base = lua_gettop(L) - narg;
|
||||
lua_pushcfunction(L, luaN_traceback);
|
||||
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 */
|
||||
if (status && nres >=0)
|
||||
lua_settop(L, base + nres); /* balance the stack on error */
|
||||
/* force a complete garbage collection if requested */
|
||||
if (doGC)
|
||||
lua_gc(L, LUA_GCCOLLECT, 0);
|
||||
|
|
|
@ -271,7 +271,7 @@ static int node_output( lua_State* L )
|
|||
lua_pushlightfunction(L, &pipe_create);
|
||||
lua_insert(L, 1);
|
||||
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
|
||||
lua_pop(L,1);
|
||||
lua_pushnil(L); /* T[1] = nil */
|
||||
|
|
|
@ -31,7 +31,7 @@ static int l_uart_on( lua_State* L )
|
|||
if (lua_type( L, stack ) == LUA_TNUMBER)
|
||||
{
|
||||
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++;
|
||||
}
|
||||
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
|
|||
cleared down to any residue.
|
||||
|
||||
]]
|
||||
local node, table, tmr, wifi, uwrite, tostring =
|
||||
node, table, tmr, wifi, uart.write, tostring
|
||||
--luacheck: no unused args
|
||||
|
||||
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 function receiveLine(s, line)
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
--[[ A telnet server T. Ellison, June 2019
|
||||
|
||||
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
|
||||
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
|
||||
Lua core. These two pipes are referenced in the Lua registry.
|
||||
|
||||
]]
|
||||
--luacheck: no unused args
|
||||
|
||||
local M = {}
|
||||
local modname = ...
|
||||
local function telnet_session(socket)
|
||||
local function telnet_session(socket)
|
||||
local node = node
|
||||
local stdout, sending
|
||||
local stdout
|
||||
|
||||
local function output_CB(opipe) -- upval: socket
|
||||
stdout = opipe
|
||||
|
@ -31,8 +32,8 @@ local function telnet_session(socket)
|
|||
|
||||
node.output(output_CB, 0)
|
||||
socket:on("receive", function(_,rec) node.input(rec) end)
|
||||
socket:on("sent", onsent_CB)
|
||||
socket:on("disconnection", disconnect_CB)
|
||||
socket:on("sent", onsent_CB)
|
||||
socket:on("disconnection", disconnect_CB)
|
||||
print(("Welcome to NodeMCU world (%d mem free, %s)"):format(
|
||||
node.heap(), wifi.sta.getip()))
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue