Newbie questions

Hi all,
I’m new to Info-Beamer, new to LUA, and new(ish) to digital signage. I am not new to programming; I’ve been programming, including production programming since I was nine, more than sixty years ago. I’ve been doing relatively well sorting through several pacakges. In particular, thanks to @infobeamer-fw for pointing me towards package-food-menu as a starting point for a restaurant signage system.
With minimal and easy modifications I’ve been able to get to this point, which is enough for a proof-of-concept demo to a client.

At this point things are starting to become a bit more challenging as I am just starting to program in LUA (I’m mostly a C++ kind of guy), and I’m trying to understand several things about LUA as implemented in IB.

  • Which version of LUA is IB based on? It seems that 5.4 is a major revision with many new features and constructs.
  • Is the IB LUA implementation a subset of the full language? I’ve been trying to write to an external file and all my attempts have hit a wall, leaving me with, at best, a partial screen, which so far seems to be my only clue as to where the error lies. I’m using “Programming in LUA, Fourth Edition” as as my text and reference. It seems excellent, but at over 300 pages I’d like to know if there are large sections (e.g., IO?) that can be ignored since they are unavailable under IB.
  • What are people using for debugging? As I mentioned above, my attempts to write debugging output to a file have been of little help, mostly crashing the package as soon as I try to do any IO.
  • Are there any example packages available that show either how to interface with external files or other useful system facilities on the IB Hosted platform or IB Pi?

I’m playing a bit with the IP Pi software, which has good and bad aspects. On the one hand it gets me closer to being able to observe packages in action (ssh in from my laptop, running info-beamer from a command line and observing the two attached screens. Also, coming from backgrounds in high-dollar value wholesale bond brokerage and real-time rail transportaion systems I like the idea of not being dependent on an external infrastructure out of my control. On the other hand I find using the Pi version a bit of a bear so far. Hosted gives me so much that I think I’ll have to construct and maintain myself if I go to production with Info-Beamer Pi.

If you’ve gotten this far, thanks much for your time and attention.

Jim Siler
Maine, USA

It’s actually 5.1 (plus some bits from 5.2) using LuaJIT.

The language is fully Lua, but the environment in info-beamer is sandboxed and not all function are exposed. There is, for example, no io table, so writing anything to disk isn’t possible. This is mostly due to how info-beamer was originally designed: The idea was that you had one or more directories containing Lua code and all necessary assets. You are then guaranteed to be able to copy that directory to any other machine and info-beamer would show you exactly the same thing. All state was fully contained in that directly and you were guaranteed to get the exact same result on any machine. Preventing writes and thus state modification is one part of that.

The general design approach to most packages is that information “flows” mostly in one direction: The configuration made by the user on the dashboard/API → synchronized to the device → potentially some package service adding additional logic or interfacing with external system → info-beamer process does all the visualization.

So far mostly print debugging. At least on hosted, all output ends up in a log buffer you can tail using logread -f | grep info-beamer:. One useful addition to stock Lua is a pretty printer function, pp(...), you can use to inspect any table object or other variable. For example pp(_G) shows all global variables.

From the point of view of your Lua code, there isn’t a lot to interface. Most important is probably using util.json_watch for monitoring modified JSON files and reacting to them. One file provided by the hosted system is config.json. It will contain all the configuration made in the dashboard as well as some metadata about the current device. From within the generated config.json you get the filenames of all configured assets (in case your package contains any asset configuration option and you can then load those using one of the resource loaders for images or videos.

If you want more flexibility you might consider breaking up your package into two parts:

  • One written in Lua, responsible for producing the visual output
  • One written in basically any language, acting as a package service to interface with external services or devices and control what the Lua part does. You can then, for example, write local (JSON) files that Lua can pick up and use. A language that compiles to a static binary might be best for that as it then doesn’t have any external dependencies. Golang might be worth a look as it almost trivially generates standalone arm binaries that run on the Pi.

There is a mechanism in hosted that almost replicates that: The dev-mode feature. You can enable that from the device configuration editor on the device’s detail page and use the Python script linked to monitor a local directory. Any change will be synced to the Pi and you almost immediately see the result. To see the log output, activate SSH on the Pi (also using the device configuration editor). You can then run logread -f to monitor the output.

Of course manually running info-beamer pi on Raspberry Pi OS works as well and you can basically package up the result later and import it into info-beamer hosted, for example using a ZIP file.

Hope that give a bit more insight into how everything fits together. Happy to answer any other question you might have.

Thanks as always, @infobeamer-fw. This gives me a real quick-start on getting my stuff up and running. It’s nice to know the "logread -f|grep info-beamer" trick. It means I can go back to hosted for now, which in turn means I don’t have to sit around my cold basement during development (it’s cold here in Maine, and my screens are sitting on the bar in my basment). I’ll try to learn dev-mode once I’ve got my head around Lua a bit more.

At some point I’d like to better understand some of the business implications of using Hosted and Pi. That would include

  1. Pricing (a big consideration, since my target is restaurants without the financial resources to use the big providers)
  2. The flow from my back-end CMS and the IB displays at client sites. I’d like to understand what vulnerabilities are there so I can minimize my exposure to failures in the path. My target clients are small, mostly family run restaurants who cannot afford much downtime. I need to be able to give realistic Service Level Agreements and to quickly recover from failures. That is one of the main reasons for my interest in a stand-alone environment within my control, although I do not want to reinvent the wheel.

I suspect that when the time comes this may be a better one-on-one discussion off-line. I’m confident at this point that if I can make things work on my end that we can find some mode of deployment that works well for everyone (you, me, my clients).

As a final note to anyone in North America pulling their hair out over finding rPis, CanaKit seems to suddenly have inventory of Zero 2 Ws and 4bs available for immediate shipment or within this month by the end of this month for Z2W or Febrauary for 4b, and at the normally quoted prices (e.g., $15 USD for Zero 2W, $10 for Zero W, and 4b 4Gb for $45). I’m apparently not the only one who has noticed, since times have stretched out by 1/2 to 1 month since I looked about eight hours ago.

Thanks for your great support and patience.

Jim Siler