The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Roger on April 09, 2006, 09:10:29 PM

Title: Help on Serial I/O
Post by: Roger on April 09, 2006, 09:10:29 PM
Hello All,

All the APIs that I want to use for serial comms need a handle obtained from CreateFile. In Win95/98 CreateFiles only seems to apply to files so what do I use to get a handle.

I quote the platform SDK:-

CreateFile

The CreateFile function creates or opens a file, file stream, directory, physical disk, volume, console buffer, tape drive, communications resource, mailslot, or named pipe. The function returns a handle that can be used to access an object.

Windows Me/98/95:   The file system restricts CreateFile to creating or opening files. You cannot create or open the objects that are identified in the first paragraph of this topic.

Regards Roger


Title: Re: Help on Serial I/O
Post by: anon on April 09, 2006, 09:51:31 PM
CreateFile works for serial communications on Win95,98/Me. I have done it in the past.
I have an older PSDK (Feb 2001) and it does not list any restrictions for communication
devices on those Windows versions.
Title: Re: Help on Serial I/O
Post by: MichaelW on April 09, 2006, 09:53:49 PM
My February 2003 version of the PSDK list various restrictions for Windows 9x, but not for communication resources. This works OK under Windows 98SE:

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
   include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
   .data
     hCom dd 0
   .code
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
   invoke CreateFile, chr$("COM1"),
                      GENERIC_READ + GENERIC_WRITE,
                      0,
                      NULL,
                      OPEN_EXISTING,
                      0,
                      NULL
   mov   hCom, eax

   .IF eax == INVALID_HANDLE_VALUE
     print "CreateFile failed",13,10
   .ELSE
     print "OK",13,10
   .ENDIF

   invoke CloseHandle, hCom

   inkey "Press any key to exit..."
   exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
Title: Re: Help on Serial I/O
Post by: farrier on April 10, 2006, 02:22:30 PM
Roger,

Check the following site:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnfiles/html/msdn_serial.asp

I have apps that use the SDK services exclusively, and they all work on 95/98/me/2000/xp.

You can use CreateFile for COMx and LPTx to access those resources!

hth,

farrier
Title: Re: Help on Serial I/O
Post by: Roger on April 10, 2006, 07:32:15 PM
Thank you for your help.  I can now receive serial data - Next I must try transmiting it.

My SDK is from about 2005, perhaps by then Microsoft had become very pro-active in not suporting Win95

Regards Roger