"get Behavior: undefined variable" whenever I use the Pins module

Hello,

Whenever I try to use the pins module and configure the pins I get the following error: ### BREAK: ?: get Behavior: undefined variable! This causes my script to fail immediately.

It appears to be coming from this line: var container = new Container({behavior: Behavior({

I cannot seem to get past this.

Any help would be greatly appreciated - thank you.

Comments

  • Can you show me more of your code? Nothing with that particular snippet looks wrong, but there could be a problem with the object you're passing into Pins.configure or the functions in the container's behavior.

  • edited May 2016

    For my "application.xml":

    <?xml version="1.0" encoding="utf-8"?>
    <application xmlns="http://www.kinoma.com/kpr/application/1" id="helloled" program="src/main" title="HelloLED">
    
    </application>
    

    This is my code for "src/main.js":

    Pins = require("pins");
    
    let main = {
        onLaunch(){
            Pins.configure({
                led: {
                    require: "Digital",
                    pins: {
                        ground: {pin: 1, type: "Ground"},
                          digital: {pin: 2, direction: "output"},
                    }
                },
                button: {
                    require: "Digital",
                    pins: {
                        power: {pin: 6, voltage: 3.3, type: "Power"},
                        ground: {pin: 7, type: "Ground"},
                        digital: {pin: 8, direction: "input"},
                    }
                },         
            }, function(success) {
                if (!success) trace("Failed to configure\n");
            });
        }
    };
    
    export default main;
    
  • I also had tried:

    Pins.invoke("/led/write", 1);
    

    in the success function

  • Adding the var keyword should fix your problem, i.e.

    var Pins  = require("pins")
    

    Once the configuration is complete, the call to Pins.invoke as you wrote it will work.

    I also just realized we're in the Kinoma Element forum, which explains why your code for a container with a behavior wasn't working--the containment hierarchy for building UIs, behaviors, etc. are all part of KinomaJS which is the application framework used for Kinoma Create, iOS/Android apps, etc. but not Kinoma Element. The Kinoma Element quick start guide and programmer's guide cover Element-specific topics, so I highly recommend using those as references.

  • I'm having the same problem. My Kinoma Element had been working fine. But after trying to launch a program from Kinoma Studio, it always returns 'get Behavior: undefined variable' error message. I guess that launching a program from Kinoma Studio broke or modified some pin libraries. Could you let me know how to recover libraries required for controlling pins?

  • I can see my Elemet using Kinoma Code via Wifi connection. 'Settings', 'Wifi' and 'Blink Light' work fine, but 'Pin Explorer' and 'Side Pins' don't work.

  • edited June 2016

    Running from Studio won't break/modify the Pins module, although I do recommend you use Kinoma Code if you're on a Mac. What firmware version is your Kinoma Element on and which version of Kinoma Code are you using? And can you show me the code you're trying to run?

    Also, as noted above, the containment hierarchy for building UIs, behaviors, etc. are all part of KinomaJS which is the application framework used for Kinoma Create, iOS/Android apps, etc. but not Kinoma Element. The Kinoma Element quick start guide and programmer's guide cover Element-specific topics, so I highly recommend using those as references. There is also excellent Pins module documentation and a couple sensor tutorials.

  • Thank you for your quick reply.

    I've solved the problem by myself! There were several extra files in K0 directory. After deleting those files, the element started working without problems.

    I describe what I did below.

    I have two Kinoma Elements, say element01 and element02.

    Element01: works fine, no problem.
    Element02: fails to run programs which handle pins.
    

    Here are the outputs of 'printenv':

    [kinoma-element01]$ printenv
    LOG=2
    MAC=005043039177
    UUID=00016422-6422-1001-EF6A-005043039177
    FW_VER=2.0.0
    _SHUTOFF_=1
    XSBUG_HOST=192.168.0.29:5003
    TIME_DIFF=540
    DST=0
    HOST=kinoma-element01
    APP_ID=elementblinkingled.kinoma.marvell.com
    
    [kinoma-element02]$ printenv
    LOG=0
    MAC=00504303916a
    UUID=00016968-6968-1001-EF6A-00504303916a
    FW_VER=2.0.0
    _SHUTOFF_=1
    XSBUG_HOST=192.168.0.29:5003
    HOST=kinoma-element02
    APP_ID=xsedit.element.kinoma.marvell.com
    

    I tried to run Kinoma Element sample program 'element-blinking-led' from Kinoma code. Kinoma code's version is 'Version 1.0b5 - Build 7.1.74.'

    Element01 works fine.

    Element02 returned an error message:

    tmp5540669729294082065.js (69) ?: get Behaviro: undefined variable!
    

    The debugger stopped at the line:

    var container = new Container({behavior: Behavior({
    

    I telneted to both elements and found extra files in k0 directory in element02.

    ---element01---
    [kinoma-element01]$ ls k0
    .manifest
    led.jsb
    main.jsb
    [kinoma-element01]$
    
    
    ---element2---
    [kinoma-element02]$ ls k0
    .manifest
    Dialer.jsb
    application.xml
    led.jsb
    main.jsb
    pins.jsb
    pins_connect_coap.jsb
    pins_connect_http.jsb
    pins_connect_local,js.jsb
    pins_connect_pins.jsb
    pins_connect_pubnub.jsb
    pins_connect_ws.jsb
    pins_share_coap.jsb
    pins_share_http.jsb
    pins_share_pubnub.jsb
    pins_share_ws.jsb
    [kinoma-element02]$
    

    I deleted all pins_* files. Then emlement02 started working. I think those pins files were created by Kinoma Studio.

  • Based on the files that were in your second device's k0 directory, it looks like you somehow uploaded the pins module for Kinoma Create to your Kinoma Element, which would certainly break things :) Glad you worked it out though!

Sign In or Register to comment.