1 person found this helpful
(If you haven't already, download the LR 5 SDK, which includes complete documentation.)
There are a few documented mechanisms for LR plugins to send data to external programs:
- The LrHTTP module lets plugins invoke URLs with GET or POST commands. Your external program could implement a local HTTP server to receive those GETs and POSTs from your LR plugin.
- Your LR plugin could write to a log a file, which your external program could poll continuously for changes. While this might offend those with more delicate architectural sensibilities, with a little tuning you can make this pretty responsive without costing too much in CPU.
- Your plugin could invoke an external program via LrTasks. If the external program is reasonably lightweight, you can do this perhaps several times a second without consuming excessive CPU.
For receiving data into your LR plugin from an external program:
- Your plugin can establish a URLHandler that will receive HTTP requests to "lightroom://" URLs made from local programs on your computer.
- The plugin can poll the external program using LrHTTP using GET and POST commands. The external program only responds when it has data to send, so the CPU overhead is low.
- Your plugin could poll a log file written by the external program. I haven't tried this direction, but it might be harder to tune such polling in this direction, given the limited capabilities of the LR SDK.
Also, there is an undocument SDK module LrRemoteCommunication that appears to set up a simple two-way pipe with an external program, but no one has posted here how to use it.
If you are just prototyping, the easiest way might be to use separate layer for MIDI, since there is also easy solutions for using MIDI data on Arduino. Several MIDI plugins and solutions exist for Lightroom, so you don't even need any Lua development skiils.
Actually, while making LR module with Lua, you may use funcitons from io package, such as open a file and write to it.
Try it out - may be there is a way to associate file with a serial port and write into it, so Arduino catches these submissions and react as you want?
LR 6 added LrSocket, which provides Unix-like sockets for communicating with local processes.
1 person found this helpful
The annoying thing about LrSocket is that it doesn't allow two way communication on a single port which makes question and answer communication messy. I ended up needing to establish connections on 4 ports, two each for both "send" mode and "receive". And if you're sending a lot of packets over a short period of time - slider changes, for example - you have to figure out how to untangle the responses because there's no guarantee that the next data you get after a send is the actual response to the send.
I'm no socket expert and there may be a good reason for this but LrSocket seems poorly considered to me. Getting popen pipes to work would have been better and simpler, surely.
I believe, also, John that you can use LrSocket to communicate over a network. I'm pretty sure I had it running between an iPad and Lightroom running on a laptop.
All that said, LrSocket is probably the fastest of all the methods, HTTP get & post probably the tidiest, if you can get an http server running in your process.