Does online compiling optimize readonly variables on nodeMcu ram? - lua

I've done several searches but wasn't able to find some documentation about the online compiler that comes with nodeMcu. I am writing some basic code, but with a lot of "const variables", that is like a #define in C. This variables are read only, and I use just for documentation and quickly change of program at development time.
As I know that RAM is tinny at nodeMcu (esp12 modules), I need to know if compiling files by calling node.compile() does help me with RAM saving by optimize this constants and placing it into some ROM memory.
Thanks!

Yes it does help. The full answer, however, is reading the dedicated chapter in our FAQ at http://nodemcu.readthedocs.io/en/latest/en/lua-developer-faq/#techniques-for-reducing-ram-and-spiffs-footprint (way to long to quote here).

Related

I want to make a procedurally generated virtualized drive - how can I do this?

I've had the idea for a procedurally generated virtual drive bouncing around my head for a long time. It wouldn't really have any uses, and really it would just be for the memes, but I've finally settled down and decided to make it.
The idea is to make a fake drive that, whenever a program asks for a sector from, a bit of code will generate that sector on the fly (instead of reading it from a storage medium like a normal drive). Of course, writing to the disk would be impossible, but that's ok - I'm just doing this for fun.
Question is: how do I actually make this appear as a drive?
I should think there's a library out there somewhere that will let you directly, but I haven't been able to find it yet. I don't really know what keywords I should be searching for, either.
I have a lot of experience with Arduinos and hardware - would it be easier to simply connect the SPI pins to an SD card slot and get the Arduino to generate the "sectors"?
I'm thinking of using this to play around with file systems and ridiculously large files - after all, there is no limit to how big the drive can be (since it doesn't require any real memory), besides 32 bit or 64 bit limits, which could be a lot of fun - if only to pretend you have a zettabyte of disk space. Even though it would be read only, I'm curious how Notepad would handle a petabyte txt file.
If anyone has any ideas on how to do this, or knows some better keywords I can use to search for this, let me know!
(I am fairly fluent in Python, Arduino, and I can do a little C if I sit down with a coffee)
You didn't specify how you wanted to tackle this, but on Linux there's Fuse, the Filesystem in Userspace. It's a library that allows you to implement functions that handle the usual filestem operations, i.e. enumerating files and directories, opening files and reading/writing to them.
It also has a python wrapper and a tutorial.

How to setup cmusphinx with lua?

So I wanted to go about designing an add-on for a game I play, World of Warcraft and the game uses Lua scripts. The add-on involves speech recognition. I found a library that apparently adds voice recognition functionality to Lua.
Here is the link to the library: https://github.com/stuarch/speechtotxt-lua
The problem is, I have no idea how to set this up. It looks like they're using linux commands, but can I use this with Windows?
Also, do I have to put all these files in a certain place (pocketsphinx, sphinxbase) like a project folder, and then call them from Lua?
I'm sorry if this a noob question, I just can't find anything online about adding these libraries to Lua, and how to include the pocketsphinx and sphinx base. Any help would be greatly appreciated.
There is a difference between let's say running the full Lua interpreter under Windows and running a Lua interpreter as part of a software like WoW.
They usually restrict the use of Lua to what makes sense for the game. You don't have to reboot the system from within WoW, you also should not be able to manipulate files or even manipulate memory ....
Just imagine you install a WoW addon from the internet and it suddenly deletes all files on your computer. Whooops.
So they simply remove the standard Lua libraries like os, debug, io...
Of course they also don't want you to extend your power beyond those limitations by loading third party code. Hence they remove the require function.
So all you can do in WoW is run restricted Lua code and use the feature set they offer you.
Adding speach recognition to WoW is not possible through the embedded Lua interpreter.

Print contents of rpg file in human-readable format

Context
A friend of mine is having trouble printing source code to a human readable format.
The compiled (I assume) programs of their welding robot have the .rpg extension. They want to collect print-outs in human-readable format, possibly for backup or future reference.
Their supplier can provide the software that accomplishes this, be it at a considerable cost (and possibly: an annual license). Because of this, my friend decided to ask me if a easier/cheaper solution exists.
Examples & Pictures
The files can be read on the console of the robot, an example:
I've done some minor research and I'm fairly sure this is the Report Program Generator (RPG) language developed by IBM. The Assembly-like syntax seems to match; it might be one of the later versions of the language.
My friend has send me an example .rpg file, the contents seem binary with some string literals scattered throughout. Screenshot of the contents of an example file in hexadecimal:
The Question
There is not much, if any, clear information to be found online so I suppose I have multiple questions (for anyone that might know more about this):
Is this (first image) Report Program Generator (RPG) code?
Does the .rpg file contain compiled or processed code? Maybe an intermediate format?
Is it possible to convert files as shown in the example, back to source-code or human-readable format, kind of 'disassemble' it?
If anyone knows more, don't hesitate to give me any information or ask more details if necessary. Thanks in advance!
And maybe not an important question but still something that bugs me (and might indicate I'm on the wrong track):
If this is indeed an RPG program, why would the compiled/processed binary have the .rpg extension, shouldn't the source-file have that? This leads me to believe I'm either (a) assuming the wrong things (the language, etc...) or (b) this is an intermediate format, easier for machines to read, that has to be interpreted by some kind of runtime system.
I don't think that's any version of IBM's RPG language. RPG does have a MOVEL opcode, but it doesn't have any of the others.
Also, all the versions of the IBM language have been intended for business programming. I doubt that it would have been used for robotics.
My guess is that's a proprietary language of the company that makes the robot.
There are some similarities but it does not look like IBM RPG language.
RPG sources are in fact source physical file members. They are not stored in the "traditional" file system but in OS/400 libraries. Therefore RPG sources have no extension. They can be converted to Integrated File System stream file though.
I can't answer this question I'm afraid as it's unknown language to me.
I expect possibly that the OP misidentifies the file type/extension; that the extension is actually .prg, and the files serve as instructions for a Panasonic Industrial Welding Robot. The following forum [drilled down to Panasonic Robots] bills itself as the biggest Industrial Robots Supportforum worldwide!; perhaps a good place to ask about those images provided in the OP, and the inquiry about getting source from what appears to be a binary instruction stream.
FWiW, the first image seems to show that the Ezed utility [on the console] gives that human-readable format, so then the question might be how to get that saved and then how to transfer that elsewhere; e.g. what type of comm ports and file transfer utilities are available from whatever platform/OS.

how useful is Cling C++ JIT interpreter developed at CERN?

I recently watched great google talks speech about Cling - C++ language interpreter. But I wonder if anyone except people at CERN (where it is developed) are using Cling, and how good it is from non-collider-physics-scientist point of view, can you write desktop apps with it?
There are some videos of uses cases different from the High Energy Physics: http://www.youtube.com/results?search_query=cling+c%2B%2B (I think first couple are the relevant ones)
It has the potential to be very useful, but it is very young. There is no documentation that I could find, no dedicated mailing list, no online tutorials. I was able to get small toy code to run, but couldn't figure out how to use it productively on a large library yet.
Cling project is well established one. You can find more information in their official website cling. They also have a forum
Thanks

How to program the TI TMS320C674x real-time clock using C

Intense googeling failed to turn out a single decent example of how to program the RTC.
all I could find were examples for the C5000/4000 models, which seems work differently as I was unable to locate any of the header files required to get the sample code to compile.
the closest I got was finding the RTC user manual, but it's no help at all on the subject of actually programming the real time clock using C
I'd appreciate to no end a working example or a pointer to where such an example exists
I'm assuming you are using TI's DSP/BIOS, as this seems to be the most common manner in which the C6000 family of DSPs are used. The DSP/BIOS operating system provides a number of APIs for interfacing with the real time clock (the CLK module). These APIs abstract away the registers and other low-level details of the RTC as described in the RTC user manual. This is generally the simplest way to use the clock as it avoids the need to manually "program" it.
See the CLK section in the API reference.

Resources