cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

ThingWorx Raspberry Pi Quickstart

wwang-21
1-Newbie

ThingWorx Raspberry Pi Quickstart

Hi everybody,

I'm currently working my way into the ThingWorx ecosystem and I am currently stuck on the Raspberry Pi Quickstart Guide when trying to connect the Lua Script Ressource to the running Edge Micro Server.

When running wsems EMS can connect to the platform but appears this problem.

[ERROR] 2017-02-22 03:39:20,806 emsRequestHandler: Thing not bound to EMS, or host is not set

I am in the config.json configuration file of the auto_bind part of the binding name "PiThing","gateway"设置为false

And as long as a run LSR it is displayed

[DEBUG] 2017-02-22 03:39:21, 30 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-22 03:39:21, 30 SDK: twTlsClient_Close: Disconnecting from server

The property can be read on the platform but the property can not be updated

1 ACCEPTED SOLUTION

Accepted Solutions
supandey
19-Tanzanite
(To:wwang-21)

Did you test by changing one of the cache setting for one of the property in ThingWorx, something like below?

View solution in original post

10 REPLIES 10
supandey
19-Tanzanite
(To:wwang-21)

Hi Wang, just to confirm is your Thing in the ThingWorx successfully bound? Does it display isConnected = True in it's property? Do you have the identifier defined in the config file to identify the thing attempting to the Thing in the ThingWorx.

Could you also share your config.json and may be also attach the full log here.

hi,Sushant

This is my log

wsems:

[INFO ] 2017-02-23 01:17:15,125 ./wsems: Using config file: /home/pi/microserver/etc/config.json

[FORCE] 2017-02-23 01:17:15,126 ./wsems: Starting up ....

[FORCE] 2017-02-23 01:17:15,126 ./wsems: Initializing EMS ....

[FORCE] 2017-02-23 01:17:15,126 main: Using config file /home/pi/microserver/etc/config.json

[INFO ] 2017-02-23 01:17:15,126 ./wsems: Creating the WsEms proxy.

[INFO ] 2017-02-23 01:17:15,126 ./wsems: Starting HTTP Server.

[INFO ] 2017-02-23 01:17:15,127 ./wsems: Initializing the ThingWorx REST interface.

[FORCE] 2017-02-23 01:17:15,127 httpServer: starting http server port=8000

[DEBUG] 2017-02-23 01:17:15,127 httpServer: http server bound to port=8000.

[DEBUG] 2017-02-23 01:17:15,128 SDK: twWs_Create: Initializing Websocket Client for 192.168.0.78:443//Thingworx/WS

[DEBUG] 2017-02-23 01:17:15,128 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-02-23 01:17:15,128 SDK: twApi_Initialize: Websocket Established after 0 tries

[DEBUG] 2017-02-23 01:17:15,128 SDK: subscribedPropsMgr_Initialize: Initializing subscribed properties manager

[DEBUG] 2017-02-23 01:17:15,129 jsonConfigurator::getJsonEntity: Key cert_chain not found

[DEBUG] 2017-02-23 01:17:15,129 jsonConfigurator::getJsonEntity: Key validation_criteria not found

[DEBUG] 2017-02-23 01:17:15,129 jsonConfigurator::getJsonEntity: Parent file not found

[INFO ] 2017-02-23 01:17:15,130 wsEmsProxy::initialize: Initialization complete!

192.168.0.78:443-->[INFO ] 2017-02-23 01:17:15,130 ./wsems: Starting the connection.

[DEBUG] 2017-02-23 01:17:15,132 SDK: twTlsClient_Reconnect: Re-establishing SSL context

[DEBUG] 2017-02-23 01:17:15,132 SDK: twTlsClient_Connect: Connecting to server

[DEBUG] 2017-02-23 01:17:15,702 SDK: twTlsClient_Connect: TLS connection established

[DEBUG] 2017-02-23 01:17:15,920 SDK: ws_on_headers_complete: Websocket connected!

[AUDIT] 2017-02-23 01:17:15,920 SDK: twWs_Connect: Websocket connected!

[DEBUG] 2017-02-23 01:17:15,921 SDK: twWs_SendMessage: Sent 60 bytes using 1 frames.

[DEBUG] 2017-02-23 01:17:16,305 SDK: twMessage_Delete:  Deleting RESPONSE Message: 1

[DEBUG] 2017-02-23 01:17:16,305 SDK: twMessage_Delete:  Deleting AUTH Message: 1

[DEBUG] 2017-02-23 01:17:16,311 SDK: sendCtlFrame: >>>>> Sending Ping. Msg: 01:17:16

[INFO ] 2017-02-23 01:17:16,333 Main: Succesfully connected.  Saving .booted config file

[DEBUG] 2017-02-23 01:17:22,426 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-02-23 01:17:22,426 TlsStream:: doopen: Setting SO_RCVTIMEO

[DEBUG] 2017-02-23 01:17:22,427 RestThingworx::callback: Handling request

[DEBUG] 2017-02-23 01:17:22,427 SDK: twInfoTable_CreateFromJson: Non-infotable format passed in.  Using single entry '_content_'

[DEBUG] 2017-02-23 01:17:22,427 RestThingworx: Executing request AddEdgeThing

[DEBUG] 2017-02-23 01:17:22,528 SDK: twWs_SendMessage: Sent 26 bytes using 1 frames.

[DEBUG] 2017-02-23 01:17:22,973 SDK: twMessage_Delete:  Deleting RESPONSE Message: 2

[DEBUG] 2017-02-23 01:17:22,973 SDK: twMessage_Delete:  Deleting BIND Message: 2

[DEBUG] 2017-02-23 01:17:22,973 jsonConfigurator::getJsonEntity: Parent file not found

[DEBUG] 2017-02-23 01:17:22,973 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-23 01:17:22,973 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:22,974 [+0000] HTTP Server: 112.9.168.192 - SeqId 2 - "POST /Thingworx/Things/LocalEms/Services/AddEdgeThing HTTP/1.1" 200 0 "-"

[DEBUG] 2017-02-23 01:17:22,974 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:22,975 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-02-23 01:17:22,976 TlsStream:: doopen: Setting SO_RCVTIMEO

[DEBUG] 2017-02-23 01:17:22,976 RestThingworx::callback: Handling request

[DEBUG] 2017-02-23 01:17:22,976 SDK: twInfoTable_CreateFromJson: Non-infotable format passed in.  Using single entry '_content_'

[DEBUG] 2017-02-23 01:17:22,976 RestThingworx: Executing request GetPropertySubscriptions

[DEBUG] 2017-02-23 01:17:23, 73 SDK: twWs_SendMessage: Sent 76 bytes using 1 frames.

[DEBUG] 2017-02-23 01:17:23,419 SDK: twMessage_Delete:  Deleting RESPONSE Message: 3

[DEBUG] 2017-02-23 01:17:23,517 SDK: twMessage_Delete:  Deleting REQUEST Message: 3

[DEBUG] 2017-02-23 01:17:23,517 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-23 01:17:23,517 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:23,518 [+0000] HTTP Server: 112.9.168.192 - SeqId 4 - "POST /Thingworx/Things/PiThing/Services/GetPropertySubscriptions HTTP/1.1" 200 460 "-"

[DEBUG] 2017-02-23 01:17:23,518 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:23,968 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-02-23 01:17:23,972 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-23 01:17:23,972 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:23,972 emsRequestHandler: Got 200 response code from POST request on Things/PiThing/Services/NotifyPropertyUpdate

[DEBUG] 2017-02-23 01:17:23,973 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:24, 41 SDK: twTlsClient_Create: Initializing TLS Client

[DEBUG] 2017-02-23 01:17:24, 41 TlsStream:: doopen: Setting SO_RCVTIMEO

[DEBUG] 2017-02-23 01:17:24, 42 RestThingworx::callback: Handling request

[DEBUG] 2017-02-23 01:17:24, 42 SDK: twInfoTable_CreateFromJson: Non-infotable format passed in.  Using single entry '_content_'

[DEBUG] 2017-02-23 01:17:24, 42 RestThingworx: Executing request HasEdgeThing

[DEBUG] 2017-02-23 01:17:24, 43 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-23 01:17:24, 43 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:24, 44 [+0000] HTTP Server: 112.9.168.192 - SeqId 6 - "POST /Thingworx/Things/LocalEms/Services/HasEdgeThing HTTP/1.1" 200 139 "-"

[DEBUG] 2017-02-23 01:17:24, 44 SDK: twTlsClient_Close: Disconnecting from server

[DEBUG] 2017-02-23 01:17:24, 72 SDK: twWs_SendMessage: Sent 17 bytes using 1 frames.

[DEBUG] 2017-02-23 01:17:24, 72 SDK: twMessage_Delete:  Deleting RESPONSE Message: 159027

[DEBUG] 2017-02-23 01:17:24, 72 SDK: twMessage_Delete:  Deleting REQUEST Message: 159027

LSR:

[INFO ] 2017-02-23 01:17:20,381 ./luaScriptResource: Using config file: /home/pi/microserver/etc/config.lua

[FORCE] 2017-02-23 01:17:20,381 ./luaScriptResource: Starting up ....

[INFO ] 2017-02-23 01:17:20,386 ./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

[FORCE] 2017-02-23 01:17:20,430 httpServer: starting http server port=8001

[INFO ] 2017-02-23 01:17:20,446 thingworx.shape: Creating a new shape.

[INFO ] 2017-02-23 01:17:20,446 PiThing: -- Configuration -------------------------------

[INFO ] 2017-02-23 01:17:20,446 PiThing: scanRate: 60000

[INFO ] 2017-02-23 01:17:20,446 PiThing: scanRateResolution: 500

[INFO ] 2017-02-23 01:17:20,446 PiThing: taskRate: 15000

[INFO ] 2017-02-23 01:17:20,446 PiThing: keepAliveRate: 60000

[INFO ] 2017-02-23 01:17:20,446 PiThing: requestTimeout: 15000

[INFO ] 2017-02-23 01:17:20,447 PiThing: registerRate: 43200000

[INFO ] 2017-02-23 01:17:20,447 PiThing: register: true

[INFO ] 2017-02-23 01:17:20,447 PiThing: getPropertySubscriptionOnReconnect: false

[INFO ] 2017-02-23 01:17:20,447 PiThing: maxConcurrentPropertyUpdates: 100

[INFO ] 2017-02-23 01:17:20,447 PiThing: defaultPushType: VALUE

[INFO ] 2017-02-23 01:17:20,447 PiThing: useShapes: true

[INFO ] 2017-02-23 01:17:20,447 PiThing: identifier: Not Specififed

[INFO ] 2017-02-23 01:17:20,447 PiThing: ------------------------------------------------

[INFO ] 2017-02-23 01:17:20,447 thingworx.template: Adding shape 'shapes.metadata' to template 'thingworx.template'

[INFO ] 2017-02-23 01:17:20,448 thingworx.template: Adding shape 'shapes.propsubscribe' to template 'thingworx.template'

[INFO ] 2017-02-23 01:17:20,448 thingworx.template: Creating new templates.PiTemplate named 'PiThing'

[INFO ] 2017-02-23 01:17:20,448 PiThing: -- Initializing properties ---------------------

[INFO ] 2017-02-23 01:17:20,449 PiThing: Initialized property upToDate [baseType: BOOLEAN, pushType: NEVER, handler: nil, value: true]

[INFO ] 2017-02-23 01:17:20,449 PiThing: Initialized property cpu_volt [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]

[INFO ] 2017-02-23 01:17:20,450 PiThing: Initialized property cpu_temperature [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]

[INFO ] 2017-02-23 01:17:20,451 PiThing: Initialized property cpu_freq [baseType: NUMBER, pushType: ALWAYS, handler: nil, value: 0]

[INFO ] 2017-02-23 01:17:20,451 PiThing: ------------------------------------------------

[INFO ] 2017-02-23 01:17:22,421 PiThing: -- Starting script --------------------------

[INFO ] 2017-02-23 01:17:22,421 PiThing: Registering core callback handler

[INFO ] 2017-02-23 01:17:22,421 PiThing: Starting main loop

[INFO ] 2017-02-23 01:17:22,421 PiThing: Calling lifecycle start listeners.

[INFO ] 2017-02-23 01:17:22,421 shapes.propsubscribe: Initialized

[INFO ] 2017-02-23 01:17:22,422 thingworx.handler: Creating a new handler.

[INFO ] 2017-02-23 01:17:22,974 PiThing: MicroServer is now available.

[INFO ] 2017-02-23 01:17:22,974 PiThing: MicroServer is online.

[INFO ] 2017-02-23 01:17:22,974 PiThing: Successfully registered PiThing with MicroServer.

[INFO ] 2017-02-23 01:17:23,521 PiThing: GetPropertySubscriptions called. 0 properties updated.

[INFO ] 2017-02-23 01:17:23,970 PiThing: Received notification that property bindings have been updated on server.

flatform:

Default Value is not 0,Can not refresh

supandey
19-Tanzanite
(To:wwang-21)

Hi Wang, thanks for sharing the log, i can't locate any error in that though. What you have mentioned in your original post is that you see emsRequestHandler: Thing not bound to EMS, or host is not set error reported but the logs which you have shared are clean, unless this is not a complete log.

In fact somewhere at the end of the log that there is confirmation that you have PiThing: Successfully registered PiThing with MicroServer.

Though i did notice at end of the log it said there was update in property but it doesn't reflect here. Could you try changing atleast one of the property's Remote Binding setting to force it to fetch the property update from the edge property using

Before testing please do save the entity and try to refresh if that helps. Otherwise the connection looks good with your above log and the RemoteThing in the Platform.

Hi,Sushant

Thank you for your answer.  My log is complete. I will just generate the upload up.

“logger”:{

  “level”:“TRACE”

  },

scripts.log_level = "TRACE"

But the platform can read the PiThing attribute can not be updated and read the property Default Value is not 0 click the refresh button Value that there is no value

supandey
19-Tanzanite
(To:wwang-21)

Did you test by changing one of the cache setting for one of the property in ThingWorx, something like below?

Thanks Sushant.

Now I can refresh the data but these two problems still exist.

[DEBUG] 2017-02-22 03:39:21, 30 TlsStream::doclose: Disconeccting socket

[DEBUG] 2017-02-22 03:39:21, 30 SDK: twTlsClient_Close: Disconnecting from server

what is the reason?  Property can be updated but the log is displayed  Disconeccting socket and  Disconnecting from server

How to know how long the platform refresh the data once?

supandey
19-Tanzanite
(To:wwang-21)

Good to hear Wang that helped. Concerning those messages, they are not errors - and i am guessing you likely won't even see them if you're to change the logging behavior, which i believe for you now is set to trace.

I believe these are notifications concerning the cyclic activity happening when sockets are opened for sending data and then closed when not needed.

Do you have any other issues in terms of property update?

Hope this would help.

Sushant,Thank you for your help!

I do not understand why the platform Defult Value that is not 0 but from the raspberry sent to read the data.

I have set the value to 0 in the PiTemplate file

properties.cpu_temperature = { baseType="NUMBER", pushType="ALWAYS", value=0 }

properties.cpu_freq = { baseType="NUMBER", pushType="ALWAYS", value=0 }

properties.cpu_volt = { baseType="NUMBER", pushType="ALWAYS", value=0 }

After the update I just click Save

Its value will be the same as Defult Value

Will not save the data for my updates

supandey
19-Tanzanite
(To:wwang-21)

Sorry i might not have fully understood your question, but if you are referring to the fact that the updates you are making to the property are not being persistent then you need to enable to Persistent aspect for that property

Thanks!

I do not understand why the platform Defult Value that is not 0 .It is the updated data

Top Tags