parallel port programming simple problem

Discussion in 'C Programming' started by Marco, Jul 10, 2006.

  1. Marco

    Marco Guest

    Could anyone please tell me why the program has the following error? I
    copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm


    /////////////////////////////////////////////////////////////////////
    #include <dos.h>
    #include <string.h>
    #include <stdio.h>

    #define PORTADDRESS 0x378 /* Enter Your Port Address Here */

    #define DATA PORTADDRESS+0
    #define STATUS PORTADDRESS+1
    #define CONTROL PORTADDRESS+2

    void main(void)
    {
    char string[] = {"Testing 1,2,3 "
    "It' Works ! "};
    char init[10];
    int count;
    int len;
    init[0] = 0x0F; /* Init Display */
    init[1] = 0x01; /* Clear Display */
    init[2] = 0x38; /* Dual Line / 8 Bits */

    outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    Make sure Forward Direction */

    outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    (Register Select) */

    for (count = 0; count <= 2; count++)
    {
    outportb(DATA, init[count]);
    outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    delay(20); /* Larger Delay for INIT
    */
    outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    (Enable)*/
    delay(20); /* Larger Delay for INIT
    */
    }

    outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    (Register Select) */

    len = strlen(string);

    for (count = 0; count < len; count++)
    {
    outportb(DATA, string[count]);
    outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    delay(2);
    outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    delay(2);
    }
    }
    ////////////////////////////////////////////////////////////////////////////////


    --------------------Configuration: Text1 - Win32
    Debug--------------------
    Compiling...
    Text1.c
    C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    'outportb' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    'inportb' : undeclared identifier
    C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    'delay' : undeclared identifier
     
    Marco, Jul 10, 2006
    #1
    1. Advertising

  2. On 2006-07-10, Marco <> wrote:
    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    >
    >
    > /////////////////////////////////////////////////////////////////////
    > #include <dos.h>
    > #include <string.h>
    > #include <stdio.h>
    >
    > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    >
    > #define DATA PORTADDRESS+0
    > #define STATUS PORTADDRESS+1
    > #define CONTROL PORTADDRESS+2
    >
    > void main(void)
    > {
    > char string[] = {"Testing 1,2,3 "
    > "It' Works ! "};
    > char init[10];
    > int count;
    > int len;
    > init[0] = 0x0F; /* Init Display */
    > init[1] = 0x01; /* Clear Display */
    > init[2] = 0x38; /* Dual Line / 8 Bits */
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > Make sure Forward Direction */
    >
    > outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    > (Register Select) */
    >
    > for (count = 0; count <= 2; count++)
    > {
    > outportb(DATA, init[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    > (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > }
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    > (Register Select) */
    >
    > len = strlen(string);
    >
    > for (count = 0; count < len; count++)
    > {
    > outportb(DATA, string[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    > delay(2);
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    > delay(2);
    > }
    > }
    > ////////////////////////////////////////////////////////////////////////////////
    >
    >
    > --------------------Configuration: Text1 - Win32
    > Debug--------------------
    > Compiling...
    > Text1.c
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'outportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'inportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > 'delay' : undeclared identifier
    >


    It looks suspiciously like you tried to use functions that you haven't
    declared or defined.

    --
    Andrew Poelstra <http://www.wpsoftware.net/projects/>
    To email me, use "apoelstra" at the above domain.
    "You people hate mathematics." -- James Harris
     
    Andrew Poelstra, Jul 10, 2006
    #2
    1. Advertising

  3. Marco

    Marco Guest

    > > --------------------Configuration: Text1 - Win32
    > > Debug--------------------
    > > Compiling...
    > > Text1.c
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > > 'outportb' : undeclared identifier
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > > 'inportb' : undeclared identifier
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > > 'delay' : undeclared identifier
    > >

    >
    > It looks suspiciously like you tried to use functions that you haven't
    > declared or defined.
    >
    > --
    > Andrew Poelstra <http://www.wpsoftware.net/projects/>
    > To email me, use "apoelstra" at the above domain.
    > "You people hate mathematics." -- James Harris



    I want to know whether outportb, delay and inportb are function in
    general function in C? (I have no experience in C at all.) If they are
    general function in C, how I can define them?
    Thanks
     
    Marco, Jul 10, 2006
    #3
  4. In article <>,
    Marco <> wrote:
    >Could anyone please tell me why the program has the following error? I
    >copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm

    ....
    >
    >--------------------Configuration: Text1 - Win32
    >Debug--------------------
    >Compiling...
    >Text1.c
    >C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >'outportb' : undeclared identifier


    Read the sentence just after the program listing in the website
    you have cited.

    --
    Rouben Rostamian
     
    Rouben Rostamian, Jul 10, 2006
    #4
  5. Marco

    Marco Guest

    > Read the sentence just after the program listing in the website
    > you have cited.
    >
    > --
    > Rouben Rostamian


    I change the program to the following, but still have error
    Could you please tell me (A new C programmer) why that happen?
    thanks


    //////////////////////////////////////////////////
    #include <stdio.h>
    #include <dos.h>
    #include <string.h>

    #define PORTADDRESS 0x378 /* Enter Your Port Address Here */

    #define DATA PORTADDRESS+0
    #define STATUS PORTADDRESS+1
    #define CONTROL PORTADDRESS+2

    void main(void)
    {
    char string[] = {"Testing 1,2,3 "
    "It' Works ! "};
    char init[10];
    int count;
    int len;
    init[0] = 0x0F; /* Init Display */
    init[1] = 0x01; /* Clear Display */
    init[2] = 0x38; /* Dual Line / 8 Bits */

    outp(CONTROL, inp(CONTROL) & 0xDF); /* Reset Control Port - Make sure
    Forward Direction */

    outp(CONTROL, inp(CONTROL) | 0x08); /* Set Select Printer (Register
    Select) */

    for (count = 0; count <= 2; count++)
    {
    outp(DATA, init[count]);
    outp(CONTROL,inp(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    delay(20); /* Larger Delay for INIT
    */
    outp(CONTROL,inp(CONTROL) & 0xFE); /* Reset Strobe (Enable)*/
    delay(20); /* Larger Delay for INIT
    */
    }

    outp(CONTROL, inp(CONTROL) & 0xF7); /* Reset Select Printer (Register
    Select) */

    len = strlen(string);

    for (count = 0; count < len; count++)
    {
    outp(DATA, string[count]);
    outp(CONTROL,inp(CONTROL) | 0x01); /* Set Strobe */
    delay(2);
    outp(CONTROL,inp(CONTROL) & 0xFE); /* Reset Strobe */
    delay(2);
    }
    }
    /////////////////////////////////////////////////

    --------------------Configuration: Text1 - Win32
    Debug--------------------
    Compiling...
    Text1.c
    c:\program files\microsoft visual studio\text1.c(22) : warning C4013:
    'outp' undefined; assuming extern returning int
    c:\program files\microsoft visual studio\text1.c(22) : warning C4013:
    'inp' undefined; assuming extern returning int
    c:\program files\microsoft visual studio\text1.c(30) : warning C4013:
    'delay' undefined; assuming extern returning int

    Text1.obj - 0 error(s), 3 warning(s)
     
    Marco, Jul 10, 2006
    #5
  6. On 2006-07-10, Marco <> wrote:
    >> > --------------------Configuration: Text1 - Win32
    >> > Debug--------------------
    >> > Compiling...
    >> > Text1.c
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> > 'outportb' : undeclared identifier
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> > 'inportb' : undeclared identifier
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    >> > 'delay' : undeclared identifier
    >> >

    >>
    >> It looks suspiciously like you tried to use functions that you haven't
    >> declared or defined.
    >>

    >
    > I want to know whether outportb, delay and inportb are function in
    > general function in C? (I have no experience in C at all.) If they are
    > general function in C, how I can define them?
    > Thanks
    >


    They are not Standard functions. If they are library functions (which
    they appear to be), you must #include the appropriate header. Otherwise,
    you would declare and define them just as any other function.

    --
    Andrew Poelstra <http://www.wpsoftware.net/projects/>
    To email me, use "apoelstra" at the above domain.
    "You people hate mathematics." -- James Harris
     
    Andrew Poelstra, Jul 10, 2006
    #6
  7. On 2006-07-10, Marco <> wrote:
    >> Read the sentence just after the program listing in the website
    >> you have cited.
    >>
    >> --
    >> Rouben Rostamian

    >
    > I change the program to the following, but still have error
    > Could you please tell me (A new C programmer) why that happen?
    > thanks
    >
    > ...
    > void main(void)


    main returns int. Get that right before asking other questions.

    --
    Andrew Poelstra <http://www.wpsoftware.net/projects/>
    To email me, use "apoelstra" at the above domain.
    "You people hate mathematics." -- James Harris
     
    Andrew Poelstra, Jul 10, 2006
    #7
  8. In article <>,
    Marco <> wrote:
    >--------------------Configuration: Text1 - Win32
    >Debug--------------------
    >Compiling...
    >Text1.c
    >c:\program files\microsoft visual studio\text1.c(22) : warning C4013:
    >'outp' undefined; assuming extern returning int
    >c:\program files\microsoft visual studio\text1.c(22) : warning C4013:
    >'inp' undefined; assuming extern returning int
    >c:\program files\microsoft visual studio\text1.c(30) : warning C4013:
    >'delay' undefined; assuming extern returning int


    The functions outp and inp are not Standard C functions.
    You won't get further useful information in this newsgroup.
    Try asking in:

    comp.os.ms-windows.programmer.win32

    --
    Rouben Rostamian
     
    Rouben Rostamian, Jul 10, 2006
    #8
  9. "Marco" <> wrote in message
    news:...
    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm


    I'd suggest comp.os.msdos.programmer for this question.

    - Bill
     
    William J. Leary Jr., Jul 10, 2006
    #9
  10. Marco

    Guest

    Hi,Macro.
    How are you...
    Please mention on which operating system your compiling this programme.

    Marco wrote:
    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    >
    >
    > /////////////////////////////////////////////////////////////////////
    > #include <dos.h>
    > #include <string.h>
    > #include <stdio.h>
    >
    > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    >
    > #define DATA PORTADDRESS+0
    > #define STATUS PORTADDRESS+1
    > #define CONTROL PORTADDRESS+2
    >
    > void main(void)
    > {
    > char string[] = {"Testing 1,2,3 "
    > "It' Works ! "};
    > char init[10];
    > int count;
    > int len;
    > init[0] = 0x0F; /* Init Display */
    > init[1] = 0x01; /* Clear Display */
    > init[2] = 0x38; /* Dual Line / 8 Bits */
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > Make sure Forward Direction */
    >
    > outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    > (Register Select) */
    >
    > for (count = 0; count <= 2; count++)
    > {
    > outportb(DATA, init[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    > (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > }
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    > (Register Select) */
    >
    > len = strlen(string);
    >
    > for (count = 0; count < len; count++)
    > {
    > outportb(DATA, string[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    > delay(2);
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    > delay(2);
    > }
    > }
    > ////////////////////////////////////////////////////////////////////////////////
    >
    >
    > --------------------Configuration: Text1 - Win32
    > Debug--------------------
    > Compiling...
    > Text1.c
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'outportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'inportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > 'delay' : undeclared identifier
     
    , Jul 10, 2006
    #10
  11. Marco

    Marco Guest

    MS VC++





    寫é“:

    > Hi,Macro.
    > How are you...
    > Please mention on which operating system your compiling this programme.
    >
    > Marco wrote:
    > > Could anyone please tell me why the program has the following error? I
    > > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    > >
    > >
    > > /////////////////////////////////////////////////////////////////////
    > > #include <dos.h>
    > > #include <string.h>
    > > #include <stdio.h>
    > >
    > > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    > >
    > > #define DATA PORTADDRESS+0
    > > #define STATUS PORTADDRESS+1
    > > #define CONTROL PORTADDRESS+2
    > >
    > > void main(void)
    > > {
    > > char string[] = {"Testing 1,2,3 "
    > > "It' Works ! "};
    > > char init[10];
    > > int count;
    > > int len;
    > > init[0] = 0x0F; /* Init Display */
    > > init[1] = 0x01; /* Clear Display */
    > > init[2] = 0x38; /* Dual Line / 8 Bits */
    > >
    > > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > > Make sure Forward Direction */
    > >
    > > outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    > > (Register Select) */
    > >
    > > for (count = 0; count <= 2; count++)
    > > {
    > > outportb(DATA, init[count]);
    > > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    > > delay(20); /* Larger Delay for INIT
    > > */
    > > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    > > (Enable)*/
    > > delay(20); /* Larger Delay for INIT
    > > */
    > > }
    > >
    > > outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    > > (Register Select) */
    > >
    > > len = strlen(string);
    > >
    > > for (count = 0; count < len; count++)
    > > {
    > > outportb(DATA, string[count]);
    > > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    > > delay(2);
    > > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    > > delay(2);
    > > }
    > > }
    > > ////////////////////////////////////////////////////////////////////////////////
    > >
    > >
    > > --------------------Configuration: Text1 - Win32
    > > Debug--------------------
    > > Compiling...
    > > Text1.c
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > > 'outportb' : undeclared identifier
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > > 'inportb' : undeclared identifier
    > > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > > 'delay' : undeclared identifier
     
    Marco, Jul 10, 2006
    #11
  12. Marco wrote:
    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm


    There are many things that could cause your problems. The program uses
    many things which are not part of C and must be provided from some
    outside source. Some of these seem not to be provided by your (or many
    other implementations). This makes the program implementation-specific,
    and there are no doubt MS-specific newsgroups to address those problems.

    In addition, there are constructs which are not C at all.


    > #include <dos.h>

    This header does not exist as a standard C header. Think about it: for
    how many systems does the whole concept of "dos" make no sense at all,
    or for which "dod" doesn't mean some variant of MS-DOS (some of my old
    PDP-8s ran "DOS", for example).


    > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */


    This and the three defines based on it suggest that you are trying to
    directly access hardware. Nothing in C guarantees you can do this, and
    many operating systems forbid you to do this.

    > void main(void)


    main does *not* have a return type of void. main returns an int.
    Defining it otherwise makes your program beyond the pale, and the
    compiler need not produce anything useful.

    > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > Make sure Forward Direction */


    There are no standard functions outportb() or inportb(). If they exist
    on your implementation, they may well need to be linked. Whether they
    exist or not or your implementation, a program using them is not
    portable, possibly not even to another version of the same compiler on
    the same platform. Your error messages suggest that your implementation
    does not have them, at least not without linking some
    implementation-specific code, which linking you have not done.

    > delay(20); /* Larger Delay for INIT


    There is no standard function delay(). The comments above apply.

    Finally, you should (and must in pre-C99 C) return a value from main.
    Since you do not include <stdlib.h>, the only return value with portably
    defined meaning is 0. With <stdlib.h> included, the return values
    portably defined include in addition EXIT_SUCCESS and EXIT_FAILURE.


    > }
     
    Martin Ambuhl, Jul 10, 2006
    #12
  13. Marco

    Default User Guest

    Marco wrote:


    > I want to know whether outportb, delay and inportb are function in
    > general function in C? (I have no experience in C at all.) If they are
    > general function in C, how I can define them?
    > Thanks



    These are old DOS functions that some compilers used to provide. They
    are standard, and aren't usually available for Windows (you mention
    VC++ elsewhere).




    Brian
     
    Default User, Jul 10, 2006
    #13
  14. In article <>,
    Marco <> wrote:
    >Could anyone please tell me why the program has the following error? I
    >copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm

    ....
    >C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >'outportb' : undeclared identifier
    >C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >'inportb' : undeclared identifier
    >C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    >'delay' : undeclared identifier
    >


    outportb(), inportb(), and delay() are not standard C functions.

    Further, assuming that outportb() and inportb() do not have anything
    to do with ship navigation and refer to Intel *86 I/O ports, these
    functions require privileges no reasonable OS will allow an ordinary
    user to have - so even if you get it to compile, it won't run for
    an unprivileged user. Reasonable OS: UNIX, Linux, recent versions
    of Windows. Unreasonable OS: Windows 3.1 (I think), MS-DOS, CP/M
    86.

    Gordon L. Burditt
     
    Gordon Burditt, Jul 10, 2006
    #14
  15. Marco

    Neil Guest

    Marco wrote:
    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    >
    >
    > /////////////////////////////////////////////////////////////////////
    > #include <dos.h>
    > #include <string.h>
    > #include <stdio.h>
    >
    > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    >
    > #define DATA PORTADDRESS+0
    > #define STATUS PORTADDRESS+1
    > #define CONTROL PORTADDRESS+2
    >
    > void main(void)
    > {
    > char string[] = {"Testing 1,2,3 "
    > "It' Works ! "};
    > char init[10];
    > int count;
    > int len;
    > init[0] = 0x0F; /* Init Display */
    > init[1] = 0x01; /* Clear Display */
    > init[2] = 0x38; /* Dual Line / 8 Bits */
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > Make sure Forward Direction */
    >
    > outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    > (Register Select) */
    >
    > for (count = 0; count <= 2; count++)
    > {
    > outportb(DATA, init[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    > (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > }
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    > (Register Select) */
    >
    > len = strlen(string);
    >
    > for (count = 0; count < len; count++)
    > {
    > outportb(DATA, string[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    > delay(2);
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    > delay(2);
    > }
    > }
    > ////////////////////////////////////////////////////////////////////////////////
    >
    >
    > --------------------Configuration: Text1 - Win32
    > Debug--------------------
    > Compiling...
    > Text1.c
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'outportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'inportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > 'delay' : undeclared identifier
    >



    Beside the programming issues posted, you have a worse problem.
    You have MS-DOS code. Windows, NT, 2000, & XP will not let a user app
    write to hardware. The code can not be fixed to do what you want.
    You need to find one of the Parallel port drivers available on the net.
     
    Neil, Jul 10, 2006
    #15
  16. Marco

    Sjouke Burry Guest

    Neil wrote:
    > Marco wrote:
    >
    >> Could anyone please tell me why the program has the following error? I
    >> copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    >>
    >>
    >> /////////////////////////////////////////////////////////////////////
    >> #include <dos.h>
    >> #include <string.h>
    >> #include <stdio.h>
    >>
    >> #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    >>
    >> #define DATA PORTADDRESS+0
    >> #define STATUS PORTADDRESS+1
    >> #define CONTROL PORTADDRESS+2
    >>
    >> void main(void)
    >> {
    >> char string[] = {"Testing 1,2,3 "
    >> "It' Works ! "};
    >> char init[10];
    >> int count;
    >> int len;
    >> init[0] = 0x0F; /* Init Display */
    >> init[1] = 0x01; /* Clear Display */
    >> init[2] = 0x38; /* Dual Line / 8 Bits */
    >>
    >> outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    >> Make sure Forward Direction */
    >>
    >> outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    >> (Register Select) */
    >>
    >> for (count = 0; count <= 2; count++)
    >> {
    >> outportb(DATA, init[count]);
    >> outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    >> delay(20); /* Larger Delay for INIT
    >> */
    >> outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    >> (Enable)*/
    >> delay(20); /* Larger Delay for INIT
    >> */
    >> }
    >>
    >> outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    >> (Register Select) */
    >>
    >> len = strlen(string);
    >>
    >> for (count = 0; count < len; count++)
    >> {
    >> outportb(DATA, string[count]);
    >> outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    >> delay(2);
    >> outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    >> delay(2);
    >> }
    >> }
    >> ////////////////////////////////////////////////////////////////////////////////
    >>
    >>
    >>
    >> --------------------Configuration: Text1 - Win32
    >> Debug--------------------
    >> Compiling...
    >> Text1.c
    >> C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> 'outportb' : undeclared identifier
    >> C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> 'inportb' : undeclared identifier
    >> C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    >> 'delay' : undeclared identifier
    >>

    >
    >
    > Beside the programming issues posted, you have a worse problem.
    > You have MS-DOS code. Windows, NT, 2000, & XP will not let a user app
    > write to hardware. The code can not be fixed to do what you want.
    > You need to find one of the Parallel port drivers available on the net.

    Yes it can,google for userport.zip
    Sometimes computers are used to control
    hardware :)
    Outportb and inportb might be outp and inp.
     
    Sjouke Burry, Jul 10, 2006
    #16
  17. Marco

    Guest

    Hi macro,
    while ur using these functions don't use directly.
    u replace like
    Ex :
    inp as _inp;
    outp as _outp
    may be thse will work for u
    Reddy



    > Could anyone please tell me why the program has the following error? I
    > copy the program from http://www.beyondlogic.org/parlcd/parlcd.htm
    >
    >
    > /////////////////////////////////////////////////////////////////////
    > #include <dos.h>
    > #include <string.h>
    > #include <stdio.h>
    >
    > #define PORTADDRESS 0x378 /* Enter Your Port Address Here */
    >
    > #define DATA PORTADDRESS+0
    > #define STATUS PORTADDRESS+1
    > #define CONTROL PORTADDRESS+2
    >
    > void main(void)
    > {
    > char string[] = {"Testing 1,2,3 "
    > "It' Works ! "};
    > char init[10];
    > int count;
    > int len;
    > init[0] = 0x0F; /* Init Display */
    > init[1] = 0x01; /* Clear Display */
    > init[2] = 0x38; /* Dual Line / 8 Bits */
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xDF); /* Reset Control Port -
    > Make sure Forward Direction */
    >
    > outportb(CONTROL, inportb(CONTROL) | 0x08); /* Set Select Printer
    > (Register Select) */
    >
    > for (count = 0; count <= 2; count++)
    > {
    > outportb(DATA, init[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe
    > (Enable)*/
    > delay(20); /* Larger Delay for INIT
    > */
    > }
    >
    > outportb(CONTROL, inportb(CONTROL) & 0xF7); /* Reset Select Printer
    > (Register Select) */
    >
    > len = strlen(string);
    >
    > for (count = 0; count < len; count++)
    > {
    > outportb(DATA, string[count]);
    > outportb(CONTROL,inportb(CONTROL) | 0x01); /* Set Strobe */
    > delay(2);
    > outportb(CONTROL,inportb(CONTROL) & 0xFE); /* Reset Strobe */
    > delay(2);
    > }
    > }
    > ////////////////////////////////////////////////////////////////////////////////
    >
    >
    > --------------------Configuration: Text1 - Win32
    > Debug--------------------
    > Compiling...
    > Text1.c
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'outportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    > 'inportb' : undeclared identifier
    > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    > 'delay' : undeclared identifier
     
    , Jul 10, 2006
    #17
  18. "Marco" <> writes:
    >> > --------------------Configuration: Text1 - Win32
    >> > Debug--------------------
    >> > Compiling...
    >> > Text1.c
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> > 'outportb' : undeclared identifier
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(22) : error C2065:
    >> > 'inportb' : undeclared identifier
    >> > C:\Program Files\Microsoft Visual Studio\Text1.c(30) : error C2065:
    >> > 'delay' : undeclared identifier
    >> >

    >>
    >> It looks suspiciously like you tried to use functions that you haven't
    >> declared or defined.

    >
    > I want to know whether outportb, delay and inportb are function in
    > general function in C? (I have no experience in C at all.) If they are
    > general function in C, how I can define them?


    No, outportb, delay, and inportb are not standard C functions.
    They're system-specific. If you need more information about them,
    you'll need to ask in a system-specific newsgroup, possibly
    comp.os.msdos.programmer. (That's assuming that Rouben Rostamian to
    read the information on the web site doesn't solve your problem.)

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Jul 10, 2006
    #18
  19. Marco

    pete Guest

    Default User wrote:
    >
    > Marco wrote:
    >
    > > I want to know whether outportb, delay and inportb are function in
    > > general function in C?


    > These are old DOS functions that some compilers used to provide. They
    > are standard, and aren't usually available for Windows (you mention
    > VC++ elsewhere).


    I don't know what you think you mean by "They are standard",
    but those functions are not described in the C standard.

    --
    pete
     
    pete, Jul 10, 2006
    #19
  20. Marco

    Chris Dollin Guest

    pete wrote:

    > Default User wrote:
    >>
    >> Marco wrote:
    >>
    >> > I want to know whether outportb, delay and inportb are function in
    >> > general function in C?

    >
    >> These are old DOS functions that some compilers used to provide. They
    >> are standard, and aren't usually available for Windows (you mention
    >> VC++ elsewhere).

    >
    > I don't know what you think you mean by "They are standard",
    > but those functions are not described in the C standard.


    I think "are" is a negatypo for "aren't".

    --
    Chris "beware the dreaded negasphere" Dollin
    "Who do you serve, and who do you trust?" /Crusade/
     
    Chris Dollin, Jul 10, 2006
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. karthik
    Replies:
    5
    Views:
    11,048
    Dale King
    Jul 25, 2003
  2. Paul Perrone
    Replies:
    0
    Views:
    14,483
    Paul Perrone
    Aug 21, 2003
  3. b3ny
    Replies:
    11
    Views:
    946
    Babu Kalakrishnan
    Nov 20, 2004
  4. Novice Experl
    Replies:
    6
    Views:
    6,723
    c d saunter
    Aug 3, 2005
  5. Soren
    Replies:
    4
    Views:
    1,322
    c d saunter
    Feb 14, 2008
Loading...

Share This Page