Author Topic: [FIXED!] Weird Serial/WiFi issues  (Read 47132 times)

digistump

  • Administrator
  • Hero Member
  • *****
  • Posts: 1465
Re: Weird Serial/WiFi issues
« Reply #15 on: January 20, 2014, 11:25:06 pm »
I haven't tried 1.5.5-R2 yet - gogol are you using 1.5.5 or 1.5.5-R2?

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #16 on: January 21, 2014, 12:51:33 am »
@digistump: I have on one box a 1.5.5R2 and verified the md5-checksum:  Its just the same!

@Kaeltis:
  • What does listcomports.exe respons, if you disconnect the DigiX?
  • Can you disconnect more COM-Ports?, What is the result than?

The usual way, searching the internet for "windows" "80010005" and perhaps "VBS"
leads to many type mismatch-errors.

I expect, that you have an device, where an NULL error is returned instead of some information, listcomports expects.


I really hate the way Arduino has implemented the solution with the two different VID/PID entries, depending in which state the DUE/DigiX is.

When a program is running, the DigiX has "2341:003E" and an associated COM-Port, e.g. COM10.  When you now try to upload a new sketch, the only thing COM10 is used, is to trigger an erase followed by an reset, so that the CPU is starting in SAM-BA mode. In that case the VID/PID pair is: 03EB:6124, where Atmel is the owner of 03EB.  For example on two of my boxes the DigiX is recognized as LEGO NXT brick in firmware update mode, because i have installed the LEGO-driver there.

As Windows reserves for each device an unique device name, 03EB:6124 will be recognized as e.g. COM14.  That will change, when it is connected next time to another USB port!
So Arduino searches with listcomports.exe the devices, and takes the first one, it finds which has the VID/PID 03EB:6124.

Awful.  When I tried to compare some issues between real DUE and  two DigiX, my sketch went several times to the wrong device, when I have not disconnected the others before :-(

So I really like, what I am seeing in JTAG possibilities: http://digistump.com/board/index.php/topic,1275.0.html

Here each device is tied to one serial port, which will even not go away, when the DigiX reboots!  So it is very stable to the programming host!
Furthermore you need no fancy USB-serial port checking in the firmware, as the Original DUE firmware does every loop.  You are able to reprogram a running device without any problem.
When you wish to use the USB port for your own programs, the port is 100% yours, you have not to take care, what to core firmware does.

Maybe the one or other will join, working on that way.


« Last Edit: January 21, 2014, 01:11:36 am by gogol »

Kaeltis

  • Newbie
  • *
  • Posts: 27
Re: Weird Serial/WiFi issues
« Reply #17 on: January 21, 2014, 05:04:13 am »
I deleted all COM ports from the device manager but it's still crashing  ???



I also tried disconnecting all USB devices with the same result.
« Last Edit: January 21, 2014, 05:14:22 am by Kaeltis »

balin

  • Newbie
  • *
  • Posts: 11
Re: Weird Serial/WiFi issues
« Reply #18 on: January 21, 2014, 02:33:38 pm »
I have the same problem like Kaeltis. I also get the same error msg in listcomports.exe

Im using arduino 1.5.5 and your addon file 0.7

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #19 on: January 22, 2014, 12:02:43 am »
@balin:
That is just a problem with listcomports.exe and your specific hardware/software situation.  The digistump addons don't play any role at this time.
I expect, that

@Kaeltis:  I don't see a recent change in the github repository!  So it looks like, that someone@arduino fixed something, but has not put it back to that repo.
If you have a chance to see the change, which was made for  1.5.4r2, you might see similar code situations, which need also an fix!



Kaeltis

  • Newbie
  • *
  • Posts: 27
Re: Weird Serial/WiFi issues
« Reply #20 on: January 22, 2014, 03:08:03 am »

balin

  • Newbie
  • *
  • Posts: 11
Re: Weird Serial/WiFi issues
« Reply #21 on: January 22, 2014, 03:45:56 am »
Well, its not just listcomport... i cant get the digix to answer me on the serial usb port. I uploaded a sketch and get no answer on the com port.

When i try the serial0 port i get a answer but i tried the serverexample and after i send a key its just says Starting and nothing happens.

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #22 on: January 22, 2014, 04:41:14 am »
This is the change that should have fixed this:
https://github.com/todbot/usbSearch/commit/d78dc8150a8ad15c0a59e6b4610385c86618bbf7

Thanks!  I have overseen, that this is so old!  However, that shows, that really NULL was causing that issue.

What happens, when you enter  "mode" on the command line?
With DigiX plugged in and with Digix not connected?

Looking to the code

Code: [Select]
        dhGetValue(L"%s", &name, objDevice, L".Name");
        dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");
                                               
        if(verbose>1) printf("'%s'.\n", name);
        if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
            // 'Manufacturuer' can be null, so only get it if we need it
            dhGetValue(L"%s", &manu, objDevice, L".Manufacturer");
            port_count++;
            char* comname = strtok( match, "()");
            printf("%s - %s - %s\n",comname, manu, pnpid);
            dhFreeString(manu);
        }
       
        dhFreeString(name);
        dhFreeString(pnpid);

I would write it as:

Code: [Select]
       
        dhGetValue(L"%s", &name, objDevice, L".Name");
                                               
        if(verbose>1) printf("'%s'.\n", name);
        if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
            // 'Manufacturuer' can be null, so only get it if we need it
            dhGetValue(L"%s", &manu, objDevice, L".Manufacturer");
            dhGetValue(L"%s", &pnpid, objDevice, L".PnPDeviceID");
            port_count++;
            char* comname = strtok( match, "()");
            printf("%s - %s - %s\n",comname, manu, pnpid);
            dhFreeString(manu);
            dhFreeString(pnpid);
        }
        dhFreeString(name);   

it seems, that they decided, to query only the manufacturer, when the devicename matches "COM"-ports.  By reading the comment, it looks like, that there are devices out, which may have no manufacturer entry.
So I think, that querying pnpid should go inside the conditional part as well, as its not needed outside. However, if that is the problem, I have no clue.

I just remembered a tool, I found longer time ago, which lists com-ports on several ways: http://www.naughter.com/enumser.html

what is that tool telling?

Kaeltis

  • Newbie
  • *
  • Posts: 27
Re: Weird Serial/WiFi issues
« Reply #23 on: January 22, 2014, 04:47:42 am »
I recompiled the code with your modification, but it still throws the same error.
I don't know much about C, but it only compiles if i remove "-std=c99" from the makefile (even the original code from github), so the code seems to violate some ISO standards.


mode - no DigiX:


mode - with DigiX:


EnumSer - no DigiX:
Quote
CreateFile method reports
COM1
QueryDosDevice method reports
COM1
GetDefaultCommConfig method reports
COM1
Device Manager (SetupAPI - GUID_DEVINTERFACE_COMPORT) reports
COM1 <Kommunikationsanschluss>
Device Manager (SetupAPI - Ports Device information set) reports
COM1 <Kommunikationsanschluss>
EnumPorts method reports
COM3
COM4
COM1
COM2
COM5
COM6
COM7
COM8
COM9
COM10
COM11
WMI method reports
COM1 <Kommunikationsanschluss (COM1)>
ComDB method reports
CEnumerateSerial::UsingComDB failed, Error:5
Registry method reports
COM1

EnumSer - with DigiX:
Quote
CreateFile method reports
COM1
COM4
QueryDosDevice method reports
COM1
COM4
GetDefaultCommConfig method reports
COM1
COM4
Device Manager (SetupAPI - GUID_DEVINTERFACE_COMPORT) reports
COM1 <Kommunikationsanschluss>
Device Manager (SetupAPI - Ports Device information set) reports
COM1 <Kommunikationsanschluss>
COM4 <Bossa Program Port>
EnumPorts method reports
COM3
COM4
COM1
COM2
COM5
COM6
COM7
COM8
COM9
COM10
COM11
WMI method reports
COM1 <Kommunikationsanschluss (COM1)>
COM4 <Bossa Program Port (COM4)>
ComDB method reports
CEnumerateSerial::UsingComDB failed, Error:5
Registry method reports
COM1
COM4
« Last Edit: January 22, 2014, 04:55:42 am by Kaeltis »

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #24 on: January 22, 2014, 07:14:07 am »
Almost clueless.

The only thing, I can imagine, is to reduce the printf statement like:
Code: [Select]
printf("%s \n",comname);and remove the two dhGetValue statements.

When the error still exists, it must be something in the disphelper-library.

On my systems, where the program works, the output of EnumSer is similar. Especially I receive the same error
UsingComDB failed, Error:5

Code: [Select]
CreateFile method reports
COM1
COM2
COM12
QueryDosDevice method reports
COM1
COM2
COM12
GetDefaultCommConfig method reports
COM1
COM2
COM12
Device Manager (SetupAPI - GUID_DEVINTERFACE_COMPORT) reports
COM1 <Kommunikationsanschluss>
COM2 <USB-SERIAL CH340>
Device Manager (SetupAPI - Ports Device information set) reports
COM1 <Kommunikationsanschluss>
COM2 <USB-SERIAL CH340>
COM12 <Bossa Program Port>
EnumPorts method reports
COM1
COM2
COM4
COM5
COM6
COM7
COM8
COM9
COM10
COM11
COM12
COM13
COM14
COM15
COM16
COM17
COM18
COM19
COM20
COM21
COM22
COM23
COM3
WMI method reports
COM1 <Kommunikationsanschluss (COM1)>
COM12 <Bossa Program Port (COM12)>
ComDB method reports
CEnumerateSerial::UsingComDB failed, Error:5
Registry method reports
COM1
COM2
COM12



Kaeltis

  • Newbie
  • *
  • Posts: 27
Re: Weird Serial/WiFi issues
« Reply #25 on: January 22, 2014, 07:38:03 am »
I started stripping parts from the code,

Code: [Select]
    FOR_EACH(objDevice, colDevices, NULL) {
       
        char* name = NULL;
        char* match;

        dhGetValue(L"%s", &name,  objDevice, L".Name");
         
/*  
        if( name != NULL && ((match = strstr( name, "(COM" )) != NULL) ) { // look for "(COM23)"
            port_count++;
            char* comname = strtok( match, "()");
printf("%s \n",comname);
        }
       
*/

        dhFreeString(name);
       
    } NEXT(objDevice);

This STILL throws that error, but only until i remove

Code: [Select]
dhGetValue(L"%s", &name,  objDevice, L".Name");
So it seems to be this line/method thats causing the problems.

Maybe we need to check "objDevice" before we hand it to that method, to make sure it can handle it, just checking for != NULL doesn't seem to work.
I guess objDevice has to be "instanceof" IDispatch but i really don't know enough about C xD (so this idea might be totally wrong)
« Last Edit: January 22, 2014, 07:51:51 am by Kaeltis »

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #26 on: January 22, 2014, 07:56:37 am »
OK, but without that line, you can't identify, what is an COM-Port.

Do you have Powershell installed on your system?

This script should do the same enumeration:

Code: [Select]
$colItems = get-wmiobject -class "Win32_PnPEntity" -namespace "root\CIMV2" -computername "."
foreach ($objItem in $colItems) {
  if ( $objItem.Name -like "*COM*" ) {
      write-host "Name: -" $objItem.Name "-"
      write-host "PNP Device ID: " $objItem.PNPDeviceID
      write-host
   }     
}

Kaeltis

  • Newbie
  • *
  • Posts: 27
Re: Weird Serial/WiFi issues
« Reply #27 on: January 22, 2014, 07:58:36 am »
Seems to work perfectly:



Posted an "official" issue, maybe someone there knows how to fix this.
https://github.com/arduino/Arduino/issues/1818

Edit: Oh great, the "listComPorts.exe" can't be the cause of my problem because it's disabled and just a leftover  :-\
« Last Edit: January 22, 2014, 08:22:36 am by Kaeltis »

gogol

  • Sr. Member
  • ****
  • Posts: 398
Re: Weird Serial/WiFi issues
« Reply #28 on: January 22, 2014, 08:31:15 am »
I have no further idea.

Edit: The interesting question is, if that problem is the same, causing your communication problem, or if there are two independent problems.

« Last Edit: January 22, 2014, 08:38:08 am by gogol »

balin

  • Newbie
  • *
  • Posts: 11
Re: Weird Serial/WiFi issues
« Reply #29 on: January 22, 2014, 09:05:25 am »
i cant get the serialusb(serial) working either. So i just use Serial0 for all of my tests and have no problem with it. Maybe you can use this one in the meantime as well for your testing.

And just make sure when you use the wifi module, that the wifi module has the same Baudrate set then you use in wifi.begin(115200); ! This was the fault, why i couldnt get the ServerExample running.