usb_configured on teensy 3.2

Status
Not open for further replies.

drjohnsmith

Well-known member
I'm having problems with usb_configured on a new teensy 3.2 project.


Have boiled it down to a simple test code,
the usb_serial_avaialble() does not cause an error , but the usb_configured causes a error, "it was not defined "

arduino 1.6.9 and teensduino 1.3

Thoughts please ?


void setup()
{
Serial.begin(9600); // USB is always 12 Mbit/sec
}

void loop()
{
Serial.println("Hello World...");
usb_serial_available();
usb_configured();
delay(1000); // do not print too fast!
}
 
For me wondering what it is you are trying to do and why you are not just using standard Arduino stuff?

That is, you can simply replace the line: usb_serial_available();
with: Serial.available();

And have no idea what is: usb_configured? When I do a search on sources installed as part of Teensyduino, I don't see this defined anywhere...
 
For me wondering what it is you are trying to do and why you are not just using standard Arduino stuff?

That is, you can simply replace the line: usb_serial_available();
with: Serial.available();

And have no idea what is: usb_configured? When I do a search on sources installed as part of Teensyduino, I don't see this defined anywhere...

Well,
the usb_serial stuff is the original, written in plain C and can be used to, say debug, plain C code.
Serial.xxx is only a C++ wrapper useful only to cpp (including ino) files.

@drjohnsmith
in fact usb_configured is only defined in usb_debug_only
uint8_t usb_configured(void)
{
return usb_configuration;
}

so you can simply add this function without sideffects
 
Well,
the usb_serial stuff is the original, written in plain C and can be used to, say debug, plain C code.
Serial.xxx is only a C++ wrapper useful only to cpp (including ino) files.
Thanks, I am aware...

but they are already in a sketch (setup, loop), and are already calling other C++ wrappers, like Serial.println()...
 
Took a quick look at the zip file and it looks like none of the files have changed since 2009.

The example program, had stuff in it like:
Code:
	usb_init();
	while (!usb_configured()) /* wait */ ;

Which today I would write as:
Code:
    Serial.begin(115200);  // baud does not really matter here.
    while (!Serial) ;
Actually I usually put a timeout in the !Serial... like: while(!Serial && (millis() < 5000)) ;
So it will wait up to 5 seconds...

Can probably also map most of the other stuff over to normal Arduino stuff, but again not sure what you are doing. The example program in the zip file was a simple program with a makefile... Not sure if what you are trying to do is as well? Also the zip file has files like print.h, analog.h as well as their .c files. Not sure how they would work in arduino builds.
 
Thanks KurtE

Thats what I was hoping,
could not work out easily which was the new style or the old style !

usb_configured seemed 'tighter' to me , but !Serial as you say is the way forward.

Thank you for your succinct answer.
 
Status
Not open for further replies.
Back
Top