The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ninjarider on February 28, 2012, 04:37:25 PM

Title: serial port createfile issue
Post by: ninjarider on February 28, 2012, 04:37:25 PM
trying to open a usb with createfile

    invoke CreateFile, addr mGetDevice3Text,GENERIC_READ OR GENERIC_WRITE,0,0,OPEN_EXISTING,0,0

i've tried just about any combination of //./com1, com1, com0, com9

im about to throw my laptop out the window cause i've tried using other code i've found on the board related to this. and it still doesn't want to work.

maybe im mistaken in that comxx's dont work with usb but i thought they were one in the same. is this a possible issue with windows 7.
Title: Re: serial port createfile issue
Post by: clive on February 28, 2012, 05:35:42 PM
No, serial ports work just fine in Windows 7, perhaps your slashes are backward

  if (Port > 9)
    sprintf(Serial->ComPort,"\\\\.\\COM%d",Port); // Required for COM10 and above
  else
    sprintf(Serial->ComPort,"COM%d",Port); // Win9x compatible

Serial->hFile = CreateFile(
    Serial->ComPort, // pointer to name of the file
    GENERIC_READ|GENERIC_WRITE,   // access (read-write) mode
    0,               // share mode
    NULL,               // pointer to security descriptor
    OPEN_EXISTING,         // how to create
    FILE_ATTRIBUTE_NORMAL,     // file attributes
NULL);                        // handle to file with attributes to copy
Title: Re: serial port createfile issue
Post by: Gunner on February 28, 2012, 06:52:00 PM
Put usb in, explorer asigns it a drive letter...  Access it like any other drive or folder
Title: Re: serial port createfile issue
Post by: farrier on February 28, 2012, 08:34:01 PM
Describe your USB hardware for us.

When you first install it, you should be prompted for the device driver software.  After the device driver software is installed, you should be able to view the COM port in the Device Manager, ports view.  Right clicking on the COM port assigned by Windows and choosing Properties, you are able to specify the COM1 - COM?? you prefer; as long as it doesn't conflict with an existing port assignment.

It should be accessed just like a regular COM port,  you should show the complete code segment including the "addr mGetDevice3Text"

Using CreateFile to access COM ports works fine from Win95 -> Win7 with regular hardware and USB dongles.

hth,

farrier
Title: Re: serial port createfile issue
Post by: ninjarider on March 01, 2012, 10:05:42 PM
well i was trying to use a droid2 to see if i could use the createfile function to get a direct link. i can open by specifing the f:\ windows assigns it as a drive. i havn't got the actual device that i will be working with which will use a com port to a usb adapter. its an automotive ecm that i will be trying to interface with.