PDA

View Full Version : Code 43 problems on Windows



Somnitec
04-29-2013, 08:22 PM
As stated on the troubleshoot (http://www.pjrc.com/teensy/troubleshoot.html) page, there is no definite solution for the "Code 43" problem. What happens, is that the Teensy3.0 suddenly (after uploading a sketch) won't install as a "USB Serial" device, but as an "Unknown Device". Strange thing is that the Teensy Loader still uploads sketches (though not automatic anymore). Serial communication doesn't work, and no COM port is displayed in the sub-menu. (All this running Windows 7.)


After a long time of trying a lot of different thing including power-down, windows update and update driver, it suddenly worked again! What I did was "Add Legacy Hardware" in the following steps:

Manage Computer > Action > Add Legacy Hardware > Install Manually from a list > Ports (COM & LPT) > PJRC.COM, LLC > USB Serial > Next > Finish

The strange thing now is that after loading the blink example the Teensy is installed correctly again and my Device Manager now shows two times "USB Serial", one for COM10 (the one I just installed) and one for COM9 (the actual Teensy)

If anyone has more information on this issue, please contribute!

Edit: I notice on one of my untested/incomplete sketches (http://pastebin.com/RPBfS3PC), I get the dreaded "Code 43", while a confirmed-to-work sketch fixes it again... Added the code (http://pastebin.com/RPBfS3PC) for potential reference.

PaulStoffregen
04-30-2013, 08:36 PM
Here's another message where someone recovered from Windows incorrectly assigning drivers.

http://forum.pjrc.com/threads/23566-Teensyduino-USB-Joystick-no-data-driver-problem-workaround?p=30944&viewfull=1#post30944

I'm not sure if messing with registry editing is a good idea in the case, but it might be worth trying if the problem returns or gets worse?

Somnitec
05-02-2013, 10:16 AM
So after another day of dealing with the problem, I found my workaround. When the Teensy3.0 suddenly loses connection, I upload a simple, tested program with Serial in it. I have to press the button on the Teensy to make it upload. And then it reconnects and I can upload the sketch I was working on again.

The problems seems to occur when sending a lot of Serial data which then suddenly stops. So my guess is a bufferoverflow or something similar. Sometime the Arduino IDE displays some sort of java memory error, though I forgot to note it earlier, will do when it happens again.

PaulStoffregen
05-02-2013, 01:52 PM
Can you post the code, both Teensy and PC side? If I can reproduce the problem here, I could try to investigate.

Somnitec
05-02-2013, 08:47 PM
So, Arduino gives me the errors pasted below, using the attached code, and windows tells me "USB device not recognized". (And again, when uploading a known to work sketch, all is fine again.) I'm using windows7, Arduino 1.0.4 and the latest TD version (not sure where I can derive the actual version number)

434
435


processing.app.SerialNotFoundException: Serial port 'COM9' not found. Did you select the right one from the Tools > Serial Port menu?
at processing.app.Serial.<init>(Serial.java:193)
at processing.app.Serial.<init>(Serial.java:92)
at processing.app.SerialMonitor.openSerialPort(Serial Monitor.java:224)
at processing.app.Editor.handleSerial(Editor.java:259 3)
at processing.app.EditorToolbar.mousePressed(EditorTo olbar.java:353)
at java.awt.Component.processMouseEvent(Component.jav a:6260)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:602 8)
at java.awt.Container.processEvent(Container.java:204 1)
at java.awt.Component.dispatchEventImpl(Component.jav a:4630)
at java.awt.Container.dispatchEventImpl(Container.jav a:2099)
at java.awt.Component.dispatchEvent(Component.java:44 60)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4574)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4235)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4168)
at java.awt.Container.dispatchEventImpl(Container.jav a:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475 )
at java.awt.Component.dispatchEvent(Component.java:44 60)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 599)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:269)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:184)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:174)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:169)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)

A. Williams
03-28-2015, 09:10 PM
Wow this is seriously the weirdest freakin problem. I've come to solve it for myself, but i have really no idea how it works or why. My first step was flashing the teensy chip with the code shown below. That seemed to have "cleared the cache" of sorts with the usb drive, and my serial com port came back up.



void setup() {Serial.begin(9600);}

void loop() {Serial.print("Fuk"); Serial.print(" "); delay(50);
}

A. Williams
03-28-2015, 09:13 PM
HOWEVER when i went back to flash the code i was working on back onto the teensy chip again, i immediately got the error again. Granted, I was attempting to send something like 30 strings through the serial port. So I edited the code to remove any extra code that could not be part of the problem, and i changed my massive serial send to only send a very simple/small string.
This is the code i then wrote



char c[38];
int knob1x; float knob1; int amountturned; int amount; int amount1; int amount2;
int index1; int indexF; int indexF1; int indexfinal;
String bs, bs2, bs3,bs4, bs5 bs6, bs7, bs8, bs9, bs10, bs11, bs12, bs13, bs14, bs15, bs16, bs17, bs18, bs19, bs20, bs21;
String bs22, bs23, bs24, bs25, bs26, bs27, bs28, bs29, bs30, bs31, bs32, bs33, bs34, bs35, bs36, bs37, bs0, bs02, bs03;
String bs04, bs05, bs06, bs07, bs08, bs09, bs010, bs011, bs012;

int mult1, mult2, mult3, mult4, mult5, mult6, mult7, mult8, mult9, mult10, mult11, mult12;
String bsmult1, bsmult2, bsmult3, bsmult4, bsmult5, bsmult6, bsmult7, bsmult8, bsmult9,bsmult10, bsmult11, bsmult12;
int auxknob1, auxknob1final, multamount;
int auxknob2, auxknob2final, multamount2;
void setup()
{
Serial.begin(9600);
}
void loop()
{ Serial.print("eh"); delay(100);
}

A. Williams
03-28-2015, 09:16 PM
BUT I STILL GOT THE ERROR.
so started messing with the way i declared the variables, and I discovered that, not only does it depend on how big your serial message is, but it also depends on how you initiate your string variables. Weirdness.
I changed my code to the code below, and the error was gone!


char c[38];
int knob1x; float knob1; int amountturned; int amount; int amount1; int amount2;
int index1; int indexF; int indexF1; int indexfinal;
String bs; String bs2; String bs3;
String bs4; String bs5; String bs6, bs7;
String bs8; String bs9;
String bs10; String bs11; String bs12;
String bs13; String bs14;
String bs15; String bs16; String bs17;
String bs18; String bs19;
String bs20; String bs21;
String bs22; String bs23;
String bs24; String bs25;
String bs26;
String bs27; String bs28;
String bs29; String bs30;
String bs31; String bs32;
String bs33; String bs34;
String bs35; String bs36, bs37;
String bs0; String bs02; String bs03; String bs04; String bs05;
String bs06; String bs07; String bs08; String bs09; String bs010; String bs011; String bs012;

int mult1, mult2, mult3, mult4, mult5, mult6, mult7, mult8, mult9, mult10, mult11, mult12;
int auxknob1, auxknob1final, multamount;
int auxknob2, auxknob2final, multamount2;
void setup()
{String bsmult1; String bsmult2; String bsmult3;
String bsmult4; String bsmult5;
String bsmult6; String bsmult7; String bsmult8; String bsmult9;
String bsmult10; String bsmult11; String bsmult12;
Serial.begin(9600);
}
void loop()
{ Serial.print("eh"); delay(100);
}

so i figured out a workable fix for this problem, but i'm still rather confused, but not complaining.

btw, i was running arduino 1.0.6 on a windows 7 computer flashing to a teensy 3.1

defragster
03-28-2015, 09:49 PM
I've not seen this issue on Win7 w/3.1 & IDE 1.6.x.

But I have seen sketches not get clean Usb/Serial on powerup so I started putting this in most every sketch and it lets me get the first message and works fine after - you can adjust the 7000, but that is worst case. Please post if you try and it changes anything - or not.


void setup() {
Serial.begin(38400);
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 7000)) ;

5shekel
12-18-2015, 10:52 PM
I've not seen this issue on Win7 w/3.1 & IDE 1.6.x.


void setup() {
Serial.begin(38400);
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 7000)) ;

thanks, adding your code re-enabled my teensies USB drivers.



#include <PrintEx.h>
using namespace ios;

int arrA[ 5 ] = { 1, 2, 3, 4, 5 };
int arrB[ 5 ] = {};

void setup() {
Serial.begin(57600);

/*
* //uncommnet to unbrink
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 7000)) ;
*/
//following will soft-brink the USB driver
debug(arrB, arrA, 5, 5);
}

void loop() {

}

void debug(int *a, int *b, int len_a, int len_b) {
int n;
// test each element to be the same. if not, return false
for (n = 0; n < len_a; n++) if (a[n] != b[n]) {
Serial << "a[" << n << "]:"<<a[n]<<" ";
Serial << "b[" << n << "]:"<<b[n]<<endl;
}
}

5shekel
12-19-2015, 11:07 AM
note: after uploading this poisonous HEX my linux/arch machine was also not happy with the teenise.
note1: that printEx.h lib is bad (on 1.6.6?), don't use.

dxinteractive
02-01-2016, 01:12 PM
I've found on one particular project was able to make this occur by accidentally Serial.println()ing before Serial.begin() was called. Not reproducible from scratch, but I might have a go trimming down the project I have until it breaks if I find the time.