I've been trying for the life of me to get my stepper board to receive commands properly. We have some python code that I'm converting to javascript. The python currently can connect and drive the stepper properly, though it does this dance where it tries to connect twice via channel.openWaitForAttachment(5000), because apparently "for some reason it always doesn't connect the first time connection only so idk just let's just ignore that."
So anyways back in javascript I cannot get the stepper to connect via a simple channel.open() even though I've been able to do it propertly with a TemperatureSensor (4-Input 1048_0) and DigitalOutput (InterfaceKit 0/0/4). I also have to forcibly set the channel and serial number which again I didn't have to do with the other boards. Surprise, surprise when I try to connect twice with open(5000) it looks like the channel actually opens up:
Code: Select all
ch open(5000).then(function (ch) {
console log('Channel Open:', ch name, ch id);
}).catch(function (err) {
ch.open(5000).then(function (ch) {
console.log('Channel Open:', ch name, ch id);
}).catch(function (err) {
console.log('Channel Failed:' + err);
});
});
It appears the channel is open. Great. Let's try setting the position:Attached: PhidgetStepper Bipolar HC(1067) (423388)
Attached: Dictionary(Dictionary) (2) [Phidget22 Control]
Channel Open: Stepper 1
Code: Select all
changePosition(position) {
this ch setEngaged(1);
this ch setTargetPosition(position);
this ch setEngaged(0);
}
I've tried this with only setting engaged and I still get a promise failure. Here's what happens when I try to run the Phidget Stepper example from the website, after of course modifying the channel.open logic to try twice on 5s intervals:Setting disc position to 43608
C:\Users\Adam Lee\source\repos\solvere-app\api\api\node_modules\phidget22\phidget22.min.js:6
e.set({name:"0",type:"u",value:t});var n=this;return e.send(this channel,gt.BP_SETDATAINTERVAL).then(function(e){n.data.dataInterval=t})},Jt.prototype.getMinDataInterval=function(){return this checkOpen(),this.data.minDataInterval},Jt.prototype.getMaxDataInterval=function(){return this checkOpen(),this.data.maxDataInterval},Jt.prototype.getEngaged=function(){return this checkOpen(),!!this.data.engaged},Jt.prototype.setEngaged=function(t){if(this.isopen!==!0)return v(w.NOT_ATTACHED);var e=new Tt(this channel.conn);e.set({name:"0",type:"d",value:t});var n=this;return e.send(this channel,gt.BP_SETENGAGED).then(function(e){n.data.engaged=t})},Jt.prototype.getIsMoving=function(){return this checkOpen(),!!this.data.isMoving},Jt.prototype.getPosition=function(){return this checkOpen(),this.data.position},Jt.prototype.getMinPosition=function(){return this checkOpen(),this.data.minPosition},Jt.prototype.getMaxPosition=functi
TypeError: Cannot read property 'rescaleFactor' of undefined
at ne.setTargetPosition (C:\Users\Adam Lee\source\repos\solvere-app\api\api\node_modules\phidget22\phidget22.min.js:6:28603)
at PhidgetStepper.changePosition (C:\Users\Adam Lee\source\repos\solvere-app\api\api\src\phidget-stepper\phidget-stepper.js:12:17)
at Socket.client.on (C:\Users\Adam Lee\source\repos\solvere-app\api\api\index.js:38:14)
at Socket.emit (events.js:198:13)
at C:\Users\Adam Lee\source\repos\solvere-app\api\api\node_modules\socket io\lib\socket.js:528:12
at process._tickCallback (internal/process/next_tick.js:61:11)
So anyways... I 'm ripping my hair out here. Our python code works fine, but I can't run it directly on Windows because of some wonky dependencies. When I run the Phidget Stepper python example it works just fine (my motor doesn't spin but that's an issue with the gearing that I already know about).PS C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605> node Stepper.js localhost
connecting to:localhost
connected to server
about to open...
channel open
(node:6948) UnhandledPromiseRejectionWarning: Error
at new lt (C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\node_modules\phidget22\phidget22.min.js:1:12955)
at v (C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\node_modules\phidget22\phidget22.min.js:1:2094)
at ne.setEngaged (C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\node_modules\phidget22\phidget22.min.js:6:25050)
at C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\Stepper.js:68:7
at process._tickCallback (internal/process/next_tick.js:68:7)
(node:6948) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:6948) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\Stepper.js:31
var newPosition = this ch.getTargetPosition() + 10000;
^
TypeError: Cannot read property 'getTargetPosition' of undefined
at updatePosition (C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\Stepper.js:31:29)
at Timeout._onTimeout (C:\Users\Adam Lee\Downloads\Phidget22_Stepper_JavaScript_Nodejs_Ex_20190605\Stepper.js:69:40)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
Can anyone help shed some light on this? I can provide whatever information you wish.