Closed cnlohr closed 8 years ago
You know, I've never heard of strtok
It does look like it solves a different problem, though.
This function "pops" a parameter off the global parameter stack, and reports whether it was successfully popped.
I do agree the function name is pretty awful.
Also, the implementation leaves a lot to be desired. Do you know if there's any way to pass variables by register-reference in GCC? Google wasn't too clear on this, but, on the lx106, parameters are passed by register. If I could update those registers and accept the different values in the caller, that would be the best of every world. The problem is when I passed them in as pointers the code size ballooned because GCC was constantly trying to push these things on the stack, make references to them and everything was just crazy.
Hmm, now I wonder if I can "trick" gcc into believing it's passing the registers by value and changing them anyway.
This function "pops" a parameter off the global parameter stack, and reports whether it was successfully popped.
Exactly what strtok(...)
does, except that you pass it the parameter stack at first call and then NULL
as long as you want to pop from the same stack.
And sorry no idea how to pass by register-reference. Not even sure what you mean :'(
Hmm, I guess what I have is pretty close to that, then! I wonder if it would be more memory-efficient to just implement strtok. Only thing it doesn't do would be the whole argument-counting I do.
Re: Register-reference. I don't know what you would call it, but the lx106 architecture passes parameters in registers. I wish I could tell GCC "hey, that register, keep using it once you're done, don't save it or back it up or anything. Trust me. I'm an engineer." I do not believe such a thing would exist, though :( -- mostly because that would be C++'s & operator.
@cnlohr wrote:
Great changes! Looks alot cleaner now. As mentioned, I got my NodeMCU.¹ I got to testing a bit. No problems so far! It's soooo much nicer to flash firmware over the network. Also no button-presses!
Small things:
./user.cfg
(893c7ac) you haveFWBURNFLAGS = -b 1000000
which causesmake burn
to fail on my module, since the baud-rate is wrong for programming.ParamCaptureAndAdvanceInt(...)
functions is a bit long. Most C programmers know the strtok(...) function fromstring.h
of the C standard library. It does basically the same. You could call themstrtok_int(...)
.¹As my luck would have it, I had to change the ESP on the NodeMCU because shipping damage :-/ Good that my other ESP-12Es came an hour later, exactly when I figured, what the problem was. On the plus side I could salvage the faulty modules' larger flash chip. Soldered it to one of my ESP-01 modules. Now I have two working and net-burnable modules. Yay!