General USB problem with Serial Node

2,055 views
Skip to first unread message

Peter Scargill

unread,
Jun 26, 2016, 5:30:38 AM6/26/16
to Node-RED
I've been struggling with Firmata on the Raspberry Pi - and plugging in an Arduino MEGA.. I just could not get the serial to work reliably and when you remove the usb serial with the node-red node still pointing to it, Node-Red won't even start up - uncaught exception. I did not want to use the internal UART of the Pi as I use that to drive a serial display.

HOWEVER I thought I'd take a step back. I plugged in a standard FTDI into the Raspberry Pi - and it appears in Node-Red serial as /dev/ttyUSB0 - no problem.

However, stick an inject node into the serial in node - and debug on the serial out node (with 100ms timeout) - short the input and output on the FTDI - you inject something - both serial in and out lights flash on the FTDI and....... nothing - no output, no error messages (in the system logs which show the USB connected just fine). I've tried various combinations of the DR and RTS pins - nothing coming into the serial in at all.

Am I missing something? Anyone else had this?

Peter Scargill

unread,
Jun 26, 2016, 6:43:15 AM6/26/16
to Node-RED

To make life easier with pictures - I've put this up here - and help appreciated. 

Dave C-J

unread,
Jun 26, 2016, 7:11:45 AM6/26/16
to node...@googlegroups.com
So are trying to drive a 5V input (on the FTDI board) with a 3.3V output from Pi ? 

Peter Scargill

unread,
Jun 26, 2016, 7:12:42 AM6/26/16
to node...@googlegroups.com

Nope – all at 3v3. See pic on my blog – there’s a link.

--
http://nodered.org
 
Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/TuRgwBIbFOM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send email to node...@googlegroups.com.
Visit this group at https://groups.google.com/group/node-red.
For more options, visit https://groups.google.com/d/optout.

Dave C-J

unread,
Jun 26, 2016, 7:30:42 AM6/26/16
to node...@googlegroups.com
Simple loopback of FTDI cable to itself

(I have the cable TTL-232R-5V from here http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm



Peter Scargill

unread,
Jun 26, 2016, 7:42:45 AM6/26/16
to node...@googlegroups.com

That’s what I’m doing (just a simple loop wire between RX and TX on the FTDI – works exactly as you’d expect… but here’s the thing…

 

I took out the FTDI - put another one in - that appeared as USB1... it worked - I took that out and plugged the ORIGINAL back in - now this appeared as USB2 (figure that out) - and worked!! Rebooted - it went back to being USB0 - it worked.  I turned the power off them on - nothing. No serial in.

 

So…. I took the FTDI out - and put it back in - now it appeared as USB1 - adjusted the setting on Node-Red accordingly - it worked.  Rebooted…No USB 1 – looked in Node – USB0 is back. Adjusted. All is well on USB0.

 

Turned the power back off then on (for the whole lot)…. Green connected lights on the in and out nodes, all’s well – BUT – no input. I could again see both lights on the FTDI indicating that it is not only sending but pulling back in – but nothing in the debug window when injecting text.

 

But this had WORKED after a reboot… but not after power up… so – I tried rebooting again…surely it would work? No.

 

I pulled the FTDI out – and plugged it back in… USB0 disappeared but USB1 was valid…. I changed the node to work with USB1 – it worked.

 

So it seems that the only situation when the input does not work – is when both the Pi and the FTDI have been powered down and back up.

 

Should I just cut my wrists now?

 

 

 

From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Dave C-J
Sent: 26 June 2016 13:31
To: node...@googlegroups.com
Subject: Re: [node-red] Re: General USB problem with Serial Node

 

Simple loopback of FTDI cable to itself

 

(I have the cable TTL-232R-5V from here http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

 


--

image001.gif

Dave C-J

unread,
Jun 26, 2016, 8:26:43 AM6/26/16
to node...@googlegroups.com
... that - or start drinking heavily

If I have a vanilla apt-get install - set to auto-start using systemd - with just that flow.
I can poweroff - boot - point browser at it and ... data comes out.

Peter Scargill

unread,
Jun 27, 2016, 6:54:37 AM6/27/16
to Node-RED
I'm getting somewhere - and no-where.

If I use the normal serial node - I can see it connect to ttyUSB0.... and if I delete the node.... I see it disconnect (running node-red in a terminal window so I can see the output).

But if I do the same with the Arduino node - I can see it connect... but no DISCONNECT.. so the odd set of circumstances I can get it to connect - say, with digital IO - and get port 7 to flick on and off - which I can.... if I change the node properties to say ANALOG - it always bombs out - and looking at the terminal output - it makes no attempt to disconnect and reconnect... and so of course you get the red "connecting message".

I don't think the FTDI is off the hook here but there is something wrong with the Firmata node.. SURELY when you change anything in the node settings - it should disconnect and reconnect??

Dave C-J

unread,
Jun 27, 2016, 8:43:14 AM6/27/16
to node...@googlegroups.com
"surely" it should.... will have a look. Would certainly explain some of the issues if it was blocking it reconnecting a second time. (Though this sounds different to the not working on boot problem).

Peter Scargill

unread,
Jun 27, 2016, 2:25:55 PM6/27/16
to node...@googlegroups.com

Well all I can say is that if you have node-red running in a terminal – every time it connects – you see it – when you change things in the serial connector you see a disconnect.. but NOT in the Arduino node….

 

I think there are TWO problems here – the serial not receiving stuff after a powerup has not gone away. I really would love to know if others have issues – maybe it would help to know what FTDIs they are using – but I use mine constantly for blowing ESP chips and Arduinos and never have issues with them from that perspective.

 

Any and all feedback or ideas welcome.

 

Pete.

 

From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Dave C-J
Sent: 27 June 2016 14:43
To: node...@googlegroups.com
Subject: Re: [node-red] Re: General USB problem with Serial Node

 

"surely" it should.... will have a look. Would certainly explain some of the issues if it was blocking it reconnecting a second time. (Though this sounds different to the not working on boot problem).

--

Peter Scargill

unread,
Jul 11, 2016, 11:58:45 AM7/11/16
to Node-RED
Just an update guys - the SERIAL issue is resolved...  was down to handshaking - I can make an utterly reliable USB serial port with shortcut name ttyUSBPETE1

So 2 problems with Node-Red nodes:

1. SERIAL  -  It cannot search for serial shortcuts - you have to enter them in manually then they work...
2. FIRMATA - now I have a working serial (can be accesses as ttyUSB0) - Firmata on an ATMEGA2560 - connects sometimes and works on port 7 to turn on and off.. try changing that however to port 11 and PWM - and Node-Red crashes quite reliable...   anyone else tried this?

Pete

Julian Knight

unread,
Jul 11, 2016, 3:32:40 PM7/11/16
to Node-RED
Sorry, never found firmata all that reliable so I always tend to hand-crank the code.

Dave C-J

unread,
Jul 12, 2016, 3:57:16 AM7/12/16
to node...@googlegroups.com
Peter

1) the underlying serialport library uses a whitelist of device names (USB, AMA, S) etc to look for so it won't "detect" aliases - so yes you will need to type them in.
2) You may need a different version of firmata for the atmega2560 as the physical pins are different to a standard Arduino

Dave C-J

unread,
Jul 12, 2016, 8:05:24 AM7/12/16
to node...@googlegroups.com
Peter,

playing with this in another thread - I'm going to recommend uninstalling the node-red-node-arduino instead to use the node-red-contrib-gpio

Peter Scargill

unread,
Jul 12, 2016, 10:32:53 AM7/12/16
to Node-RED
Thanksd for that Dave

A little feedback for you.

Having seen your response - I went to my Pi installation (I have a spare identical one that I can screw up without committing suicide) and sure enough I have the yellow gpio contrib node.

I put a couple of injects on it (1 and 0) an set it up to ttyUSB0 - and then to test - to ttyUSB-PETER - both worked on GPIO 7 - I could turn a light on and off. It seemed to take a couple of seconds to say "Connected!!!".   

But again when trying to change to say, pin 6... I noted that it now said "connection" -  I must stress at this point a BIG difference between this and the Arduino node - Node-Red is NOT crashing - that's a big move forward.

I wondered. Recall the log for Node-Red when messing with the serial port says "connecting" and disconnecting" etc when you  change. I wondered if perhaps no DISCONNECT was taking place.

I stopped node-red and started Node-Red manually...


1468333183183 Connected Firmata

Sure enough - back to the graphics screen - "connectged" - I tried the port - yes.

Tested the light - yes..

Clicked on the yellow node to make a change - to port bit 6. ~Clicked DEPLOY.


12 Jul 16:22:04 - [info] Stopping modified nodes
12 Jul 16:22:04 - [info] Stopped modified nodes
12 Jul 16:22:04 - [info] Starting modified nodes
12 Jul 16:22:04 - [info] Started modified nodes

Should there have been a disconnect/connect sequence there?  No such sequence occurred and once again.... "connecting"....

Without shutting down the ATMEGA2560 or disconnecting, I stopped Node-Red - and restarted.... VOILA - bit 6 working.

I'm not an expert - but my money is on missing disconnect-reconnect sequence when making changes to the Firmata settings.

To push this - I set up PWM on one of the 2560 pins.. pin 11.

Again - no crashing Node-Red (good) - but "connecting"  (BAD).

I stopped and started Node-Red. I changed the "1" to "10" - sure enough - a dimly lit LED.

This tells me - in my simple logic - that the ATMEGA2560 is working a treat - and that there is something wrong happening when you make a change to the node.....that perhaps the connection should be closed and re-opened.

STILL - at least it doesn't crash Node-Red now.

Any way we can TEST this idea??

Dave C-J

unread,
Jul 13, 2016, 9:21:20 AM7/13/16
to node...@googlegroups.com
Peter,

as per other thread I have now rewritten the Arduino node to use another npm - (version 0.0.8) - and hopefully fixed the stop/start problem at the same time... but no doubt you'll let me know if otherwise :-)

Peter Scargill

unread,
Jul 14, 2016, 4:55:30 AM7/14/16
to Node-RED
Thanks Dave

I've been playing with this, this morning (and last night) - as you know I had to change NODE versions - that in itself was tear-producing - however - done, all working.

This morning I've been sending PWM to the Arduino (with Firmata loaded) and switching stuff on and off - on the one hand, reliability has shot up - insofar as Node-Red now DOES NOT crash - that's a great move forward (glad to know it wasn't me). However, on the other front - nowhere.

SO - I have an inject firing outputs one a second into a function  which then feeds the Arduino node - just as an example. I can make changes to the function - no problem - sending out digital or analog values - no problem. BUT - as soon as I open up the Arduino node to change, say the pin or the function (digital/PWM/etc) or both - that's it - dead - the node states "connecting" and simply won't connect to the unit. A restart of Node-Red fixes this every time now.

So there is some difference between restarting node red and modifying values in the node that allows the former to reliably connect to the USB - but the latter to NEVER reconnect to the USB.

I am around on and off today to do any tests if you are able to look at this one.

(Incidentally it handles both ttyUSB0 and the shortcuts equally - and that's good).

Dave C-J

unread,
Jul 14, 2016, 4:59:09 AM7/14/16
to node...@googlegroups.com
so basically it works fine on first deploy/start... and as long as none of the Arduino nodes change they stay fine... but any change to them then needs a restart.   I think I can guess - the actual instance of the link to the pin is not going away on redeploy - so it blocks the next connect attempt...

Will have a play but have some client work to do today (uurgh)... it'll either be an easy fix... or not ! :-)
Thanks 

Max Hadley

unread,
Jul 14, 2016, 5:03:58 AM7/14/16
to Node-RED
Are you doing a full deployment or a 'changed nodes only'? I have realised there is a potential issue in the rfxcom node I need to look at and it could be present here as well - using 'remove all listeners' when a node is closed might disconnect other, unchanged nodes.
Max

Peter Scargill

unread,
Jul 14, 2016, 5:49:36 AM7/14/16
to node...@googlegroups.com

Your a good person :)

--

Peter Scargill

unread,
Jul 14, 2016, 9:59:45 AM7/14/16
to node...@googlegroups.com
I am using a "changed nodes only" - as a full redeploy resets my home control which is running on another tab :-)

For "remove all listeners" I defer to Dave :-)

Pete.

-----Original Message-----
From: node...@googlegroups.com [mailto:node...@googlegroups.com] On Behalf Of Max Hadley
Sent: 14 July 2016 11:04
To: Node-RED <node...@googlegroups.com>
Subject: Re: [node-red] Re: General USB problem with Serial Node

--
http://nodered.org

Join us on Slack to continue the conversation: http://nodered.org/slack
---
You received this message because you are subscribed to a topic in the Google Groups "Node-RED" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/node-red/TuRgwBIbFOM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to node-red+u...@googlegroups.com.
To post to this group, send an email to node...@googlegroups.com.

Peter Scargill

unread,
Jul 14, 2016, 11:19:59 AM7/14/16
to Node-RED, pe...@scargill.org

I understand that just perhaps - a fix is on the way - looks like partial deploy does reproduce the problem I'm having whereas full deploy is ok.

I am so looking forward to seeing this working correctly - expecially as recent changes have made my CONTRIB-GPIO bright shiny node disappear..

But can I make a feature request...

And I quote from the ATMEGA2560 board documentation..

44 digital IO pins, 14 of which can be used for PWM.  16 Analog inputs, 4 UARTS

Any chance of adding in those analog inputs and 4 uarts to the items controlled in the Arduino node when using Firmata? That would be nice - especially as these boards are now under £6 from China.

Dave C-J

unread,
Jul 14, 2016, 12:34:40 PM7/14/16
to node...@googlegroups.com
Peter,

you can re-install the contrib-gpio node any time you like... 
There is nothing to stop the basic digital and analogue pins working other than support via firmata. We don't limit the pin number you can enter so you can enter pin 99 if you had one. (but I'm not sure which pins firmata supports... probably all of them these days... but ymmv).

We do not intend to give passthrough access to other serial ports - too many settings and options to handle. Will let someone else do that if they feel like a challenge.
Reply all
Reply to author
Forward
0 new messages