-
what is wrong with my sample code - any comments ?
online with WEB IDE
var bla = { init : function() { console.log("bla.init"); this.foo(); this.bar(); }, foo : function() { console.log("bla.foo"); }, bar : function() { console.log("bla.bar"); } } > bla.init(); /* output bla.init bla.foo bla.bar */
with E.on(): Uncaught Error.....
var bla = { init : function() { console.log("bla.init"); this.foo(); this.bar(); }, foo : function() { console.log("bla.foo"); }, bar : function() { console.log("bla.bar"); } } E.on("init",bla.init) setTimeout(save,2000); /* output bla.init Uncaught Error: Function "foo" not found! at line 2 col 10 this.foo(); ^ in function called from system */
-
-
-
@Frida please double check i2c_master.c and jshardware.h
@tve please also take a detailed look, if possible.
-
-
created pull request #874
-
comment this line and you get this:
tcpdump -XX -nnr x.pcap | grep ICMP
reading from PCAP-NG file x.pcap
21:00:53.676020 IP 192.168.194.64 > 192.168.194.52: ICMP echo request, id 44975, seq 1, length 40
21:00:53.676059 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 1, length 40
21:00:54.791637 IP 192.168.194.64 > 192.168.194.52: ICMP echo request, id 44975, seq 2, length 40
21:00:54.791662 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 2, length 40@tve please check
-
-
@tve take it and let you get payed for your great work on Esprunino for ESPs at Bug Bounty
>require("ESP8266").getState() ={ "sdkVersion": "1.5.4(baaeaebb)", "cpuFrequency": 160, "freeHeap": 8960, "maxCon": 10, "flashMap": "4MB:512/512", "flashKB": 4096, "flashChip": "0xe0 0x4016" } >ESP8266.ping("192.168.194.52"); 23417> >> ping ip: 192.168.194.52 : 14 =undefined > 23423> Received a ping response! 24523> Received a ping response! 25623> Received a ping response! 26723> Received a ping response! 27773> Received a ping response! 28922> ping 5, timeout 0, total payload 160 bytes, 5504 ms
-
ESP on 192.168.194.65, Macbook on 192.168.194.52
ESP pings Macbook and Macbook captures packages with tcpdump
tcpdump -s 1550 -w x.pcap -v host 192.168.194.64
tcpdump: data link type PKTAP
tcpdump: listening on pktap, link-type PKTAP (Packet Tap), capture size 1550 bytes
10 packets captured
87 packets received by filter
0 packets dropped by kerneltcpdump -XX -nnr x.pcap | grep ICMP
reading from PCAP-NG file x.pcap
17:13:10.851201 IP 192.168.194.64 > 0.0.0.0: ICMP echo request, id 44975, seq 11, length 40
17:13:10.851227 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 11, length 40
17:13:11.772757 IP 192.168.194.64 > 0.0.0.0: ICMP echo request, id 44975, seq 12, length 40
17:13:11.772777 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 12, length 40
17:13:13.001780 IP 192.168.194.64 > 0.0.0.0: ICMP echo request, id 44975, seq 13, length 40
17:13:13.001813 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 13, length 40
17:13:13.933726 IP 192.168.194.64 > 0.0.0.0: ICMP echo request, id 44975, seq 14, length 40
17:13:13.933756 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 14, length 40
17:13:15.107559 IP 192.168.194.64 > 0.0.0.0: ICMP echo request, id 44975, seq 15, length 40
17:13:15.107585 IP 192.168.194.52 > 192.168.194.64: ICMP echo reply, id 44975, seq 15, length 40funny .....
-
also works for me with sdk 1.5.4
>require("ESP8266").getState(); ={ "sdkVersion": "1.5.4(baaeaebb)", "cpuFrequency": 160, "freeHeap": 9144, "maxCon": 10, "flashMap": "4MB:512/512", "flashKB": 4096, "flashChip": "0xe0 0x4016" } >var ESP8266=require("ESP8266"); =function () { [native code] } >var Wifi = require("Wifi") =function () { [native code] } >Wifi.getIP(); ={ "ip": "192.168.194.64", "netmask": "255.255.255.0", "gw": "192.168.194.1", "mac": "5c:cf:7f:05:c1:00" } >ESP8266.setLog(2); =undefined >ESP8266.ping("192.168.2.1", function(e){ console.log(e);}); =undefined >140681> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 5, "seqNo": 1, "timeoutCount": 0, "bytes": 32, "error": 0 } >141775> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 2, "seqNo": 2, "timeoutCount": 0, "bytes": 32, "error": 0 } >142824> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 3, "timeoutCount": 0, "bytes": 32, "error": 0 } >144024> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 4, "timeoutCount": 0, "bytes": 32, "error": 0 } >145149> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 5, "timeoutCount": 0, "bytes": 32, "error": 0 } >146322> ping 5, timeout 0, total payload 160 bytes, 5646 ms
-
-
-
on ESP you can use this with the latest build
I2C1.setup({sda: D4, scl: D5} ); function isDeviceOnBus(i2c, addr) { try { return i2c.readFrom(addr,1); } catch(err) { return -1; } } function i2cdetect( i2c, first, last ) { if (typeof first === "undefined") first = 0x03; if (typeof (last) === "undefined") last = 0x77; print( " 0 1 2 3 4 5 6 7 8 9 a b c d e f" ); for (var upper = 0; upper < 8; ++upper) { var line = upper + "0: "; for (var lower = 0; lower < 16; ++lower) { var address = (upper << 4) + lower; // Skip unwanted addresses if ((address < first) || (address > last)) { line += " "; continue; } if ( ! isDeviceOnBus(i2c,address) ){ line += (address + 0x100).toString( 16 ).substr( -2 )+" "; } else line += "-- "; } print( line ); } } i2cdetect( I2C1, 0x03, 0x77); /* sample output for a connected PCA9635 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: 60 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: 70 -- -- -- -- -- -- -- */
-
@Frida now I found some time to test this nice modifications
step one build a version with your modification and run some simple tests
I2C1.setup({sda:D4, scl:D5, bitrate:100000}); =undefined >I2C1._options ={ "sda": D4, "scl": D5, "bitrate": 100000 } >
read data from eeprom
>I2C1.readFrom(0x62,9); =new Uint8Array([48, 50, 48, 49, 48, 48, 48, 50, 50]) >I2C1.readFrom(0x62,9); =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255])
hmm ?
>I2C1.readFrom(0x62,9); =new Uint8Array([255, 255, 255, 255, 255, 255, 255, 255, 255]) >I2C1.writeTo(0x62,1); =undefined >I2C1.readFrom(0x62,9); =new Uint8Array([48, 50, 48, 49, 48, 48, 48, 50, 50]) >
can not read twice, have to send dumy writeTo to read again ?!
i2cget -y 2 0x62 0 has no problems ......
any comments or hints ?
-
-
Found a nice circular LED Bar from microbot MR400-013.1 using a NXP PC9635 I2C chip.
Operating power supply voltage range of 2.3 V to 5.5 V
Target is to write a module, more infos in the next couple days
-
running on ESP8266-12E
mem:{"free":1557,"usage":143,"total":1700,"history":22}
version:1v85.MaBe_master_d1aeb8f
git_commit:d1aeb8f9f8f692e1c987597624137b546173c08dtested with .1 (router) and .52 (mac book) - so this works fine for my configuration
>var ESP8266=require("ESP8266"); =function () { [native code] } > =undefined >var Wifi = require("Wifi") =function () { [native code] } >Wifi.getIP(); ={ "ip": "192.168.194.64", "netmask": "255.255.255.0", "gw": "192.168.194.1", "mac": "5c:cf:7f:05:c1:00" } > =undefined >ESP8266.setLog(2); =undefined >ESP8266.ping("192.168.194.1", function(e){ console.log(e);}); =undefined >456182> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 6, "seqNo": 56, "timeoutCount": 0, "bytes": 32, "error": 0 } >457274> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 57, "timeoutCount": 0, "bytes": 32, "error": 0 } >458425> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 58, "timeoutCount": 0, "bytes": 32, "error": 0 } >459499> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 59, "timeoutCount": 0, "bytes": 32, "error": 0 } >460602> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 4, "seqNo": 60, "timeoutCount": 0, "bytes": 32, "error": 0 } >461723> ping 5, timeout 0, total payload 160 bytes, 5547 ms
ESP8266.ping("192.168.194.52", function(e){ console.log(e);}); =undefined >750842> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 2, "seqNo": 61, "timeoutCount": 0, "bytes": 32, "error": 0 } >751924> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 62, "timeoutCount": 0, "bytes": 32, "error": 0 } >753100> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 63, "timeoutCount": 0, "bytes": 32, "error": 0 } >754175> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 1, "seqNo": 64, "timeoutCount": 0, "bytes": 32, "error": 0 } >755300> Received a ping response! { "totalCount": 0, "totalBytes": 0, "totalTime": 0, "respTime": 2, "seqNo": 65, "timeoutCount": 0, "bytes": 32, "error": 0 } >756423> ping 5, timeout 0, total payload 160 bytes, 5582 ms
-
-
-
changes to module DHT22:
.... setTimeout(function() { pinMode(D5,'output');digitalPulse(D5, 0, 1) // fire a 1ms marker clearWatch(ht.watch); delete ht.watch; .... } },6); }; ....
sample DHT22 code:
E.on("init",function(){ dht = require("DHT22").connect(D4); setInterval(function(){ dht.read(function (a) { console.log("t = "+a.temp.toFixed(1).toString() +", rh = "+a.rh.toFixed(1).toString() //+"\nraw:"+a.raw+ //+"\nerr:"+a.err+ //+", cse:"+a.checksumError );}, 1); },2000); }); save();
output is -1 for both value, changing 6 to 30 I receive correct values.
plus logic analyzer screen shot "001.jpg" of on dht.read
Question: why is the marker fired so late ?
thanks !