![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Feb 2005
Posts: 1
Rep Power: 0
![]() |
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); } |
|
|
|
|
|
#2 |
|
Programmer
|
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"; |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|