Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rx.write Error sending reply #23

Open
eloyucu opened this issue Sep 25, 2014 · 2 comments
Open

rx.write Error sending reply #23

eloyucu opened this issue Sep 25, 2014 · 2 comments

Comments

@eloyucu
Copy link

eloyucu commented Sep 25, 2014

Hello everyone (Hello Nathan... again).

I am trying make a litle test to see how nrf worls, butn I am finding any troubles. The (by the moment) principal issue is that when I try to send something through tx var, the module throw this error: Error sending reply. [Error: Packet timeout, transmit queue flushed.]
It makes me think... can I only use the tx to reply a petition from a slave (assuming that the rasp will be a master)?

Returning to the main theme, this is my code (on the wifi.js file):

var NRF24 = require("nrf"),
    spiDev = "/dev/spidev0.0",
    cePin = 22, irqPin = 25,            //var ce = require("./gpio").connect(cePin)
    pipes = [Buffer("746D610000",'hex'), Buffer("0000616D74",'hex')];

var nrf = NRF24.connect(spiDev, cePin);

nrf.channel(2);
nrf.transmitPower('PA_MAX');
nrf.dataRate('2Mbps');
nrf.crcBytes(1);
nrf.autoRetransmit({count:15, delay:500});
var tx;
nrf.begin(function () {
    var rx = nrf.openPipe('rx', pipes[0]);
   tx = nrf.openPipe('tx', pipes[1]);

    nrf.printDetails();
    rx.on('data', function (d) {
        console.log(d);
        //tx.write(d);
    });
    tx.on('error', function (e) {
        console.warn("Error sending reply.", e);
    });
});

exports.send = function(data){
    tx.write(data);
}

And here, how I invoke the send function from the index.js:

router.get("/example1", function(req, res)
{
    wifi.send("1");
    res.render(...............);
});

And the printDetails:

Recommend use with IRQ pin, fallback handling is suboptimal.
SPI device:      /dev/spidev0.0
CE GPIO:         22
IRQ GPIO:        undefined
STATUS:          0xe RX_DR=0 TX_DS=0 MAX_RT=0 RX_P_NO=7 TX_FULL=0
RX_ADDR_P0–1:    0x0000616d74 0x746d610000
RX_ADDR_P2–5:    0xc3 0xc4 0xc5 0xc6
TX_ADDR:         0x0000616d74
RX_PW_P0–5:      0x20 0x20 0x0 0x0 0x0 0x0
EN_AA:           0x3f
EN_RXADDR:       0x03
RF_CH:           0x2
RF_SETUP:        0x0f
CONFIG:          0x0b
DYNPD/FEATURE:   0x3f 0x07
Data Rate:       2Mbps
Model:           nRF24L01+
CRC Length:      8 bits
PA Power:        PA_MAX
GET /example1 304 8357.400 ms - -
GET /stylesheets/style.css 304 68.628 ms - -
Error sending reply. [Error: Packet timeout, transmit queue flushed.]

Iwas reading about problems with the comms (arduino-rasp in my case), in this post and this other one and I think I am making everything correctly... I made this (becouse I used the c++ library):

sudo modprobe -r spi_bcm2708
sudo modprobe spi_bcm2708

And the printDetails is from the second running (the address on the first failed).

Thank you very much.

@natevw
Copy link
Owner

natevw commented Sep 26, 2014

If you get a "Packet timeout, transmit queue flushed" error this means either:

  • the remote radio could not receive the packet
  • the local radio did not hear the acknowlegement

This will usually be due to simple radio range trouble (try moving closer) or when developing more often this is because of a configuration mismatch (channel, data rate, address, crc length). Does that help?

@eloyucu
Copy link
Author

eloyucu commented Sep 26, 2014

Hello Natan, thank you for your fast answer.

Upppssss!!! you are right... the arduino wasn´t right set up.

But... regret a lot, for taking... when I send the first message to the arduino works fine, the second message too works... but the third stops to work... the server continues running, and it seems that pass through the send method, where I put a console.log:

exports.send = function(data){
    console.log("I am sending. Value: " + data);
    tx.write(data);
}

With idea to have more info I set the _debug variable to true, and here are the results.
The firs time I send something:

I am sending. Value: 1
Set CE low.
setStates { TX_ADDR: <Buffer f0 f0 f0 f0 e1>,
  PRIM_RX: false,
  RX_ADDR_P0: <Buffer f0 f0 f0 f0 e1> }
GET /example1 304 8580.798 ms - -
execCommand [ 'R_REGISTER', 0 ] 1
 - exec read: <Buffer 0e 0b>
execCommand [ 'W_REGISTER', 0 ] [ 10 ]
blocked for 130µs.
execCommand [ 'W_REGISTER', 10 ] <Buffer f0 f0 f0 f0 e1>
execCommand [ 'W_REGISTER', 16 ] <Buffer f0 f0 f0 f0 e1>
execCommand W_TX_PAYLOAD <Buffer 31>
GET /stylesheets/style.css 304 73.585 ms - -
Set CE true.
blocked for 10µs.
Set CE false.
blocked for 4µs.
_checkStatus, irq = true checking = false
execCommand [ 'R_REGISTER', 7 ] 1
 - exec read: <Buffer 2e 2e>
gotStates { RX_P_NO: 7, TX_DS: 1, MAX_RT: 0, RX_DR: 0 } null
IRQ. { RX_P_NO: 7, TX_DS: 1, MAX_RT: 0, RX_DR: 0 }
setStates { TX_DS: true, MAX_RT: true, RX_DR: false }
execCommand [ 'R_REGISTER', 7 ] 1
 - exec read: <Buffer 2e 2e>
execCommand [ 'W_REGISTER', 7 ] [ 62 ]
Set CE high.
setStates { PRIM_RX: true }
execCommand [ 'R_REGISTER', 0 ] 1
 - exec read: <Buffer 0e 0a>
execCommand [ 'W_REGISTER', 0 ] [ 11 ]
blocked for 130µs.
_checkStatus, irq = true checking = false
execCommand [ 'R_REGISTER', 7 ] 1
 - exec read: <Buffer 40 40>
gotStates { RX_P_NO: 0, TX_DS: 0, MAX_RT: 0, RX_DR: 1 } null
IRQ. { RX_P_NO: 0, TX_DS: 0, MAX_RT: 0, RX_DR: 1 }

The second time I send:

I am sending. Value: 1
Set CE low.
setStates { TX_ADDR: <Buffer f0 f0 f0 f0 e1>,
  PRIM_RX: false,
  RX_ADDR_P0: <Buffer f0 f0 f0 f0 e1> }
GET /example1 304 644.694 ms - -
execCommand [ 'R_REGISTER', 0 ] 1
 - exec read: <Buffer 40 0b>
execCommand [ 'W_REGISTER', 0 ] [ 10 ]
blocked for 130µs.
execCommand [ 'W_REGISTER', 10 ] <Buffer f0 f0 f0 f0 e1>
execCommand [ 'W_REGISTER', 16 ] <Buffer f0 f0 f0 f0 e1>
execCommand W_TX_PAYLOAD <Buffer 31>
Set CE true.
blocked for 10µs.
Set CE false.
blocked for 4µs.
GET /stylesheets/style.css 304 28.213 ms - -

And the third and next times I send something:

I am sending. Value: 0
GET /example0 304 691.173 ms - -
GET /stylesheets/style.css 304 15.526 ms - -

Do I need to flush a cache or something like that?? or what am I doing wrong??
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants