Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Feb 14th, 2005, 9:53 AM   #1
dominic
Newbie
 
Join Date: Feb 2005
Posts: 1
Rep Power: 0 dominic is on a distinguished road
port programming

Hi,
kindly show me how to modify the code below so that it takes its input from a user specifeied file (prompted by the program) and the data also read from the port is also taken to another filename provided by the user. I a have written this program to assist me send data to a stream cipher circuitry connected to the PC's parallel port at address 0x378 (IOBASE).

SOFTWARE DESIGN.

/* *******************************************************/
/*This program is intended to WRITE and READ data to and from the SPP port */

/*Author: Mr. Dominic. */

/*Date: 8-12 Feb. 2005.
/*Reference: www.bibinjohn.tk . */

/******************************************************************/
#include <stdio.h> /* required so as to access the filesystem*/
#include <dos.h>
#include <time.h>
#define DATA 0x378 /*Data Register base address*/
#define STATUS DATA+1 /* Status Register address*/
#define CONTROL DATA+2 /*Control Register address*/

main()
{
char s;
char c;
c='A';


outport(CONTROL,inportb(CONTROL)&0xF0|0x04); /*initialise the
CONTROL port for data input*/

outportb(DATA, c); /*write c to the DATA register*/

s=(inportb(STATUS)&0xF0); /* read MSnibble*/

s=s|(inportb(CONTROL)&0x0F);/*Read LSnibble*/

s=s^0x84; /*toggle bit 2 and 7 */
/*pins 11 and 14 are hardware inverted*/

printf("character: %c becomes: %c\n", c,s);

return (0);

}
dominic is offline   Reply With Quote
Old Feb 14th, 2005, 10:52 AM   #2
Lance
Programmer
 
Lance's Avatar
 
Join Date: Oct 2004
Location: Chicago, IL USA
Posts: 74
Rep Power: 4 Lance is on a distinguished road
Send a message via AIM to Lance
You wrote all that, yet you don't know how to use the scanf() function? Perplexing...

Anyways, go and read 'man 3 scanf' or this online article:

http://www.cs.ntu.edu.au/sit/resourc...gram/c_016.htm

Or just use google: 'scanf input c' or some other query.

Pretty straightforward, eh? :p
__________________
/* LANCE */
C++;  /* this makes C bigger but returns the old value */
char *site = "slackwise.net",
     *home = "lance.slackwise.net",
     *pics = "flickr.com/photos/slackwise";
Lance is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:32 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC