Closed humblewizard closed 9 years ago
Well, i made some changes to support different modes, please test pp-modes-fix
branch (npm i git+https://github.com/DeniSix/node-lpt.git#pp-modes-fix
).
You can set mode in constructor:
var lpt = require('lpt'),
port = new lpt.Port(0, 'byte'); // could be 'epp', 'ecp'... more in readme
port.data = 255;
console.log(port.data)
Data direction selected automatically on read/write to property. Please tell me if it works and if you need manual data direction control.
I'm getting a new error. Doesn't get to running. \ Installation response ****
lpt@0.2.2 install /home/bob/node_modules/lpt node-gyp rebuild make: Entering directory
/home/bob/node_modules/lpt/build' CXX(target) Release/obj.target/lpt/src/binding.o CXX(target) Release/obj.target/lpt/src/port.o CXX(target) Release/obj.target/lpt/src/port-status.o CXX(target) Release/obj.target/lpt/src/port-control.o SOLINK_MODULE(target) Release/obj.target/lpt.node SOLINK_MODULE(target) Release/obj.target/lpt.node: Finished COPY Release/lpt.node make: Leaving directory
/home/bob/node_modules/lpt/build' lpt@0.2.2 node_modules/lpt
**test code***** var lpt = require("lpt"); port = new lpt.Port(0); setInterval(function(){ console.log(port.data); },1000);
***** execution output error *****
/home/bob/TBinst/listPorts.js:25
port = new lpt.Port(0);
^
TypeError: Can't negotiate required mode
at Object.
Try to use different modes, like:
port = new lpt.Port(0, 'epp');
or
port = new lpt.Port(0, 'ecp');
But it probably expects IEEE 1284 compliant device on the wire, so if it wouldn't work i'll keep digging ;)
2015-02-24 22:41 GMT+03:00 Humblewizard notifications@github.com:
I'm getting a new error. Doesn't get to running. \ Installation response ****
lpt@0.2.2 install /home/bob/node_modules/lpt node-gyp rebuild make: Entering directory /home/bob/node_modules/lpt/build' CXX(target) Release/obj.target/lpt/src/binding.o CXX(target) Release/obj.target/lpt/src/port.o CXX(target) Release/obj.target/lpt/src/port-status.o CXX(target) Release/obj.target/lpt/src/port-control.o SOLINK_MODULE(target) Release/obj.target/lpt.node SOLINK_MODULE(target) Release/obj.target/lpt.node: Finished COPY Release/lpt.node make: Leaving directory/home/bob/node_modules/lpt/build' lpt@0.2.2 node_modules/lpt
****test code******* var lpt = require("lpt"); port = new lpt.Port(0); setInterval(function(){ console.log(port.data); },1000);
***** execution output error *****
/home/bob/TBinst/listPorts.js:25 port = new lpt.Port(0); ^ TypeError: Can't negotiate required mode at Object. (/home/bob/TBinst/listPorts.js:25:8) at Module._compile (module.js:456:26) at Object.Module._extensions..js (module.js:474:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Function.Module.runMain (module.js:497:10) at startup (node.js:119:16) at node.js:902:3
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75829901.
Those also die:
/home/bob/TBinst/listPorts.js:25
port = new lpt.Port(0,'ecp');
^
TypeError: Can't negotiate required mode
at Object.
/home/bob/TBinst/listPorts.js:25
port = new lpt.Port(0,'epp');
^
TypeError: Can't negotiate required mode
at Object.
/home/bob/TBinst/listPorts.js:25
port = new lpt.Port(0,'byte');
^
TypeError: Can't negotiate required mode
at Object.
I now have a working way to read the port on my device using parport. Xavier gives a way to write the control port which has a bit to change the data direction. It is not set automatically on a read operation like you're trying to do which I think would be a nice feature. You might have a look at it. https://github.com/jmendeth/parport.js
var par = require('parport');
var port = new par.Port();
port.writeControl(241); // sets the control port bit 5 to read mode
var reading = 128 + port.readData();
Well, that's not what tons of articles about parport in the internet tells.
I can't find any mention of fifth bit in control registry.
I updated pp-modes-fix
branch with "hard" mode set, so reinstall it and
try to use the following:
port = new lpt.Port(0,'byte', true);
And if it wouldn't work i'll try to find out what the mess with control register.
2015-02-24 23:23 GMT+03:00 Humblewizard notifications@github.com:
I now have a working way to read the port on my device using parport. Xavier gives a way to write the control port which has a bit to change the data direction. It is not set automatically on a read operation like you're trying to do which I think would be a nice feature. You might have a look at it. https://github.com/jmendeth/parport.js
var par = require('parport'); var port = new par.Port(); port.writeControl(241); // sets the control port bit 5 to read mode var reading = 128 + port.readData();
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75837960.
I'll give it try again.
Have you seen this? The control pin C5 is discussed. http://users.utcluj.ro/~baruch/media/siee/labor/Standard-Parallel-Port.pdf
The code runs without error now but the port has not been tristated for input. The read op fails to give the correct value and external cmos can not drive the port.
That's strange. I'm changing data direction but in the other way: by
ioctl
on the port. Please give it a try with the all others modes instead
of byte
: spp
, nibble
, epp
, ecp
.
2015-02-25 0:12 GMT+03:00 Humblewizard notifications@github.com:
The code runs without error now but the port has not been tristated for input. The read op fails to give the correct value and external cmos can not drive the port.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75847105.
I tried all 5 modes and the same thing happened, output register still not tristated for input.
Ok, try the last one update. Writing to control register now.
2015-02-25 0:36 GMT+03:00 Humblewizard notifications@github.com:
I tried all 5 modes and the same thing happened, output register still not tristated for input.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75851616.
It works!
Using: 'byte'
Great! I'll merge it into master and update npm package tomorrow 'cause it's late here.
OK, but just one more thing. Now writing is broken.
port.data = 255;
I have a 1 second timer that is writing one second and then reading the next second. The read op is working but there is no output on write now. On the write op you need to reverse the channel again.
Grab an update, it should be working now
2015-02-25 1:36 GMT+03:00 Humblewizard notifications@github.com:
OK, but just one more thing. Now writing is broken.
port.data = 255;
I have a 1 second timer that is writing one second and then reading the next second. The read op is working but there is no output on write now. One the write op you need to reverse the channel again.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75862249.
Still stuck in input mode.
Here is my code:
var lpt = require('lpt');
port = new lpt.Port(0,'byte',true);
var x = true;
var y = true;
setInterval(function(){
if(x){
// read port
console.log(port.data);
x = false;
}else{
// write port and every other time set high/low
x = true;
if(y){
port.data = 255;
y = false;
console.log("wrote 255");
}else{
port.data = 0;
y = true;
console.log("wrote 0");
}
}
},1000);
Have you tried to switch it back with parport.js
lib from
writeControl(241)
to writeControl(1)
so i was sure that's problem in
code?
2015-02-25 2:15 GMT+03:00 Humblewizard notifications@github.com:
Still stuck in input mode.
Here is my code:
var lpt = require('lpt'); port = new lpt.Port(0,'byte',true);
var x = true; var y = true; setInterval(function(){ if(x){ // read port console.log(port.data); x = false; }else{ // write port and every other time set high/low x = true; if(y){ port.data = 255; y = false; console.log("wrote 255"); }else{ port.data = 0; y = true; console.log("wrote 0"); } } },1000);
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-75869706.
parport.js is not working correctly either. Using the code example above (adapted to parport), if I don't do the writeControl(32) to assert input direction then the output will toggle high and low. If I do the writeControl(32) then it goes into input mode and writeControl(0) or writeControl(1) does not return the port to forward direction. I am going to read documentation on the parallel port further to see if there is something else that needs to happen here.
One more telling fact is the when I kill the process and restart it, the port starts in forward direction (output) and not until the writeControl(32)/C5 happens does it go to reverse direction (input). Why then does it not go back to forward when C5 is cleared???
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c
https://gist.github.com/DeniSix/b3d8ca9734f22052c452
https://gist.github.com/DeniSix/9e05d116bb25bb971e01
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev notifications@github.com wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207.
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev <notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637.
Dennis, partest2.c is working the best but has one thing wrong yet. It is reading data when it should and is getting the right value on the read operation. However when it switches to output the levels on all the port-pins go high no matter whether written with a 1 or 0.
I have another computer -- a new Intel Atom motherboard -- with an integrated parallel port. Im going to move over to that box and see what it does.
On Wed, Feb 25, 2015 at 12:29 PM, Denis Shemanaev notifications@github.com wrote:
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev < notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76049246.
Denis,
I moved my project over to a new computer. It's a small intel board with an integrated parallel port. Using partest2 the behavior is similar to the other comput/parport. When it is in input mode the drivers to the port pins can drive them and the data is being read OK. When it turns to the output mode alternating between high on low on all pins the output is always low. The difference being that on the last computer the output was always high. What we were expecting here was alternating high and low periods in between the data reading interval.
Strange and oddly difficult.
Bob
On Wed, Feb 25, 2015 at 12:29 PM, Denis Shemanaev notifications@github.com wrote:
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev < notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76049246.
I'm so inconsiderate! I am actually reading data instead of writing in "write" code section, sorry :( Let's try with updated gist.
2015-02-26 21:09 GMT+03:00 Humblewizard notifications@github.com:
Denis,
I moved my project over to a new computer. It's a small intel board with an integrated parallel port. Using partest2 the behavior is similar to the other comput/parport. When it is in input mode the drivers to the port pins can drive them and the data is being read OK. When it turns to the output mode alternating between high on low on all pins the output is always low. The difference being that on the last computer the output was always high. What we were expecting here was alternating high and low periods in between the data reading interval.
Strange and oddly difficult.
Bob
On Wed, Feb 25, 2015 at 12:29 PM, Denis Shemanaev < notifications@github.com> wrote:
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev < notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub <https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207 .
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76049246.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76231850.
Success, it works like it should. Data is reading fine and the output gets set appropriately high then low in between the data read ops.
So how is this different than what you had in the node.js driver?
Nice work!
Bob
On Thu, Feb 26, 2015 at 10:50 AM, Denis Shemanaev notifications@github.com wrote:
I'm so inconsiderate! I am actually reading data instead of writing in "write" code section, sorry :( Let's try with updated gist.
2015-02-26 21:09 GMT+03:00 Humblewizard notifications@github.com:
Denis,
I moved my project over to a new computer. It's a small intel board with an integrated parallel port. Using partest2 the behavior is similar to the other comput/parport. When it is in input mode the drivers to the port pins can drive them and the data is being read OK. When it turns to the output mode alternating between high on low on all pins the output is always low. The difference being that on the last computer the output was always high. What we were expecting here was alternating high and low periods in between the data reading interval.
Strange and oddly difficult.
Bob
On Wed, Feb 25, 2015 at 12:29 PM, Denis Shemanaev < notifications@github.com> wrote:
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev < notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub < https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207 .
— Reply to this email directly or view it on GitHub <https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637 .
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76049246.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76231850.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76242067.
Well, there was a few misconceptions in the code. Try fixed library from
pp-modes-fix
branch, please. Looks like it should be fixed now. And there
is no need in additional params to Port
class, just port number like it
was.
2015-02-26 23:10 GMT+03:00 Humblewizard notifications@github.com:
Success, it works like it should. Data is reading fine and the output gets set appropriately high then low in between the data read ops.
So how is this different than what you had in the node.js driver?
Nice work!
Bob
On Thu, Feb 26, 2015 at 10:50 AM, Denis Shemanaev < notifications@github.com>
wrote:
I'm so inconsiderate! I am actually reading data instead of writing in "write" code section, sorry :( Let's try with updated gist.
2015-02-26 21:09 GMT+03:00 Humblewizard notifications@github.com:
Denis,
I moved my project over to a new computer. It's a small intel board with an integrated parallel port. Using partest2 the behavior is similar to the other comput/parport. When it is in input mode the drivers to the port pins can drive them and the data is being read OK. When it turns to the output mode alternating between high on low on all pins the output is always low. The difference being that on the last computer the output was always high. What we were expecting here was alternating high and low periods in between the data reading interval.
Strange and oddly difficult.
Bob
On Wed, Feb 25, 2015 at 12:29 PM, Denis Shemanaev < notifications@github.com> wrote:
Oh, i messed with timeouts, it's in seconds :) Try the updated gists please.
2015-02-25 23:16 GMT+03:00 Humblewizard notifications@github.com:
Denis,
Thanks for your continued support in this.
I tried your two c examples and in both cases they set the port from an input (left that way before starting) to an output. They hit the if(x){} once and then nothing more shows on the console and the output on the port doesn't change. It's as if they hit the sleep(1000) and never woke up again. No errors showing on the console. Might there be errors in a log file somewhere?
Bob
On Wed, Feb 25, 2015 at 9:58 AM, Denis Shemanaev < notifications@github.com
wrote:
Here is two different ways of parport usage in plain c. All tutorials claimed that it working methods. Give it a try. Compiling simply by gcc partest.c https://gist.github.com/DeniSix/b3d8ca9734f22052c452 https://gist.github.com/DeniSix/9e05d116bb25bb971e01
— Reply to this email directly or view it on GitHub < https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76018207 .
— Reply to this email directly or view it on GitHub < https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76046637 .
— Reply to this email directly or view it on GitHub <https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76049246 .
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76231850.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76242067.
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76259910.
Denis,
I am reporting back to you that everything looks good with your node-lpt tool now. The issues I had have been corrected. Thanks for your support and diligent effort on this.
Bob
Glad to help you, Bob. Pushed a new version into npm.
2015-03-01 8:21 GMT+03:00 Humblewizard notifications@github.com:
Denis,
I am reporting back to you that everything looks good with your node-lpt tool now. The issues I had have been corrected. Thanks for your support and diligent effort on this.
Bob
— Reply to this email directly or view it on GitHub https://github.com/DeniSix/node-lpt/issues/3#issuecomment-76574985.
The output writing works on my system. I can set D0-D7 either high or low. But I can't read external data through the port. The read operation does not change the data direction.
I can see with an oscilloscope that the ports are being set by the port.data command but the read operation does not clear the output state to allow the external CMOS to drive the port.
The ECP Reverse Data Cycle needs to be used?????