Thread: inportb() again, sorry

  1. #1
    Registered User
    Join Date
    Apr 2003
    Posts
    16

    inportb() again, sorry

    Ok, yes i know of google, but lifes too short to sort through thousands of articles and manuals that do not answer my question.

    value = inportb(0x378);

    I am using port talk to allow me access to COM1 on XP. The above code was supplied.

    My only aim is to read data sent to the port from some electronics i have been doing. I have set up the port to recieve the data, and terminal software is recieving an input, so data is comming in.

    Now the question is, how do i get the port name to go between the brackets?

    At the moment i am only getting 0xFF returned. So i am guessing somming is worng .

    According to the device manager the I/O range is 03F8 to 03FF. Anyone got any ideas.???


    Thanks,

    - MP

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    Well inportb() assumes 2 things
    1. That you're using DOS. Nothing else allows such unfettered access to the hardware. I note from your post that you're using XP, so that means you're not using DOS.
    You might think your black rectangle of a c:\> prompt is DOS, but it isn't.

    2. You need a DOS compiler. From your previous posts, you seem to be using DEV-C++.
    This isn't a DOS compiler, though it can generate win32 console programs. Despite their superficial similarity to DOS boxes of old, they're not DOS either.

    Read
    And scroll down to "Communications Resources"
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    16
    Arrg, ok thanks

    Starting to hate documentation, it was just a copy past thing. nm

    What include do i need to use create file?

  4. #4
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    depends. If you are using a console program or DOS you can use straight C++ file handling which associates a file with a stream, like this:

    char fileName[] = "myFile.txt";
    fstream dataStream(fileName);

    By default, if myFile.txt doesn't exist it will be created. If it does exist the data in it will be overwritten and the file will be started from scratch (you loose anything that was in the file originally). Since those two options aren't what you want all of the time, there are a number of ios flags that can be used to do what you want with regard creation/use of files. the streams used to manipulate files: fstream, ifstream, and ofstream; are in the header file called iostream (or iostream.h if you have an older compiler).

    If you are using Windows or some other API or if you want to use a pure DOS command in your program, there are ways to do it, but you need to be able to state exactly what you are trying to do with what equipment/tools so you get the answer most applicable to your situation.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help on Serial Port programming!!!
    By Unregistered in forum C Programming
    Replies: 4
    Last Post: 06-04-2002, 05:02 PM
  2. yes...more inportb.
    By SavesTheDay in forum C Programming
    Replies: 5
    Last Post: 02-18-2002, 04:03 PM