News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

serial port createfile issue

Started by ninjarider, February 28, 2012, 04:37:25 PM

Previous topic - Next topic

ninjarider

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.

clive

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
It could be a random act of randomness. Those happen a lot as well.

Gunner

Put usb in, explorer asigns it a drive letter...  Access it like any other drive or folder
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

farrier

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
It is a GOOD day to code!
Some assembly required!
ASM me!
With every mistake, we must surely be learning. (George...Bush)

ninjarider

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.