Read from 15-pin port

This is a discussion on Read from 15-pin port within the C Programming forums, part of the General Programming Boards category; Have you tried getting info and/or drivers from IBM or Microsoft?...

  1. #16
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Have you tried getting info and/or drivers from IBM or Microsoft?

  2. #17
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    No, I have not.
    though the TESTCFG.SYS device driver can perform the function i want...however from the last thing I posted that guy suggested it was no good.



    though this page says it works
    http://notebook.arkane-systems.net/i...I/O_under_OS/2


    Code:
    // Include all needed includes for the .DLL definitions
    
    #define INCL_DOS
    #include <os2.h>
    
    // TESTCFG driver command constants
    #define   CFG_CATEGORY        0x80
    
    #define   CFG_IN_IO           0x41
    #define   CFG_OUT_IO          0x42
    
    #define   CFG_IO_BYTE         1
    #define   CFG_IO_WORD         2
    #define   CFG_IO_DWORD        4
    
    // TESTCFG driver structures
    // IO packet structures
    typedef struct _IOPKT {
         USHORT         io_address ;
         USHORT         data_width ;
         union {
              UCHAR     ucData ;
              USHORT    usData ;
              ULONG     ulData ;
              } d ;
         } IOPKT ;
    
    typedef IOPKT * PIOPKT ;
    
    typedef struct _IODATAPKT {
         union {
              UCHAR     ucData ;
              USHORT    usData ;
              ULONG     ulData ;
              } d ;
         } IODATAPKT ;
    
    typedef IODATAPKT * PIODATAPKT ;
    
    // exported functions
    // open_ports - prepare the system I/O ports to be read/written
    
    HFILE _Export open_ports (void)
    {
       HFILE  hfDevice ;
       ULONG  action ;
    
       DosOpen ("TESTCFG$", &hfDevice, &action, 0, 0, FILE_OPEN, OPEN_ACCESS_READWRITE |
                OPEN_SHARE_DENYNONE, NULL) ;
       return hfDevice ;
    }
    
    // close_ports - close the I/O port device driver
    APIRET _Export close_ports (HFILE hfDevice)
    {
       return DosClose (hfDevice) ;
    }
    
    // port i/o input functions
    
    APIRET            _Export input_byte (HFILE hfDevice, USHORT port, PBYTE pb)
    {
       APIRET      rc ;
       ULONG       cbparm, cbdata ;
       IOPKT       iopkt ;
       IODATAPKT   iodatapkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_BYTE ;
       cbparm = sizeof (iopkt) ;
       cbdata = sizeof (iodatapkt) ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_IN_IO, &iopkt, sizeof (iopkt), &cbparm,
                         &iodatapkt, sizeof (iodatapkt), &cbdata) ;
       *pb = iodatapkt.d.ucData ;
       return rc ;
    }
    
    APIRET            _Export input_word (HFILE hfDevice, USHORT port, PUSHORT pw)
    {
       APIRET      rc ;
       ULONG       cbparm, cbdata ;
       IOPKT       iopkt ;
       IODATAPKT   iodatapkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_WORD ;
       cbparm = sizeof (iopkt) ;
       cbdata = sizeof (iodatapkt) ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_IN_IO, &iopkt, sizeof (iopkt), &cbparm,
                         &iodatapkt, sizeof (iodatapkt), &cbdata) ;
       *pw = iodatapkt.d.usData ;
       return rc ;
    }
    
    APIRET            _Export input_dword (HFILE hfDevice, USHORT port, PULONG pd)
    {
       APIRET      rc ;
       ULONG       cbparm, cbdata ;
       IOPKT       iopkt ;
       IODATAPKT   iodatapkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_DWORD ;
       cbparm = sizeof (iopkt) ;
       cbdata = sizeof (iodatapkt) ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_IN_IO, &iopkt, sizeof (iopkt), &cbparm,
                         &iodatapkt, sizeof (iodatapkt), &cbdata) ;
       *pd = iodatapkt.d.ulData ;
       return rc ;
    }
    
    // port i/o output functions
    APIRET            _Export output_byte (HFILE hfDevice, USHORT port, BYTE b)
    {
       APIRET rc ;
       ULONG  cbparm, cbdata ;
       IOPKT  iopkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_BYTE ;
       iopkt.d.ucData = b ;
       cbparm = sizeof (iopkt) ;
       cbdata = 0 ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_OUT_IO, &iopkt, sizeof (iopkt), &cbparm, NULL,
                         0, &cbdata) ;
       return rc ;
    }
    
    APIRET            _Export output_word (HFILE hfDevice, USHORT port, USHORT w)
    {
       APIRET rc ;
       ULONG  cbparm, cbdata ;
       IOPKT  iopkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_WORD ;
       iopkt.d.usData = w ;
       cbparm = sizeof (iopkt) ;
       cbdata = 0 ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_OUT_IO, &iopkt, sizeof (iopkt), &cbparm, NULL,
                         0, &cbdata) ;
       return rc ;
    }
    
    APIRET            _Export output_dword (HFILE hfDevice, USHORT port, ULONG d)
    {
       APIRET rc ;
       ULONG  cbparm, cbdata ;
       IOPKT  iopkt ;
    
       iopkt.io_address = port ;
       iopkt.data_width = CFG_IO_DWORD ;
       iopkt.d.ulData = d ;
       cbparm = sizeof (iopkt) ;
       cbdata = 0 ;
       rc = DosDevIOCtl (hfDevice, CFG_CATEGORY, CFG_OUT_IO, &iopkt, sizeof (iopkt), &cbparm, NULL,
                         0, &cbdata) ;
       return rc ;
    }


    I have no idea how I would incorporate that code and the code for my timer .
    Last edited by Euphorica; 07-07-2008 at 12:23 PM.

  3. #18
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    Here is what the connector looks like
    http://img77.imageshack.us/img77/3281/wiringwd2.jpg

    Its hard to read but it reads from top to bottom:

    Not used
    Not used
    Not used
    AENOUT-
    AENOUT+
    CONTACTOR+
    CONTACTOR-
    INTERLOCK+
    INTERLOCK-
    TERMINATE+
    TERMINATE-
    AENRIN-
    AENRIN+
    DATA/CLK-
    DATA/CLK+

  4. #19
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    more info on reading i/o info

    http://www.edm2.com/0501/devicedrivers5.html

  5. #20
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    Looks like a standard "D" 15 pin serial port.

    The important thing to me is that the port is being handled currently (successfully), by OS2, and OS2 was a joint effort by IBM and Microsoft, which MS eventually separated themselves from.

    Why not go straight to the "horse's mouth", and contact IBM? They obviously would know how to do this in OS2, since OS2 is their baby.

  6. #21
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    So... test the code you got from wiki!
    You will use it like this, if that is what your asking:
    Code:
    HFILE portHandler;
    USHORT port;
    BYTE data;
    
    portHandler = open_ports();   //initialize, open port, run this before the machine runs (or not)
    output_byte (PortHandler, port, data);  //you get a BYTE from the port
    input_byte (PortHandler, port, data);  //you send a BYTE from the port
    close_port (portHandler); //you close the port, when you are done
    I m just guessing here. But usually you use them like that. So you will read the data from the machine with output_data and ...well see what you are going to do.

    Test these functions the way I posted by sending/receiving bytes and you/we will see from there.

    But... you still need the port number or definition (like PARAPORT) for the port number... Search os2.h?

  7. #22
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    well its not IBMs baby anymore....they stopped supporting it a while ago.

    granted im sure someone there knows what to do, it seems I have found all the relevent information ill need to do this. The problem is sorting through it all, coming up with the right code and getting it to work with my little program. As I keep saying im a newb so this is a slow process, and I appreciate the help so far from everyone.

  8. #23
    Registered User
    Join Date
    Jun 2008
    Posts
    20
    Ok so I found out some ways to look at some system info....and i also got an email letting me know that the card has to be used with IRQ5.

    I look up various info and nothing is listed for irq 5...hrmmm its like its hidden.

    i might try a port sniffer next. but thats a pain due to security reasons.

    :/

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    "Port sniffer" is something for sniffing ethernet packages.

    You need the specifications of that board to be able to find out what IO port to use. Is it a PCI board or a ISA board?

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C# output based on data read by serial port.
    By james557 in forum C# Programming
    Replies: 5
    Last Post: 12-28-2008, 06:32 AM
  2. how to read data from 15 pin connection?
    By Euphorica in forum Networking/Device Communication
    Replies: 0
    Last Post: 06-27-2008, 03:38 PM
  3. serial port - read chars twice
    By matze in forum Linux Programming
    Replies: 1
    Last Post: 12-07-2007, 06:32 AM
  4. brace-enclosed error
    By jdc18 in forum C++ Programming
    Replies: 53
    Last Post: 05-03-2007, 05:49 PM
  5. how to make parallel port read data
    By lwong in forum Windows Programming
    Replies: 0
    Last Post: 01-05-2004, 07:14 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21