Comm Test

HTML

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://www.chilipeppr.com/js/require.js"></script>
<div id="com-chilipeppr-widget-commtest" class="modal fade">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <div class="btn-toolbar pull-right" role="toolbar">
                    <div class="btn-group">
                    </div>
                </div>	
				<span class="modal-title" data-toggle="popover">Comm Test - Hardware Version:  </span>  
				<span class="fb-build">(waiting)</span>
            </div>
        </div>
    </div>
    <div id="com-chilipeppr-serialport-spselector" />
</div>

CSS

#com-chilipeppr-widget-tinyg-body {
    /* padding:0; */
}
#com-chilipeppr-widget-configtinyg .nav-tabs>li>a {
    padding: 2px 6px;
}
#com-chilipeppr-widget-configtinyg .tab-pane {
    padding:10px 16px 20px 16px;
    overflow:auto;
}
#com-chilipeppr-widget-configtinyg .panel-footer {
    font-size:11px;
    padding:0;
    margin:0;
}
#com-chilipeppr-widget-configtinyg .col-xs-3 {
    padding:0;
    margin:0;
}
#com-chilipeppr-widget-configtinyg .progress-bar span {
    color: black;
    padding-left:4px;
}
#com-chilipeppr-widget-configtinyg .stat-val {
    padding-left:4px;
}
}

JavaScript

// Test this element. This code is auto-removed by the chilipeppr.load()
cprequire_test(["inline:com-chilipeppr-widget-test"], function (ls) {
    console.log("test running of " + ls.id);

    // Serial Port Selector
    // http://jsfiddle.net/chilipeppr/4RgrS/
    // NEW VERSION for SPJS v1.7 http://jsfiddle.net/chilipeppr/vetj5fvx/
     chilipeppr.load("com-chilipeppr-serialport-spselector",
        "http://fiddle.jshell.net/chilipeppr/vetj5fvx/show/light/",

    function () {
        cprequire(
        ["inline:com-chilipeppr-widget-serialport"],

        function (sp) {
            sp.setSingleSelectMode();
            sp.init(null, "CommTest", 115200);
        });
    });
	ls.init();
} /*end_test*/ );

cpdefine("inline:com-chilipeppr-widget-test", ["chilipeppr_ready"], function (cp) {
    return {
        id: "com-chilipeppr-widget-test",
        url: "http://jsfiddle.net/khauser/roL36mvk/show/light/",
        fiddleurl: "http://jsfiddle.net/khauser/roL36mvk/",
        name: "Widget / Comm Test",
        desc: "This widget",
        publish: {},
        subscribe: {},
        foreignPublish: {
            "/com-chilipeppr-widget-serialport/send": "We send to the serial port certain commands like the initial configuration commands for the TinyG to be in the correct mode and to get initial statuses like planner buffers and XYZ coords. We also send the Emergency Stop and Resume of ! and ~",
                "/com-chilipeppr-elem-flashmsg/flashmsg": "To flash messages"
        },
        foreignSubscribe: {
            "/com-chilipeppr-widget-serialport/recvline": "When we get a dataline from serialport, process it and fire off generic CNC controller signals to the /com-chilipeppr-interface-cnccontroller channel."
        },
        done: false,
        attempts: 50,
        init: function () {
            var that = this;
			chilipeppr.subscribe("/com-chilipeppr-widget-serialport/recvline", this, this.recvProcessor);
           ...