Skip to content

Instantly share code, notes, and snippets.

@TerryE
TerryE / APIchanges.lst
Created November 7, 2015 15:08
List of Esp8266 SDK API changes 0.95 -> 1.4
(1.1) at_register_response_func:register a callback for user-define AT response.
(1.0) at_register_uart_rx_intr:set UART0 to be used by user or AT commands
(1.1) at_response:set AT response
(1.0) espconn_clear_opt: clear configuration of TCP connection
(1.1) espconn_dns_setserver : set default DNS server
(1.0) espconn_get_keepalive: get configuration of TCP keep-alive
(1.0) espconn_mdns_close: close mDNS 
(1.0) espconn_mdns_disable: disable mDNS 
(1.0) espconn_mdns_enable: endisable mDNS 
(1.0) espconn_mdns_get_hostname: set mDNS host name 
@TerryE
TerryE / op_counts.php
Last active December 22, 2015 14:29
Simple RDTSC-based instrumentation of PHP 5.5.3
<?php
/*
* Simple parser of op_counts file. Output is desgined to be pasted / imported into spreadsheet
* for further analysis.
*/
define('PHP_SOURCE_DIR', '~/work/php55'); /* replace as required */
define('OP_COUNT', 164*25); /* as at PHP 5.5 */
define('OP_COUNT_EXTRAS', 5);
$total_count = array_fill(0, OP_COUNT + OP_COUNT_EXTRAS, 0);
$total_cycles = array_fill(0, OP_COUNT + OP_COUNT_EXTRAS, 0);
@TerryE
TerryE / Terry_005.phpt
Last active December 31, 2015 21:48
OPcache Tests
--TEST--
Validate corrrect optimisation of defined, constant, function_exists, is_callable, extension_loaded
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.optimization_level=-1
opcache.file_update_protection=0
--SKIPIF--
<?php if (!extension_loaded('Zend OPcache') || php_sapi_name() != "cli") die("skip CLI only"); ?>
--FILE--
@TerryE
TerryE / Terry_007.phpt
Created December 23, 2013 00:24
Optimization binding of class constants is not safely opcacheable
--TEST--
Optimization binding of class constants is not safely opcacheable
--INI--
opcache.enable=0
--SKIPIF--
<?php if (!extension_loaded('Zend OPcache') || php_sapi_name() != "cli") die("skip CLI only"); ?>
--FILE--
<?php
$root = str_replace('.php', "", __FILE__);
$base = basename( $root );
@TerryE
TerryE / generate_user_modules.lua
Last active February 17, 2016 16:47
generate_user_modules.lua
#! /usr/bin/lua
--[[
This Lua script will build your user_config.h and user_modules.h file in your app/includes
directory. Maintain a user.cnf file in this directory and then run
tools/generate_user_modules.lua
from the root nodemcy directory. The cnf file contains directives of the following form,
and most have sensible defaults so only need to specify the ones that you want to override.
@TerryE
TerryE / enum_reg_funcs.lua
Created February 19, 2016 15:17
Module net leakgages
-- Q & D function form of require tk enumerate the regristry fu7nctions
return function(delim,nocall)
print( '+++'..(delim or '==============='))
for i = 1,3 do collectgarbage() end
for i,f in ipairs(debug.getregistry()) do
print (i,f)
if type(f)=='function' and not nocall then
uart.write(0, ' Dummmy -')
local ok, msg = pcall(f, 'socket','Data-'..i)
if not ok then print(msg) end
@TerryE
TerryE / benchmark.lua
Last active February 20, 2016 23:52
benchmark.lua
function benchmark(count1,count2,opt)
local workLoop,fn = [[
local x,clr,n = "",tmr.wdclr,...;
for i = 1, n,1 do x = x .. "."; if n%100 == 0 then clr() end end;
return x:len()
]]
file.open("test.lua","w"); file.writeline(workLoop); file.close()
if opt == 1 then
fn = loadstring(workLoop)
diff --git a/app/include/user_config.h b/app/include/user_config.h
index 8060253..9a07daf 100644
--- a/app/include/user_config.h
+++ b/app/include/user_config.h
@@ -42,6 +42,7 @@
#endif /* NODE_ERROR */
#define GPIO_INTERRUPT_ENABLE
+#define GPIO_INTERRUPT_HOOK_ENABLE
// #define GPIO_SAFE_NO_INTR_ENABLE
@TerryE
TerryE / LROR Paper.md
Last active July 1, 2017 11:20
LROR Paper.md

LROR (Lua Read-Only Resources) in NodeMCU Lua 5.3

Drafting Caveat

Updates since last realease:

  • Extra details on the multi-host make system
  • Extra details on the legacy module support and how this can be used to compile and run modules written for the Lua 5.1 version with no or minimal source changes.
  • Slight rework of ROTable implementation to support the same.
@TerryE
TerryE / debug_log.md
Last active March 26, 2018 13:28
Example Remote debug session

If you need to do C level debugging, then you need to compile the relevant files / subdirectories with -ggdb and -O0. Don't compile everything with -O0 because the resulting firmware image will be too large.

In this case I am debuggin the lua core so I have modified the app/lua/Makefile to set the debug defines and select the correct compiler options. I have also enabled break at startup on GPIO pin low. With the pin pulled low, the RTS traps into the gdb client, and I can connect to it using the xtensa remote debugger on the host.

What this debugging feature does is to call a common routine which