Adding new Setting: Help with error resolution - non iterable NoneType?

In trying to add a new page to the actions menu for upper and lower software controlled z axis limits, I have the button in place:

but when clicked on it, it says:


and the terminal message is:

cannot unpack non-iterable NoneType object

The setZaxis.html file it is supposed to open is super simple and a stripped down version of the zaxis.html file. I am guessing it needs an object called setZaxis that refers to setZaxis.html or when an object is named the same as the file that it knows to call that file? When the zaxis.html file is opened from the button press, it is referred to like this:

<button type=“button” class=“btn btn-primary btn-block” onclick=“requestPage(‘zAxis’);”>ZAxis

and it opens the xAxis.html page. Similarly the setZaxis page is called:

<button type=“button” class=“btn btn-lg btn-block btn-secondary” onclick=“requestPage(‘setZaxis’);$(’#contentModal’).modal(‘hide’);”>Set Z-Axis Limits

There is no .js file to go with it because the setZaxis.hml code is:

{% block content %}
<div class=“container-fluid”>
<div class=“card”>
<div class=“card-body”>
<h3 class=“card-title”>Z-Axis endstops</h3>
<h4 class=“card-title”>Step 1: Clear Z-Axis upper and lower limits</h4>
<p>Press the button to clear previously set limits if moving beyond them is desired, otherwise skip to step 2</p>
<button type=“button” class=“btn btn-lg btn-block btn-secondary” onclick=“action(‘ClearZ’);”">Clear Z</button>
<h3 class=“card-title”>Step 2: Set Z-Axis Upper Limit</h4>
<p>Move your sled to the extreme upper limit and press the button to save the new position.</p>
<button type=“button” class=“btn btn-lg btn-block btn-secondary” onclick=“action(‘SetMaxZ’);”>Set Max Z</button>
<h4 class=“card-title”>Step 3: Z-Axis Lower Limit</h4>
<p>Move your sled to the extreme lower limit and press the button to save the new position.</p>
<button type=“button” class=“btn btn-lg btn-block btn-secondary” onclick=“action(‘SetMinZ’);”>Set Min Z</button>
{% endblock %}

Note: when these buttons are added to the regular z axis page, they work fine, but they are being moved because this is a one-time set and forget. It is probably a comma somewhere, but I’m not seeing it. A second set of eyes would be helpful. I’m just trying to learn the ways of the force. Thanks.

1 Like

You need to add the page to the file. I created a class just for processing webpage requests that come in via websockets.

ok. I was hoping it was something simple like this, just not sure where to look. I get the python side of this more than the web side, but it gets fuzzy where they cross. This sounds like a one line fix. Thanks! I’ll get it working later today hopefully.

Its a few-lines fix, but simple enough. You’ll see when you get there.

How would one get a response from the controller and display it on the page as well? For example… push a button to ask what the limit values are and then show on the page.

EDIT for clarity: how does a text input from the serial input make it to the web page to display?

It’s not as simple and a bit convoluted because how it evolved. This is one area I’m not really proud of.

If you want to send data back, you need to add a message via ui_queue1. For example, to send the position of the home coordinates the following code is used:

position = {“xval”: oldHomeX * scaleFactor, “yval”: oldHomeY * scaleFactor}“Action”, “homePositionMessage”, position)

Then… in, [see processMessage() ]when it sees an “Action” command it either does some additional processing or wraps up the action as a json and sends it with the “message” header (see line 549).

socketio.emit(“message”, {“command”: msg[“message”], “data”: msg[“data”], “dataFormat”: “json”},

No additional processing is done with a homePositionMessage so it goes to line 549. Then in baseSocket.js, the received websocket message is parsed and a switch/case for the particular command (e.g., ‘homePositionMessage’) is performed and the appropriate function is called (see baseSocket.js, line 143-145). In this example, in frontPage.js, there’s a processHomePosition function defined. You would need to define some function in your new html file (or if you use a js file with it) to include a function that could be called.

In a nutshell, send it similar to homePositionMessage (perhaps call it zAxisLimitMessage) and then add a new switch/case that looks for that and then calls processZAxisLimitMessage in your html/js file.

Hope this is clearer than mud. Also when you get confused, look at DataStructures/uiQueue to see how calls to add messages to the queue are “converted” into a totally different format to be more confusing. Like I said, it evolved and I’m not proud of it.

1 Like

The proof is in the pudding, my friend, and this one turned out fine. I’m impressed by the ingenuity required to get all the pieces to actually work together. I’m not qualified to grade you on it and if I was, why? I do appreciate the complexity of the pieces I comprehend and most of us greatly appreciate the abilities the software provides. Thanks for the direction! I’ll check back when I have something.