Your suggestion sounded great so I did a few tests. I loaded a PCJR Teensy
LC (ARM Cortex-M0+) and a genuine Arduinio Leonardo (ATmega32u4) with the
standard BLINK program -- the Arduino equivalent of the Linux HELLOWORLD.
For those unfamiliar with the Arduino world both of these boards have native
USB support rather than using a FT232 or other separate chip. The BLINK
program requires no extra hardware but uses an Arduino pin to blink the
onboard LED. The program is only a few lines and there is no explicit code
to enable serial communication or do anything USB related. Hidden from the
user, several thousand bytes of system routines to control interrupts,
timers, USB, etc. are loaded together with the 5 line user program.

Results:
As soon as the Teensy LC is plugged in, lsusb shows a new USB device with
VID/PID of 16c0/04d3. PathPilot shows a status message that a USB device has
been connected.

As soon as the Arduino Leonardo is plugged in, lsusb shows a new USB device
with VID/PID of 2341-8036.  PathPilot shows a status message that a USB
device has been connected.

Conclusion:
The standard Arduino ecosystem does not easily allow USB enumeration to be
delayed. Everything is open source software so I'm sure that one can
disable/enable the on-chip USB but doing so is beyond my expertise.     

-----Original Message-----
From: Chris Albertson <albertson.ch...@gmail.com> 
Sent: December 3, 2020 12:58 PM
To: Enhanced Machine Controller (EMC) <emc-users@lists.sourceforge.net>
Subject: Re: [Emc-users] USB - Serial question

The problem is with the USB device.  If a FT232 chip is used it seems to be
doing the enumeration as soon as it is plugged in.
The simple solution is to avoid using the FT232 and use something else where
you have control over when and if enumeration occurs.

The good news is that this "something else is free and you already have it
-- the USB pins in the microcontroller.

In the Arduino IDE what start the enumeration is the ".begin()" method that
is called on the USB connection object.   Look in the IDE
File->Examples->USB to see an example
The example that is built into the IDE uses a keyboard or mouse object but
these are subclasses of something called (from my poor memory)
"PluggableUSB" and the source code for PluggableUSB explains hove to make
you own class that maybe you would call "MyCNC".    Then when you call
MyCNC.begin() the enumeration occurs and never before the call to
MyCNC.begin()

You can experiment with the examples provided.


On Thu, Dec 3, 2020 at 5:23 AM <ken.stra...@gmail.com> wrote:

> Les Newell wrote:
> Another option is to regularly poll the serial buffer using
> Serial.available() while you are initializing. If you don't spend too 
> much time in each loop() cycle, serialEvent() does most of the work for
you.
>
> Polling with Serial.available is my current approach for normal 
> processing
> -- moving steppers, actuating pneumatics, controlling pump, etc -- and 
> I'll probably extend it to handling initialization.
>
> -----Original Message-----
> From: Les Newell <les.new...@fastmail.co.uk>
> Sent: December 3, 2020 7:28 AM
> To: emc-users@lists.sourceforge.net
> Subject: Re: [Emc-users] USB - Serial question
>
> I'm a software guy so here are some possible software solutions.
> Why not wait for PathPilot to send it's setup query then do your 
> initialization? You still have plenty of time to do your 
> initialization while the machine is being homed etc.
> Another option is to regularly poll the serial buffer using
> Serial.available() while you are initializing. If you don't spend too 
> much time in each loop() cycle, serialEvent() does most of the work for
you.
> The hardest option would be to write your own serial interrupt routine 
> and do all of your serial in the ISR. You need to be comfortable with 
> talking directly to the ATMega hardware registers to do this.
>
> Les
>
>
>
> On 03/12/2020 00:53, ken.stra...@gmail.com wrote:
> > Chris wrote:  I think USB takes care of this for you.  "set up"
> > packets are sent by the host (the PC) and never by the device 
> > (mouse, disk, or whatever) The device never starts doing anything 
> > until after it
> hears from the host.
> >
> > You've precisely described my problem!  I need to do somewhat time 
> > consuming initialization -- home some steppers, actuate a pneumatic 
> > cylinder, prime a pump, verify coolant pressure, etc. Soon after 
> > PathPilot starts it scans for my USB device and, if found, sends a 
> > query to ensure that I'm actually alive. If I ignore or reject the 
> > alive query then PathPilot ignores me until my USB disconnects and 
> > then
> reconnects.
> >
> > My problem is that I may not yet know if I will ever be alive and 
> > ready when I'm first asked. I have a plan to queue any host requests 
> > received while I'm still initializing.
> >
> > Probably more explanation than you wanted!
>
>
>
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>
>
>
> _______________________________________________
> Emc-users mailing list
> Emc-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/emc-users
>


-- 

Chris Albertson
Redondo Beach, California

_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users



_______________________________________________
Emc-users mailing list
Emc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to