Skip to main content
1-Visitor
March 29, 2018
Solved

Running LSR on Raspberry Pi

  • March 29, 2018
  • 1 reply
  • 7072 views

Hi,

 

I'm trying to set up my Raspberry Pi to Thingworx. I'm following the quickstart guide (https://developer.thingworx.com/resources/guides/thingworx-raspberry-pi-quickstart/run-lsr). I've set up the EMS and that works. However, I'm now at the point where I have configured the LSR and am now trying to run it. I have the EMS running in another window and input the code below as instructed:

sudo ./luaScriptResource

The result is below:

[INFO ] 2018-03-29 13:50:57,437 ./luaScriptResource: Using config file: /home/pi/microserver/etc/config.lua
[FORCE] 2018-03-29 13:50:57,437 ./luaScriptResource: Starting up ....

[INFO ] 2018-03-29 13:50:57,441 luaScriptResource:main: Encryption is disabled on the RAP connection.
[INFO ] 2018-03-29 13:50:57,441 luaScriptResource:main: FIPS is disabled.
[INFO ] 2018-03-29 13:50:57,444 ./luaScriptResource: New path is /home/pi/microserver/etc/thingworx/clibs:/home/pi/microserver/etc/custom/clibs:/home/pi/microserver/etc/community/clibs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[WARN ] 2018-03-29 13:50:57,446 ScriptResource::initialize: Encryption is disabled on HTTP Server.
[ERROR] 2018-03-29 13:50:57,447 ScriptResource::initialize: Failed to get HTTP Server authenticate configuration.
[ERROR] 2018-03-29 13:50:57,447 ./luaScriptResource: Error initiatizing script resource
[ERROR] 2018-03-29 13:50:57,447 luaScriptResource:main: Insecure configuration. Shutting down LSR.

[WARN ] 2018-03-29 13:50:58,447 luaConfigurator::~luaConfigurator: Closing Lua state

Any advice is greatly appreciated.

 

Thanks in advance,

Charlotte

 

Best answer by jdass

Hello cssummers1,

 

I made some quick changes to the lua file.Try with the below config.lua

 

scripts.log_level = "DEBUG"
scripts.PiThing = {
                file = "thing.lua",
                template = "PiTemplate",
    identifier = "PiThing",
                scanrate = 1000,
                taskrate = 30000
        }

scripts.rap_host = "127.0.0.1"
scripts.rap_port = 8000
scripts.rap_ssl = false
scripts.rap_server_authenticate = false


scripts.script_resource_host = "127.0.0.1"
scripts.script_resource_port = 8001
scripts.script_resource_ssl = false
scripts.script_resource_authenticate = false

 

 Changed the scripts.rap_port to 8000 - This should be the port on which EMS is running. Should be the same as the http_server port in config.json.

 

I have also added the identifier in the binding section.

 

Let me know if this helps.

1 reply

13-Aquamarine
March 29, 2018

Hi,

 

What version of EMS are you using? And can you share your config.lua file here?

 

 

csummers11-VisitorAuthor
1-Visitor
April 3, 2018

I'm using the latest version of the EMS that's provided by ThingWorx - I got the download here.

This is the current state of my config.lua file:

scripts.log_level = "INFO"
scripts.PiThing = {
 file = "thing.lua",
 template = "PiTemplate",
 scanRate = 1000,
 taskRate = 30000,
 indentifier = "PiThing"
 }

scripts.rap_host = "127.0.0.1"
scripts.rap_host = 8080
scripts.rap_ssl = false


scripts.script_resource_host = "localhost"
scripts.script_resource_port = 9001
scripts.script_resource_ssl = "false"
scripts.script_resource_authenticate = false

 

 

Since making the post I made some changes to my config.lua file and this is the new output I get:

[INFO ] 2018-04-04 08:31:01,796 ./luaScriptResource: Using config file: /home/pi/microserver/etc/config.lua
[FORCE] 2018-04-04 08:31:01,796 ./luaScriptResource: Starting up ....

[INFO ] 2018-04-04 08:31:01,802 luaScriptResource:main: Encryption is disabled on the RAP connection.
[INFO ] 2018-04-04 08:31:01,802 luaScriptResource:main: FIPS is disabled.
[INFO ] 2018-04-04 08:31:01,805 ./luaScriptResource: New path is /home/pi/microserver/etc/thingworx/clibs:/home/pi/microserver/etc/custom/clibs:/home/pi/microserver/etc/community/clibs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[WARN ] 2018-04-04 08:31:01,807 ScriptResource::initialize: Encryption is disabled on HTTP Server.
[WARN ] 2018-04-04 08:31:01,808 ScriptResource::initialize: Authentication is disabled on the HTTP Server.
[FORCE] 2018-04-04 08:31:01,837 httpServer: starting http server port=9001
[INFO ] 2018-04-04 08:31:01,907 thingworx.shape: Creating a new shape.
[INFO ] 2018-04-04 08:31:01,908 PiThing: -- Configuration -------------------------------
[INFO ] 2018-04-04 08:31:01,908 PiThing: scanRate: 1000
[INFO ] 2018-04-04 08:31:01,908 PiThing: scanRateResolution: 500
[INFO ] 2018-04-04 08:31:01,908 PiThing: taskRate: 30000
[INFO ] 2018-04-04 08:31:01,908 PiThing: keepAliveRate: 60000
[INFO ] 2018-04-04 08:31:01,908 PiThing: requestTimeout: 15000
[INFO ] 2018-04-04 08:31:01,908 PiThing: registerRate: 43200000
[INFO ] 2018-04-04 08:31:01,908 PiThing: register: true
[INFO ] 2018-04-04 08:31:01,908 PiThing: getPropertySubscriptionOnReconnect: false
[INFO ] 2018-04-04 08:31:01,908 PiThing: maxConcurrentPropertyUpdates: 100
[INFO ] 2018-04-04 08:31:01,909 PiThing: defaultPushType: VALUE
[INFO ] 2018-04-04 08:31:01,909 PiThing: useShapes: true
[INFO ] 2018-04-04 08:31:01,909 PiThing: identifier: Not Specififed
[INFO ] 2018-04-04 08:31:01,909 PiThing: ------------------------------------------------
[INFO ] 2018-04-04 08:31:01,911 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'
[INFO ] 2018-04-04 08:31:01,912 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'
[INFO ] 2018-04-04 08:31:01,912 thingworx.template: Creating new templates.PiTemplate named 'PiThing'
[INFO ] 2018-04-04 08:31:01,912 PiThing: -- Initializing properties ---------------------
[INFO ] 2018-04-04 08:31:01,912 PiThing: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]
[INFO ] 2018-04-04 08:31:01,913 PiThing: Initialized property cpu_volt [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2018-04-04 08:31:01,913 PiThing: Initialized property cpu_temperature [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2018-04-04 08:31:01,913 PiThing: Initialized property cpu_freq [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2018-04-04 08:31:01,913 PiThing: ------------------------------------------------
[INFO ] 2018-04-04 08:31:03,884 PiThing: -- Starting script --------------------------
[INFO ] 2018-04-04 08:31:03,884 PiThing: Registering core callback handler
[INFO ] 2018-04-04 08:31:03,884 PiThing: Starting main loop
[INFO ] 2018-04-04 08:31:03,884 PiThing: Calling lifecycle start listeners.
[INFO ] 2018-04-04 08:31:03,884 shapes.propsubscribe: Initialized
[INFO ] 2018-04-04 08:31:03,889 thingworx.handler: Creating a new handler.
[ERROR] 2018-04-04 08:31:03,907 UnencryptedClientStream::doopen: Error opening socket. Error: 22
[ERROR] 2018-04-04 08:31:03,907 HttpClient::initialize: Exception while opening connection request to 8080. Error: Error opening non-TLS socket [8080:8000]
[ERROR] 2018-04-04 08:31:03,908 luaBindings::httpPost: Error POSTing to HTTP Server at 8080/Thingworx/Things/LocalEms/Services/AddEdgeThing
[INFO ] 2018-04-04 08:31:03,908 PiThing: Error occured while accessing EMS. Checking isConnected.
[ERROR] 2018-04-04 08:31:03,910 UnencryptedClientStream::doopen: Error opening socket. Error: 22
[ERROR] 2018-04-04 08:31:03,910 HttpClient::initialize: Exception while opening connection request to 8080. Error: Error opening non-TLS socket [8080:8000]
[ERROR] 2018-04-04 08:31:03,910 luaBindings::httpGet: Error GETing from HTTP server at 8080/Thingworx/Things/LocalEms/Properties/isConnected
[INFO ] 2018-04-04 08:31:03,910 PiThing: EMS is available: false, online: false
[ERROR] 2018-04-04 08:31:09,452 UnencryptedClientStream::doopen: Error opening socket. Error: 22
[ERROR] 2018-04-04 08:31:09,453 HttpClient::initialize: Exception while opening connection request to 8080. Error: Error opening non-TLS socket [8080:8000]
[ERROR] 2018-04-04 08:31:09,453 luaBindings::httpPost: Error POSTing to HTTP Server at 8080/Thingworx/Things/LocalEms/Services/AddEdgeThing
[INFO ] 2018-04-04 08:31:09,453 PiThing: Error occured while accessing EMS. Checking isConnected.
[ERROR] 2018-04-04 08:31:09,455 UnencryptedClientStream::doopen: Error opening socket. Error: 22
[ERROR] 2018-04-04 08:31:09,455 HttpClient::initialize: Exception while opening connection request to 8080. Error: Error opening non-TLS socket [8080:8000]
[ERROR] 2018-04-04 08:31:09,455 luaBindings::httpGet: Error GETing from HTTP server at 8080/Thingworx/Things/LocalEms/Properties/isConnected
[INFO ] 2018-04-04 08:31:09,455 PiThing: EMS is available: false, online: false

 

Any further comments, questions or help is greatly appreciated.

 

Charlotte

13-Aquamarine
April 4, 2018

Hello Charlotte,

 

I noticed that you are using scripts.rap_host = 8080 instead of scripts.rap_port = 8080 in the config.lua.

Also as you have defined an identifier for the remote thing in the config.lua have you also added the identifier to the PiThing in the Composer?