Mleaf / stm32flash

Automatically exported from code.google.com/p/stm32flash
0 stars 0 forks source link

On Windows version COMn > COM9 init does not work #41

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. try to use COM10 or bigger as serial port

What version of the product are you using? On what operating system?
* Win-XP32, Win7

Please provide any additional information below.
* I already fixed that bug and would provide the change - just tell me how to 
commit or patch that code snippet into serial_w32.c...

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
serial_t* serial_open(const char *device) 
{
    unsigned char i=0;
    COMMTIMEOUTS timeouts = {MAXDWORD, 0, 0, 0, 0};
    serial_t *h = calloc(sizeof(serial_t), 1);

    /* Fix the device name if required for COM10..99 */
    char tmp[11];
    if (strlen(device) > 4 && device[0] != '\\')
    {
        while(device[i] && i<=10)
        {
            tmp[i] = device[i];
            i++;
        }
        if (i<11)
            tmp[i] = 0x00;
        else
            tmp[10] = 0x00;

        sprintf(device, "\\\\.\\%s", tmp);
    }

    /* Create file handle for port */
    h->fd = CreateFile(device, GENERIC_READ | GENERIC_WRITE, 
            0, /* Exclusive access */
            NULL, /* No security */
            OPEN_EXISTING,
            0, //FILE_FLAG_OVERLAPPED,
            NULL);

    if(h->fd == INVALID_HANDLE_VALUE)
    {
        fprintf(stderr, "Could not open Comport: %s", device);
        return NULL;
    }

    SetupComm(h->fd, 4096, 4096); /* Set input and output buffer size */

    SetCommTimeouts(h->fd, &timeouts);

    SetCommMask(h->fd, EV_ERR); /* Notify us of error events */

    GetCommState(h->fd, &h->oldtio); /* Retrieve port parameters */
    GetCommState(h->fd, &h->newtio); /* Retrieve port parameters */

    return h;
}

Original issue reported on code.google.com by Tomas.Ku...@gmail.com on 15 Aug 2013 at 5:38

GoogleCodeExporter commented 9 years ago
Please make a git patch:

git clone git://gitorious.org/stm32flash/stm32flash.git
cd stm32flash
git checkout merging

# Now do your changes or copy in your edited file.
# Use "git diff" to see your changes and verify you don't change
# something else by accident.
# When you are done with your change

git commit -a

# Here enter a summary on the top line, then an empty line, then more comments.
# If you do several independent changes (e.g. fixing two different bugs) do
# a commit for each of them.

# To fix up a commit (also the patch commit message, use git commit -a --amend

git format-patch -o .. HEAD^

... this generates a patch file from your commit. Edit name/address if needed, 
review code changes and comments and attach it here when it looks good.

Thanks!

Original comment by lists.to...@gmail.com on 15 Aug 2013 at 1:21

GoogleCodeExporter commented 9 years ago
Tomas, what does your patch exactly do, expressed in words?

Original comment by lists.to...@gmail.com on 15 Sep 2013 at 9:58

GoogleCodeExporter commented 9 years ago
The serial interface Windows-API uses another format for COM10..99 compared to 
COM1 to COM9. 
This was not handled ok in the code, probably never tested with > COM9...
I fixed this and it works now. It was tested with win-xp32, win7-32/64 using 
TDM-GCC 32-bit toolchain executable.

Have fun, Tom.

Original comment by Tomas.Ku...@gmail.com on 16 Sep 2013 at 10:35

GoogleCodeExporter commented 9 years ago
It seems like this issue was already reported and fixed here: 
http://code.google.com/p/stm32flash/issues/detail?id=5

Original comment by lists.to...@gmail.com on 19 Sep 2013 at 8:27

GoogleCodeExporter commented 9 years ago

Original comment by lists.to...@gmail.com on 8 Dec 2013 at 11:50