These are chat archives for esp8266/Arduino

15th
Jun 2016
sticilface
@sticilface
Jun 15 2016 09:26
here is a weird request... anyone reckon there is a way of getting an Md5 of the current binary on flash?
Me No Dev
@me-no-dev
Jun 15 2016 09:40
Yup :) see how it's done for the ota in Update. Same thing, but you read the flash instead of the network
sticilface
@sticilface
Jun 15 2016 09:44
I'm on it..
:)
sticilface
@sticilface
Jun 15 2016 10:18
does EspClass::getSketchSize() return the correct sketch size or the 32bit aligned sketch size? I'm wanting to compare the md5 of the current sketch vs the sketch to be flashed. so I'm not sure it will be possible if sketchsize() is stored as aligned, versus the unaligned that comes down with updater. if that makes sense
if it stores aligned, is there any way to get the unaligned sketch size?
Charles
@hallard
Jun 15 2016 10:24
@igrr
any chance to merge this PR about getting serial baud rate into master esp8266/Arduino#2079 Maybe I've done something wrong, if it's the case, just let me know?
Me No Dev
@me-no-dev
Jun 15 2016 10:26
@sticilface I have no clue
never investigated that deeply
Ivan Grokhotkov
@igrr
Jun 15 2016 10:34
@sticilface sketch size is always 16-byte aligned, and ESP.getSketchSize returns sketch size which is 1 to 16 bytes less than the real .bin file size
@hallard merged that, thanks
Charles
@hallard
Jun 15 2016 10:36
Nice, thanks to you for merging
Ivan Grokhotkov
@igrr
Jun 15 2016 10:36
although i did find it a bit funny that the bit about Serial.baudRate function is longer than the whole bit about all other Serial stuff)
not to deter you from writing good documentation tho
Charles
@hallard
Jun 15 2016 10:39
Oh, sorry I didn't realize that
not sure to understand, I just added one function call to SDK internal call
Ivan Grokhotkov
@igrr
Jun 15 2016 10:42
actually, uart_get_baudrate is not an SDK function
Charles
@hallard
Jun 15 2016 10:44
Correct, ;-) I'm writting to much code on different project, I forgot this one ;-)
sticilface
@sticilface
Jun 15 2016 10:44
so i guess calculating the same md5 that would be generated by the linux command line md5 xyz.bin is impossible?
Ivan Grokhotkov
@igrr
Jun 15 2016 10:47
#2153. i think we can sneak this into 2.3.0
should be pretty trivial
sticilface
@sticilface
Jun 15 2016 10:53
ooo :) thank you.
i'll take a look.. always something to learn
sticilface
@sticilface
Jun 15 2016 12:45
ok got that all working:)
i can make a pull request.. is it worth adding to ESPClass a getSketchMD5() function?
Clemens Kirchgatterer
@everslick
Jun 15 2016 13:37
@me-no-dev you there?
i implemented a filebrowser, but content gets always downloaded, instead of rendered inlined
(there is a callback for rendering and one for downloading a file)
AFAICS, the last parameter to request->beginResponse() tells the server to set the header accordingly.
Me No Dev
@me-no-dev
Jun 15 2016 13:54
аре ъоу тръинг то дисплаъ ит ин тхе бровсер?
oops
are you trying to display it in the browser?
most brwsers will not display most content
and will download it instead ;)
btw never needed to alter the headers
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:12
it works in the sync server
i tested with text and mp3 files
i show the filename and on the right hand side there are 3 links: View Download Delete
View should show it inline, Download should save to disk
Me No Dev
@me-no-dev
Jun 15 2016 14:14
code should be exacly the same
it works in the FSBrowser example
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:15
does it have a "View" button there?
Me No Dev
@me-no-dev
Jun 15 2016 14:15
well when you click on a file that it can display, it does so
right click gives menu for download and delete
btw the server has it's own "get_content_type"
sending empty string there will trigger it
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:19
i could try that
Me No Dev
@me-no-dev
Jun 15 2016 14:21
//view
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, path); 
//download
AsyncWebServerResponse *response = request->beginResponse(SPIFFS, path, String(), true);
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:22
aha
the first line works. partly.
it works with jpg
but not with mp3
Me No Dev
@me-no-dev
Jun 15 2016 14:23
are you opening it in iframe of a sort?
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:23
setting my own content type does not work at all
no, no iframes
add the needed types for mp3 and whatever you need
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:26
ic, but why doesn't it work, with my own content_type as parameter? scrachinghead
you ignore the 3rd parameter completely
Me No Dev
@me-no-dev
Jun 15 2016 14:34
hahaha
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:35
that's why :D
Me No Dev
@me-no-dev
Jun 15 2016 14:35
there you go
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:35
additionally IMHO downloading by setting the content type to octet stream is not really correct
thats what the response->addHeader("Content-Disposition",... is for
Me No Dev
@me-no-dev
Jun 15 2016 14:37
it was what I found a while back for forceing download
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:37
then one can set the content type AND the filename and still have it downloaded or rendered
Me No Dev
@me-no-dev
Jun 15 2016 14:38
have to test "Content-Disposition" to nmake sure it does not display some files instead of downloading them
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:38
there is a very good explanation on stackoverflow
Me No Dev
@me-no-dev
Jun 15 2016 14:39
feel free to PR, but make sure files are downloaded and not displayed in the browsers
the content type forces that always, as "wrong" as it is
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:40
so true should download false display (the last parameter)
Me No Dev
@me-no-dev
Jun 15 2016 14:44
yes
true is to force download
false will do whatever the browser can do
Clemens Kirchgatterer
@everslick
Jun 15 2016 14:44
ok
Clemens Kirchgatterer
@everslick
Jun 15 2016 15:01
This message was deleted
Clemens Kirchgatterer
@everslick
Jun 15 2016 15:16
PR sent
Me No Dev
@me-no-dev
Jun 15 2016 15:21
PR Merged :)
Clemens Kirchgatterer
@everslick
Jun 15 2016 15:22
thx! :)
Ivan Grokhotkov
@igrr
Jun 15 2016 15:26
@sticilface thanks for the PR! Actually it's a bit easier, result=(pos+16)&15 😉
Miguel Angel Salinas Gancedo
@masalinas
Jun 15 2016 15:41
Hello somebody used any 4-20 ma shield with arduino??
Me No Dev
@me-no-dev
Jun 15 2016 15:46
@masalinas 4-20?
sticilface
@sticilface
Jun 15 2016 15:46
@igrr oh dear. du mind explaining how that works?
and my sketchmd5 although works is flawed.
Me No Dev
@me-no-dev
Jun 15 2016 15:47
bong with pins?
@me-no-dev it's a shield to connect industrial sensor with this protocol 4-20 miliamperes
Me No Dev
@me-no-dev
Jun 15 2016 15:51
@sticilface (pos + 15) & 16 will either give 16 or 0 depending if (pos & 15) > 0
@masalinas looks interesting and 5V board
@masalinas also we have just one analog read channel
but yeah, if properly wired, it should work for a single channel
Me No Dev
@me-no-dev
Jun 15 2016 15:59
@sticilface try:
result = (pos & ~0xF) + (((pos & 0xF) +0xF) & 0x10);
Miguel Angel Salinas Gancedo
@masalinas
Jun 15 2016 16:21
@me-no-dev that's work now, i connected a 4-20ma inclinometer type 3 mode
sticilface
@sticilface
Jun 15 2016 16:21
I thought the
Problem was something different. The pos
sticilface
@sticilface
Jun 15 2016 17:59
The end size of actual binary can be any no of bytes 0-16. but we don't know exactly where. I check a load of sketches looking at the 16 bytes passed where getsketchsize() returns. The sketch always ended at the first 255 byte. So I'm not sure how using maths on pos will return the unknown number of bytes that the binary goes past. It has to be exact for the md5 to return the same as the md5 function in Linux. Unless I've got totally the wrong end of the stick.... I don't see how adding 16 bytes when it ends at 12 would work?
Clemens Kirchgatterer
@everslick
Jun 15 2016 19:01
is there a size limit on PSTR() strings?
Martin Ayotte
@martinayotte
Jun 15 2016 19:14
@everslick , not that I'm aware of.
Me No Dev
@me-no-dev
Jun 15 2016 19:46
@sticilface the math will round the sketch size to 16 bytes address
so the result will always be 16 bytes aligned. I imagined trhat's what you are looking for
Michael Miller
@Makuna
Jun 15 2016 19:54
@everslick I believe the limit is flash memory.
Me No Dev
@me-no-dev
Jun 15 2016 19:57
@Makuna true! but not even that. Actually the limit is the start of SPIFFS :)
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:04
my html page string was cut at around 6KB, dunno why
wanted to refactor that anyway... :-D
Me No Dev
@me-no-dev
Jun 15 2016 20:05
how are you sending it?
you might be cut by the tcp window
Michael Miller
@Makuna
Jun 15 2016 20:06
Was this limited by compiler? By sending? or could you write some code to just read it and it failed (null terminated?)
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:30
to be honest, i didn't bother to check. that code was ugly beyond repair, so a chose to refactor before investigating it further. i just saw that the html was cut short befor the supposed end, and taht was around 6KB.
it was with the sync webserver though
and the html code was built in a String
but the missing part was not on the end of that string but the end of a part that came directly from flash
confused?
;-P
Me No Dev
@me-no-dev
Jun 15 2016 20:39
yeah :D
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:39
so i can rule out, the tcp window thing (that would hav cut at the very end)
Me No Dev
@me-no-dev
Jun 15 2016 20:39
what do you mean by "built in a String"
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:40
String html += PSTR(.....)
Me No Dev
@me-no-dev
Jun 15 2016 20:40
your string was not able to alloc what it needed probably
and since you say it ended on some part of a constructed string
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:40
i did html.reserve(7*1024) first
Me No Dev
@me-no-dev
Jun 15 2016 20:41
that was the last it can alloc
did it reserve it though?
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:41
reserve is supposed to alloc everithing. the error check was ok
Me No Dev
@me-no-dev
Jun 15 2016 20:41
and it ends before those 7K
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:42
yes
but the last += still worked
Me No Dev
@me-no-dev
Jun 15 2016 20:42
just was not sent?
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:42
it was the += before the last (that with the very long PSTR() that failed
thats why i thought, hugh? the end of the html code is ther, but in the middle is something missing (that was on the end of the log PSTR())
Me No Dev
@me-no-dev
Jun 15 2016 20:44
are te other parts also PSTR?
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:44
so my guess was PSTR() can only be such long
not all some are from ram
Me No Dev
@me-no-dev
Jun 15 2016 20:44
any PSTR that did output?
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:44
const char *foo = "bar";
it was only one PSTR that was cut. the long one
Me No Dev
@me-no-dev
Jun 15 2016 20:45
gimme a sec to look through the code
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:46
i guess my firmware is a tough test case.... g
Me No Dev
@me-no-dev
Jun 15 2016 20:48
:D
yeah... code looks good
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:49
yeah, don't waste your time. next time i see that, i will check it out
this is what get's executed
when you are moving to async, read the server readme ;) has examples for many cases, including large flash strings
we have tested it with over 40K
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:52
mayby my flash is borked and there is a byte stuck at '\0' hehehe
Me No Dev
@me-no-dev
Jun 15 2016 20:53
you can check the return of html.concat(PSTR)
if true for the large string then it sees it as 0 length
Clemens Kirchgatterer
@everslick
Jun 15 2016 20:54
yeah, i've studied the readme, very usful APIs there
no it was not 0, because most of the string was there, just the end of the string was missing
Me No Dev
@me-no-dev
Jun 15 2016 20:55
maybe borked then for real
why not output to serial first to check it out?
Clemens Kirchgatterer
@everslick
Jun 15 2016 21:02
because that code is now gone (never made it to git) :-P
Me No Dev
@me-no-dev
Jun 15 2016 21:03
just on your ESP?
if you have nothing better to do and want to find out wether it's a bug, you can dump the flash and look for the string
Clemens Kirchgatterer
@everslick
Jun 15 2016 21:07
i will wait, until it comes back. or i will a do minimal testcase for that anytime later.
but not today, it's 11pm here! :-) i'm off!
CU, and thx for the merge today!
Me No Dev
@me-no-dev
Jun 15 2016 21:08
you are not far from me
germany?
Clemens Kirchgatterer
@everslick
Jun 15 2016 21:09
austria
Me No Dev
@me-no-dev
Jun 15 2016 21:09
nice
Clemens Kirchgatterer
@everslick
Jun 15 2016 21:09
summer sucks currently! ;-)
Me No Dev
@me-no-dev
Jun 15 2016 21:09
the best looking flight attendants ever
get on a plane :D
Clemens Kirchgatterer
@everslick
Jun 15 2016 21:10
hehe. indeed, i had one in my study group (a former stewardess)
top notch!
so, anyway, i have to go
cu
Me No Dev
@me-no-dev
Jun 15 2016 21:11
have fun :)
Germán Martín
@gmag11
Jun 15 2016 21:28
@sticilface I've done MD5 calculation an checking on web page during upload in my FSBrowser GitHub repository. Have a look and ask any question you need.
sticilface
@sticilface
Jun 15 2016 21:39
Will take a look. Is that md5 for uploaded files/spiffs files?
Germán Martín
@gmag11
Jun 15 2016 21:40
For uploaded scketch for OTA, but you could use it for hash every file you upload.
sticilface
@sticilface
Jun 15 2016 21:46
Ah ok. I've got all that sorted. I'm trying to hash the actual sketch. The running one.
Well I've done it. And it works.
That way u can compare an incoming binary to the running one without having to specify versions and defines, and commit hashes and all sorts that gets complicated.
sticilface
@sticilface
Jun 15 2016 21:51
I just need to verify and change on thing. And check this sketch size issue. As the sketch size needs to return the same size as the binary on the computer. Not the aligned one. As the hash function needs this same size.
If that makes sense.
So far from all the sketches I've tested they are either 0,4,8,12 bytes larger than the current getsketchsize()
Me No Dev
@me-no-dev
Jun 15 2016 22:32
what is common in the sizes (look at them in hex)
it is surely rounding up the size to some common denominator (like 16 bytes or 0xF)
so if the hex of the incomming size in bytes always ends on 0, the formula above should give you the size you are looking for
pos being equal to getsketchsize()