NO

Author Topic: InpOut32 for PellesC  (Read 36068 times)

tiwag

  • Guest
Re: Serial interface
« Reply #15 on: April 29, 2005, 08:40:36 PM »
Quote from: "sven"

of course, typical beginner's mistake...


we all started this way,
what's a compiler ? linker ? preprocessor ? 150+ unknown important things....
don't worry, take it easy, continue learning


Quote from: "sven"

Now my next step in this daVinci puzzle is to find out how to handle the CommMask. Where can I find info about that ?


start here:
http://msdn.microsoft.com/library/default.asp
and use the search field   8)

or

download & install the Win32 SDK
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/psdk-full.htm

good start !

-tiwag

JohnF

  • Guest
InpOut32 for PellesC
« Reply #16 on: April 30, 2005, 10:02:34 AM »
Tried various COM listings to read from the port - nuffing!

Well, not quite, on my old PC there is COM1 & COM2, COM2 works but not COM1. On my new PC there is only COM1 which does not show any chars read form the port.

Any information about why this is ?

John

Anonymous

  • Guest
InpOut32 for PellesC
« Reply #17 on: April 30, 2005, 11:54:54 AM »
Quote from: "JohnF"
Tried various COM listings to read from the port - nuffing!

Well, not quite, on my old PC there is COM1 & COM2, COM2 works but not COM1. On my new PC there is only COM1 which does not show any chars read form the port.

Any information about why this is ?

John


Which version of windows are you on John?  

Win 32 versions, especially NT and it's descendents (2000, XP, 2003, Win64...) actively block direct access to IO devices, requiring you to go through the OS drivers instead.

Check the Platform SDK for CreateFile, SetCommState and DeviceIOControl functions.  I think you'll find that it's actually a rather simple matter to treat a serial IO port as though it were a file.  You can open the Serial port with a CreateFile call, and send and receive in the same manner as reading or writing a disk file using ReadFile and WriteFile.   Settings and initialization is handled by SetCommState.  I used to do this with receipt printers all the time.

Here's the general info from MSDN...
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/devio/base/communications_resources.asp

You'll likely find it a lot easer than trying to do an end run around Windows.

tiwag

  • Guest
InpOut32 for PellesC
« Reply #18 on: April 30, 2005, 12:01:06 PM »
Quote from: "JohnF"
Tried various COM listings to read from the port - nuffing!

Well, not quite, on my old PC there is COM1 & COM2, COM2 works but not COM1. On my new PC there is only COM1 which does not show any chars read form the port.

Any information about why this is ?

John


Hi John

from my experience, this is what i can say :
InpOut32 is working absolutely reliable for acces of all kind of IO mapped registers.
i used it for parallel port reading / writing
and for some self designed hardware projects.

i did not and will not do any serial port stuff with it,
i won't write an interrupt handler for the serial port for win32,
cause this is already done by M$ and known as working...
see CreateFile("COM1", ...) stuff

what exactly is your need ?
if you want to set the level of handshake lines of the RS232,
it can easily be done with win32 API

if you remember, i have sent you a few (i guess 2) years ago an M$ sample
called mttty (multy threaded tty) which i ported to lccwin32
and improoved a little bit.

There you can look how to access all kinds of serial IO stuff.

best regards,
tiwag

JohnF

  • Guest
InpOut32 for PellesC
« Reply #19 on: April 30, 2005, 12:35:07 PM »
Quote from: "ldblake"

Which version of windows are you on John?  


WinXP

Quote

Win 32 versions, especially NT and it's descendents (2000, XP, 2003, Win64...) actively block direct access to IO devices, requiring you to go through the OS drivers instead.


Although COM2 works on my old machine. (WinXP)

Quote

Check the Platform SDK for CreateFile, SetCommState and DeviceIOControl functions.  I think you'll find that it's actually a rather simple matter to treat a serial IO port as though it were a file.  You can open the Serial port with a CreateFile call, and send and receive in the same manner as reading or writing a disk file using ReadFile and WriteFile.   Settings and initialization is handled by SetCommState.  I used to do this with receipt printers all the time.


Yes am using CreateFile, etc.

John

JohnF

  • Guest
InpOut32 for PellesC
« Reply #20 on: April 30, 2005, 12:41:35 PM »
Quote from: "tiwag"

if you remember, i have sent you a few (i guess 2) years ago an M$ sample called mttty (multy threaded tty) which i ported to lccwin32
and improoved a little bit.

There you can look how to access all kinds of serial IO stuff.

best regards,
tiwag


I will find it and take a look, will let you know...

Some time later - that mttty works on COM2 but will not work on COM1 on my old machine. This is the same result as using other listings. If no doubt it will behave like that on my new machine. (COM1)

John

tiwag

  • Guest
InpOut32 for PellesC
« Reply #21 on: April 30, 2005, 02:11:34 PM »
Quote from: "JohnF"

...Some time later - that mttty works on COM2 but will not work on COM1 on my old machine. This is the same result as using other listings. If no doubt it will behave like that on my new machine. (COM1)

John


one com port works - the other not ??!? mysterious !!??!
i don't know how i can help you further
-tiwag

JohnF

  • Guest
InpOut32 for PellesC
« Reply #22 on: April 30, 2005, 02:13:05 PM »
Quote from: "tiwag"
Quote from: "JohnF"

...Some time later - that mttty works on COM2 but will not work on COM1 on my old machine. This is the same result as using other listings. If no doubt it will behave like that on my new machine. (COM1)

John


one com port works - the other not ??!? mysterious !!??!
i don't know how i can help you further
-tiwag


Ok, thanks anyway.

John

Anonymous

  • Guest
InpOut32 for PellesC
« Reply #23 on: April 30, 2005, 05:32:15 PM »
Quote from: "JohnF"

Although COM2 works on my old machine. (WinXP)


From what you say I'd bet it's hardware not sofware that's messing you up...

1) Are you shure your new machine has 2 ports?

2) Is it configured as a serial port in the bios? (some set COM2 for Infrared by default)

3) Check in hardware manager... is it set up correctly?

4) Have you tried hardware diagnostics with a loopback plug?

JohnF

  • Guest
InpOut32 for PellesC
« Reply #24 on: April 30, 2005, 08:43:38 PM »
Quote from: "ldblake"
Quote from: "JohnF"

Although COM2 works on my old machine. (WinXP)


From what you say I'd bet it's hardware not sofware that's messing you up...

1) Are you shure your new machine has 2 ports?

2) Is it configured as a serial port in the bios? (some set COM2 for Infrared by default)

3) Check in hardware manager... is it set up correctly?

4) Have you tried hardware diagnostics with a loopback plug?


I don't have a loopback plug but Device Manager says the port is working properly.

John

Anonymous

  • Guest
InpOut32 for PellesC
« Reply #25 on: May 01, 2005, 01:46:43 AM »
Quote from: "JohnF"
I don't have a loopback plug but Device Manager says the port is working properly.


 :(  And it always tells me my camera dock is working correctly too... except that I don't have a dockable camera...

Check your bios settings (hit DEL during boot up...) it is quite likely it's working properly, but not as expcected...  It could be configured as an IR (InfraRed) device port instead of as a standard serial port, or it could simply be disabled. In that case the back panel connector will be dead as a door nail.  Some BIOS's do this by default, and it annoys me to no end  :wink:

Loopback is  very easy, all you need is the correct plug and a little bit of solder.  You can also purchase them pre-wired, but at about 5x the price of making one yourself.  The specs (and a wealth of other stuff) is here...  http://www.beyondlogic.org/serial/serial.htm#2

JohnF

  • Guest
InpOut32 for PellesC
« Reply #26 on: May 01, 2005, 07:34:32 AM »
Quote from: "ldblake"
Quote from: "JohnF"
I don't have a loopback plug but Device Manager says the port is working properly.


 :(  And it always tells me my camera dock is working correctly too... except that I don't have a dockable camera...

Check your bios settings (hit DEL during boot up...) it is quite likely it's working properly, but not as expcected...  It could be configured as an IR (InfraRed) device port instead of as a standard serial port, or it could simply be disabled. In that case the back panel connector will be dead as a door nail.  Some BIOS's do this by default, and it annoys me to no end  :wink:


Ok checked that, the bios had the serial port just as AUTO so I made it COM1, still no go though.

EDIT: Addition info. I have a DELL with it's own diagnostic partition which one can boot - it says that the serial port 1 passed all tests.

John

Anonymous

  • Guest
InpOut32 for PellesC
« Reply #27 on: May 01, 2005, 10:16:50 AM »
Quote from: "JohnF"
Ok checked that, the bios had the serial port just as AUTO so I made it COM1, still no go though.

EDIT: Addition info. I have a DELL with it's own diagnostic partition which one can boot - it says that the serial port 1 passed all tests.


Ok, now that you've changed the BIOS settings, you'll most likely have to go through the Device Manager settings again and reconfigure it there.

BTW... If you enabled the IRQs in the bios, please be aware that they are bassackwards... Com1 is irq4, Com2 is irq3.

Take a look inside the case of your computer.  See what CPU board is in there (Odds are it's MSI but not always).  You can always try replacing the drivers with the ones from the CPU board manufacturer.  (They're usually a lot less buggy than the Dell ones.)

FWIW... I have a couple of friends who bought Dell... took them a while to get everything working right.  Dell has a production version of XP that's installed by an unattended script.  It's not the same as the version on the CD you got... and since it is licenced in a certain state,  it's not likely to have the most up to date drivers.

JohnF

  • Guest
InpOut32 for PellesC
« Reply #28 on: May 01, 2005, 10:39:27 AM »
Quote from: "ldblake"

Ok, now that you've changed the BIOS settings, you'll most likely have to go through the Device Manager settings again and reconfigure it there.

BTW... If you enabled the IRQs in the bios, please be aware that they are bassackwards... Com1 is irq4, Com2 is irq3.

Take a look inside the case of your computer.  See what CPU board is in there (Odds are it's MSI but not always).  You can always try replacing the drivers with the ones from the CPU board manufacturer.  (They're usually a lot less buggy than the Dell ones.)

FWIW... I have a couple of friends who bought Dell... took them a while to get everything working right.  Dell has a production version of XP that's installed by an unattended script.  It's not the same as the version on the CD you got... and since it is licenced in a certain state,  it's not likely to have the most up to date drivers.


I have reinstalled it, XP that is.

The IRQ is set as 4. The best thing is to find another driver, thanks for your input.

John

tiwag

  • Guest
InpOut32 for PellesC
« Reply #29 on: May 01, 2005, 11:31:09 AM »
Quote from: "JohnF"

... The best thing is to find another driver, thanks for your input...


if they are from M$, named
serenum.sys and
serial.sys
and have a description which correlates to the installed XP Sservice pack
(here i have XP SP2 and the drivers are of version (xpsp_sp2_rtm.040803-2158))
then let them as they are!


2nd)
have you tried to disable the FIFO settings in "advanced port setting" ?
just slide completely to the left or uncheck the option, if there is a checkbox.

-tiwag