i tired using the attached template but it doesn't seem to work, any other solutions?
Related post
Solved! Go to Solution.
I found out that using the Raspberry PI 4 was the problem, the code to fetch the frequency must be changed I think,
Hi @harikj.
Did you check for a template provided with the version you are running? Changes may have been made to the one in the previous post.
Are you receiving errors? It may be helpful for you to provide the logs.
Regards.
--Sharon
the ems server is running correctly.
sudo ./wsems
[FORCE] 2020-02-24 04:06:58,47 ./wsems: Initializing EMS ....
[FORCE] 2020-02-24 04:06:58,47 main: Using config file /home/pi/Desktop/microserver/etc/config.json
[INFO ] 2020-02-24 04:06:58,47 ./wsems: Creating the WsEms proxy.
[INFO ] 2020-02-24 04:06:58,48 ./wsems: Starting HTTP Server.
[WARN ] 2020-02-24 04:06:58,48 Main: Encryption is disabled on HTTP Server.
[WARN ] 2020-02-24 04:06:58,48 Main: Authentication is disabled on the HTTP Server.
[INFO ] 2020-02-24 04:06:58,48 ./wsems: Initializing the ThingWorx REST interface.
[FORCE] 2020-02-24 04:06:58,48 httpServer: starting http server port=8080
[INFO ] 2020-02-24 04:06:58,48 wsEmsProxy::initialize: FIPS is disabled.
[INFO ] 2020-02-24 04:06:58,48 wsEmsProxy::initialize: Encryption is enabled on Web Socket connection.
[WARN ] 2020-02-24 04:06:58,50 SDK: SDK Version: 2.2.0
[WARN ] 2020-02-24 04:06:58,50 SDK: TLS Library: OpenSSL
[WARN ] 2020-02-24 04:06:58,50 SDK: TLS Library Version: 1.0.2l-fips
[WARN ] 2020-02-24 04:06:58,50 SDK: FIPS Capable
[INFO ] 2020-02-24 04:06:58,200 WsProxy::initialize: EMS Version 5.4.5.512
[INFO ] 2020-02-24 04:06:58,200 WsProxy::initialize: twApi singleton initialized
[WARN ] 2020-02-24 04:06:58,201 WsProxy::initialize: Certificate validation is disabled.
[INFO ] 2020-02-24 04:06:58,202 wsEmsProxy::initialize: Initialization complete!
[INFO ] 2020-02-24 04:06:58,203 ./wsems: Starting the connection.
pp-2002130552vs.devportal.ptc.io:443-->[INFO ] 2020-02-24 04:06:59,153 SDK: Server supports websocket extensions: permessage-deflate
[INFO ] 2020-02-24 04:06:59,153 SDK: twWs_Connect: Websocket connected!
[INFO ] 2020-02-24 04:07:00,307 Main: Succesfully connected. Saving .booted config file
[INFO ] 2020-02-24 04:07:00,307 EMS: Duty Cycle is disabled.
i get an error running the lua script
[DEBUG] 2020-02-24 04:10:41,504 luaScriptProxy::runScript: Starting Script
[DEBUG] 2020-02-24 04:10:41,505 luaScriptProxy::getStatus: Script Thingworx status = Ready
[DEBUG] 2020-02-24 04:10:41,505 luaScriptProxy::execute: Script Thingworx now executing
[FORCE] 2020-02-24 04:10:41,510 httpServer: starting http server port=8001
[DEBUG] 2020-02-24 04:10:41,518 utils: Adding utils functions to tw_utils
[DEBUG] 2020-02-24 04:10:41,522 httpServer: http server bound to port=8001.
[DEBUG] 2020-02-24 04:10:41,526 ScriptResource::registerScriptCallback: Registered path /scripts/Thingworx/ with callback handle_request
[DEBUG] 2020-02-24 04:10:41,526 luaHttpBinding::l_registerCallback: Registered path '/' with callback 'handle_request' for script 'Thingworx'
[DEBUG] 2020-02-24 04:10:41,526 ScriptResource::registerScriptCallback: Registered path /scripts/Thingworx/registerIdentifier/ with callback register_identifier
[DEBUG] 2020-02-24 04:10:41,527 luaHttpBinding::l_registerCallback: Registered path '/registerIdentifier' with callback 'register_identifier' for script 'Thingworx'
[INFO ] 2020-02-24 04:10:41,527 thingworx.shape: Creating a new shape.
[INFO ] 2020-02-24 04:10:41,528 PiThing: -- Configuration -------------------------------
[INFO ] 2020-02-24 04:10:41,528 PiThing: scanRate: 1000
[INFO ] 2020-02-24 04:10:41,528 PiThing: scanRateResolution: 500
[INFO ] 2020-02-24 04:10:41,528 PiThing: taskRate: 30000
[INFO ] 2020-02-24 04:10:41,528 PiThing: keepAliveRate: 60000
[INFO ] 2020-02-24 04:10:41,528 PiThing: requestTimeout: 15000
[INFO ] 2020-02-24 04:10:41,528 PiThing: registerRate: 43200000
[INFO ] 2020-02-24 04:10:41,528 PiThing: register: true
[INFO ] 2020-02-24 04:10:41,528 PiThing: getPropertySubscriptionOnReconnect: false
[INFO ] 2020-02-24 04:10:41,528 PiThing: maxConcurrentPropertyUpdates: 100
[INFO ] 2020-02-24 04:10:41,528 PiThing: defaultPushType: VALUE
[INFO ] 2020-02-24 04:10:41,528 PiThing: useShapes: true
[INFO ] 2020-02-24 04:10:41,528 PiThing: identifier: Not Specififed
[INFO ] 2020-02-24 04:10:41,528 PiThing: ------------------------------------------------
[INFO ] 2020-02-24 04:10:41,529 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'
[INFO ] 2020-02-24 04:10:41,529 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'
[INFO ] 2020-02-24 04:10:41,529 thingworx.template: Creating new templates.PiTemplate named 'PiThing'
[INFO ] 2020-02-24 04:10:41,529 PiThing: -- Initializing properties ---------------------
[INFO ] 2020-02-24 04:10:41,529 PiThing: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]
[INFO ] 2020-02-24 04:10:41,529 PiThing: Initialized property cpu_volt [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:10:41,529 PiThing: Initialized property cpu_temperature [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:10:41,529 PiThing: Initialized property cpu_freq [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:10:41,529 PiThing: ------------------------------------------------
[DEBUG] 2020-02-24 04:10:41,529 luaScriptProxy::getStatus: Script PiThing status = Running
[DEBUG] 2020-02-24 04:10:41,529 luaScriptProxy::getStatus: Script Thingworx status = Running
[DEBUG] 2020-02-24 04:10:41,529 luaScriptProxy::getStatus: Script Thingworx status = Running
[INFO ] 2020-02-24 04:10:43,499 PiThing: -- Starting script --------------------------
[INFO ] 2020-02-24 04:10:43,499 PiThing: Registering core callback handler
[DEBUG] 2020-02-24 04:10:43,499 ScriptResource::registerScriptCallback: Registered path /scripts/PiThing/ with callback core_handler
[DEBUG] 2020-02-24 04:10:43,499 luaHttpBinding::l_registerCallback: Registered path '/' with callback 'core_handler' for script 'PiThing'
[INFO ] 2020-02-24 04:10:43,499 PiThing: Starting main loop
[INFO ] 2020-02-24 04:10:43,499 PiThing: Calling lifecycle start listeners.
[DEBUG] 2020-02-24 04:10:43,499 PiThing: Executing lifecycle start event: shapes.propsubscribe_start
[INFO ] 2020-02-24 04:10:43,499 shapes.propsubscribe: Initialized
[INFO ] 2020-02-24 04:10:43,500 thingworx.handler: Creating a new handler.
[DEBUG] 2020-02-24 04:10:43,502 thingworx.server: Invoking /Thingworx/Things/LocalEms/Services/AddEdgeThing on server. content: {"keepalive":60000,"port":"8001","timeout":15000,"host":"localhost","proto":"http","name":"PiThing","path":"/scripts/Thingworx"}
[DEBUG] 2020-02-24 04:10:43,502 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-02-24 04:10:43,519 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-02-24 04:10:43,520 TlsStream::doclose: Disconeccting socket
[DEBUG] 2020-02-24 04:10:43,521 SDK: twTlsClient_Close: Disconnecting from server
[DEBUG] 2020-02-24 04:10:43,521 SDK: twTlsClient_Close: Disconnecting from server
[INFO ] 2020-02-24 04:10:43,521 PiThing: MicroServer is now available.
[INFO ] 2020-02-24 04:10:43,521 PiThing: MicroServer is online.
[INFO ] 2020-02-24 04:10:43,521 PiThing: Successfully registered PiThing with MicroServer.
[DEBUG] 2020-02-24 04:10:43,521 TlsServerStream:: doopen: Setting SO_RCVTIMEO
[DEBUG] 2020-02-24 04:10:43,521 thingworx.server: Invoking /Thingworx/Things/PiThing/Services/GetPropertySubscriptions on server. content: {}
[DEBUG] 2020-02-24 04:10:43,522 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-02-24 04:10:43,522 TlsStream::doclose: Disconeccting socket
[DEBUG] 2020-02-24 04:10:43,523 SDK: twTlsClient_Close: Disconnecting from server
[DEBUG] 24/Feb/2020:04:10:43 [+0000] HTTP Server: 0.0.0.0 - SeqId 2 - "" 400 375 "-"
[DEBUG] 2020-02-24 04:10:43,523 SDK: twTlsClient_Close: Disconnecting from server
[DEBUG] 2020-02-24 04:10:44,129 TlsStream::doclose: Disconeccting socket
[DEBUG] 2020-02-24 04:10:44,130 SDK: twTlsClient_Close: Disconnecting from server
[DEBUG] 2020-02-24 04:10:44,130 SDK: twTlsClient_Close: Disconnecting from server
[INFO ] 2020-02-24 04:10:44,130 PiThing: Error occured while accessing EMS. Checking isConnected.
[DEBUG] 2020-02-24 04:10:44,131 SDK: twTlsClient_Create: Initializing TLS Client
[DEBUG] 2020-02-24 04:10:44,135 TlsStream::doclose: Disconeccting socket
[DEBUG] 2020-02-24 04:10:44,135 SDK: twTlsClient_Close: Disconnecting from server
[DEBUG] 2020-02-24 04:10:44,136 SDK: twTlsClient_Close: Disconnecting from server
[INFO ] 2020-02-24 04:10:44,136 PiThing: EMS is available: true, online: true
[INFO ] 2020-02-24 04:10:44,136 PiThing: Attempting to GetPropertySubscriptions from server failed. code: 500, result:
[DEBUG] 2020-02-24 04:10:44,136 PiThing: Wrote property: upToDate Updated updateTime to 4294967295
[DEBUG] 2020-02-24 04:10:44,154 [PiTemplate]: temp 42.0
[DEBUG] 2020-02-24 04:10:44,158 [PiTemplate]: raw freq frequency(48)=750199232
[ERROR] 2020-02-24 04:10:44,158 luaScriptProxy::execute: [-1241516976] Error executing script PiThing, Error = Error: ...ktop/microserver/etc/custom/templates/PiTemplate.lua:32: attempt to perform arithmetic on local 's' (a nil value)
[ERROR] 2020-02-24 04:10:44,158 luaScriptProxy::app_unlock: [-1241516976] Attempt to unlock app_mutex while not holding it.L= 0x1aea768
[DEBUG] 2020-02-24 04:10:44,158 luaScriptProxy::execute: Script PiThing has stopped executing
[DEBUG] 2020-02-24 04:10:44,158 luaScriptProxy::cleanup: Script PiThing is cleaning up
i noticed if i comment out the frequency calculation part in the script, the error goes away . but i get error 500
sudo ./luaScriptResource
[INFO ] 2020-02-24 04:14:15,513 ./luaScriptResource: Using config file: /home/pi/Desktop/microserver/etc/config.lua
[FORCE] 2020-02-24 04:14:15,513 ./luaScriptResource: Starting up ....
[INFO ] 2020-02-24 04:14:15,515 luaScriptResource:main: Encryption is disabled on the RAP connection.
[INFO ] 2020-02-24 04:14:15,515 luaScriptResource:main: FIPS is disabled.
[INFO ] 2020-02-24 04:14:15,517 ./luaScriptResource: New path is /home/pi/Desktop/microserver/etc/thingworx/clibs:/home/pi/Desktop/microserver/etc/custom/clibs:/home/pi/Desktop/microserver/etc/community/clibs:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[WARN ] 2020-02-24 04:14:15,517 ScriptResource::initialize: Encryption is disabled on HTTP Server.
[WARN ] 2020-02-24 04:14:15,518 ScriptResource::initialize: Authentication is disabled on the HTTP Server.
[FORCE] 2020-02-24 04:14:15,528 httpServer: starting http server port=8001
[INFO ] 2020-02-24 04:14:15,558 thingworx.shape: Creating a new shape.
[INFO ] 2020-02-24 04:14:15,558 PiThing: -- Configuration -------------------------------
[INFO ] 2020-02-24 04:14:15,558 PiThing: scanRate: 1000
[INFO ] 2020-02-24 04:14:15,558 PiThing: scanRateResolution: 500
[INFO ] 2020-02-24 04:14:15,558 PiThing: taskRate: 30000
[INFO ] 2020-02-24 04:14:15,558 PiThing: keepAliveRate: 60000
[INFO ] 2020-02-24 04:14:15,558 PiThing: requestTimeout: 15000
[INFO ] 2020-02-24 04:14:15,558 PiThing: registerRate: 43200000
[INFO ] 2020-02-24 04:14:15,558 PiThing: register: true
[INFO ] 2020-02-24 04:14:15,558 PiThing: getPropertySubscriptionOnReconnect: false
[INFO ] 2020-02-24 04:14:15,558 PiThing: maxConcurrentPropertyUpdates: 100
[INFO ] 2020-02-24 04:14:15,558 PiThing: defaultPushType: VALUE
[INFO ] 2020-02-24 04:14:15,559 PiThing: useShapes: true
[INFO ] 2020-02-24 04:14:15,559 PiThing: identifier: Not Specififed
[INFO ] 2020-02-24 04:14:15,559 PiThing: ------------------------------------------------
[INFO ] 2020-02-24 04:14:15,559 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'
[INFO ] 2020-02-24 04:14:15,559 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'
[INFO ] 2020-02-24 04:14:15,559 thingworx.template: Creating new templates.PiTemplate named 'PiThing'
[INFO ] 2020-02-24 04:14:15,559 PiThing: -- Initializing properties ---------------------
[INFO ] 2020-02-24 04:14:15,560 PiThing: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]
[INFO ] 2020-02-24 04:14:15,560 PiThing: Initialized property cpu_volt [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:14:15,560 PiThing: Initialized property cpu_temperature [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:14:15,560 PiThing: Initialized property cpu_freq [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]
[INFO ] 2020-02-24 04:14:15,560 PiThing: ------------------------------------------------
[INFO ] 2020-02-24 04:14:17,529 PiThing: -- Starting script --------------------------
[INFO ] 2020-02-24 04:14:17,529 PiThing: Registering core callback handler
[INFO ] 2020-02-24 04:14:17,529 PiThing: Starting main loop
[INFO ] 2020-02-24 04:14:17,529 PiThing: Calling lifecycle start listeners.
[INFO ] 2020-02-24 04:14:17,529 shapes.propsubscribe: Initialized
[INFO ] 2020-02-24 04:14:17,530 thingworx.handler: Creating a new handler.
[INFO ] 2020-02-24 04:14:17,552 PiThing: MicroServer is now available.
[INFO ] 2020-02-24 04:14:17,552 PiThing: MicroServer is online.
[INFO ] 2020-02-24 04:14:17,552 PiThing: Successfully registered PiThing with MicroServer.
[INFO ] 2020-02-24 04:14:18,196 PiThing: Error occured while accessing EMS. Checking isConnected.
[INFO ] 2020-02-24 04:14:18,202 PiThing: EMS is available: true, online: true
[INFO ] 2020-02-24 04:14:18,202 PiThing: Attempting to GetPropertySubscriptions from server failed. code: 500, result:
[INFO ] 2020-02-24 04:14:18,859 PiThing: Error occured while accessing EMS. Checking isConnected.
[INFO ] 2020-02-24 04:14:18,865 PiThing: EMS is available: true, online: true
[INFO ] 2020-02-24 04:14:18,865 PiThing: Attempting to GetPropertySubscriptions from server failed. code: 500, result:
[INFO ] 2020-02-24 04:14:19,923 PiThing: Error occured while accessing EMS. Checking isConnected.
[INFO ] 2020-02-24 04:14:19,928 PiThing: EMS is available: true, online: true
[WARN ] 2020-02-24 04:14:19,928 thingworx.server: Could not set properties on server. code: 500, resp:
i am using the same files provided in the guide.
Hello @harikj,
Do you have LocalEms thing on the server? Do you see any errors in ThingWorx ApplicationLog or ScriptLog?
/ Constantine
I found out that using the Raspberry PI 4 was the problem, the code to fetch the frequency must be changed I think,
Hi @harikj.
If you are comfortable with the solution you found, please mark your last post as the Accepted solution for the benefit of others with the same issue.
Regards.
--Sharon