anyone can plz explain the code below....i have understood the basics of outortb and inportb but couldnt understand why and where specific hexcode values are used
#include<stdio.h> //header//
#include<conio.h> //header//
#include<dos.h> //header//
#include<graphics.h> //header//
#include<process.h> //header//
#include<time.h> //header//
#define PORT1 0x3f8 //port address//
unsigned char ca_data[25];
void portinit(void)
{
outportb(PORT1 + 1,0);
outportb(PORT1 + 3,0x80);
outportb(PORT1 + 0,0x0c);
outportb(PORT1 + 3,0x03);
outportb(PORT1 + 4,0x0B);
}
char* dwt(){
time_t t;
time(&t);
return ctime(&t);
}
void portclr(void)
{
char ch;
while(inportb(PORT1 + 5) & 1)
{
ch=inportb(PORT1);
}
}
void portread(int dnum,int timout)
{
int i=0,j=0;
while((i < timout) && (j < dnum))
{
delay(1);
if((inportb(PORT1 + 5) & 1))
{
if(j!=0)
{
ca_data[j]=inportb(PORT1);
j++;
}
else
{
ca_data[j]=inportb(PORT1);
if(ca_data[j]==0x65) //0x55
j++;
}
}
i++;
}
ca_data[dnum]=j;
}
void main(void)
{
int scan=0,device_1=0,device_2=0,dnum=12,timout=1000;
clrscr();
printf("A Project on RFID System\n");
do
{
do
{
portinit();
do
{
portclr();
do
{
//printf("Scanning...........\n");
portread(dnum,timout);
}
while(ca_data[dnum] < dnum);
}while((ca_data[0]!=0x65)||(ca_data[1]!=0x99));
printf("\nA Project on RFID System");
printf("\nScanning................................ ");
if(ca_data[3]==0x56)
device_1=1;
if(ca_data[3]==0x59)
device_2=1;
scan++;
}while(scan<5);
clrscr();
printf("A Project on RFID System\n");
printf("\nScanning Results...........");
printf("\nAvailable Devices..........");
if(device_1==1)
printf("\nDevice Name________Electronic Notebook");
if(device_2==1)
printf("\nDevice Name________Vacuum Cleaner");
printf("\npresent time________%s",dwt());
if((device_1==0)||(device_2==0))
{
printf("\n\nDevices Missing..........");
if(device_1==0)
printf("\nDevice Name________Electronic Notebook");
if(device_2==0)
printf("\nDevice Name________Vacuum Cleaner");
sound(3000);
printf("\npresent time________%s",dwt());
printf("\nPress any key to Continue.........");
getch();
}
printf("\n\n\n__________________________________") ;
device_1=0;
device_2=0;
scan=0;
//delay(1000);
}while(!kbhit());
}
insight on below specific lines would be highly appreciated :
}while((ca_data[0]!=0x65)||(ca_data[1]!=0x99));
if(ca_data[j]==0x65) //0x55
5 2735 Banfa 9,065
Expert Mod 8TB @kaushalneo
No we can't but I can explain why we can't. outportb writes directly to a memory location in the machine (you can't do this in WinXP, Vista or W7) so for instance I can see that your portinit function is writing 5 values to 4 separate locations in memory.
Now from the function name I would assume that it is initialising the hardware at those memory locations (probably 1 piece of hardware with several registers) but without knowing what that piece of hardware is and having access to its technical specification neither I nor anyone else can say what writing those specific values to those specific registers will do.
thanks banfa for replying on this little piece of information that i have...
sir i m only initialising the com port by these commands and not the hardware in the portinit function and all the hexcode values in them are there for the registers of the UART for specifying the baud rate, parity, stop bits etc.
i took the pains to understand about those details and got them from the net...i must mention it took great pains to do even that
but as of this program i just need help on specific data values that are being returned which ofcourse my hardware would send. for example i m referring to while((ca_data[0]!=0x65)||(ca_data[1]!=0x99));
in this line i m unable to understand what 0x65 and 0x99 could possibly mean. similarly if(ca_data[3]==0x56)
device_1=1;
if(ca_data[3]==0x59)
device_2=1;
in this piece of code i m unable to get the significance of 0x56 and 0x59 and i suppose this would be the data that would come to my "COM port 1" and received from there.
for instance in the portinit function the hex values refer to as follows :
outportb(PORT1 + 3 , 0x80); /*Open Port*/
outportb(PORT1 + 0 , 0x0C); /*Baud Rate 9600*/
outportb(PORT1 + 3 , 0x03); /* 8 Bits, No Parity, 1 Stop Bit */
outportb(PORT1 + 4 , 0x0B); /* Turn on DTR, RTS, and OUT2 */
these all are pre-defined for the UART and do not refer to my hardware.
any further help would be greatly acknowledged
Obviously, 0x56 and 0x59 are rfid tag ids stuck to notebook and vacuum. The hardware is supposed to issue 0x65 to its output and then up to 12 bytes (or until timeout expires), fourth of which is item's id. I'd rather start with reading this hardware's specs.
heyy thanks newb16...ur info helped a lot really....
could u juz give me insight on 0x99 used in the same while loop.....
thanks in advance...
i ll try to geet the specs abt the hardware....and tell u the details and specifications of the same...
Hi the Port 1 defined with address 0x3F8 is the communications port COM 1 of the system, which is generally a printer port. You can find its specifications in any system from the system tools - system information. In the program, you are manipulating this COM 1 address and doing IO operations.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: willie |
last post by:
Hi,
I'm writing a program which requires the use of three serial ports and
one parallel port. My application has a scanning devices on each port,
which I can access fine with pyserial. ...
|
by: sarah |
last post by:
hI,
I have a project. I need to realise serial communication between PC
and Altera FPGA in c or c++. The function of FPGA is working well. it
can send data to uart.
Does anybody know how to...
|
by: rusttree |
last post by:
Many moons ago, I took a class in embedded control at school. The
course focused on a micro-controller mounted on a small electric car
that was programmed using simple C code. The...
|
by: Duffey, Kevin |
last post by:
I don't know if jdbc/java code requires this, but when I use two gui admin tools I found, and I insert a row into the table using their row editor feature, both require me to enter a number for the...
|
by: Suchandra Thapa |
last post by:
I was wondering if there was a reliable method to get the last id
inserted into a serial column in a table. I believe previous
recommendations given were to use a sequence, have your app get the...
|
by: Al the programmer |
last post by:
I need to access the serial ports on my webserver from an asp.net page. I
have no problem accessing the serial ports from a windows form application,
but the code doesn't work in asp.net. I have...
|
by: vicky |
last post by:
Hello,I met a question when I wrote the program.I want the program can
transmit the data frame continuosly through the RS232 when the
communication has been interrupted.But I don't know how to...
|
by: shussai2 |
last post by:
Hi,
I am trying to access Serial Port in XP. I am using Dev-C++ IDE that
uses Mingw as a compiler. I just want to know how I can open up serial
port on COM1 and write some data. I have searched...
|
by: Rob |
last post by:
Hi all,
I am fairly new to python, but not programming and embedded. I am
having an issue which I believe is related to the hardware, triggered
by the software read I am doing in pySerial. I...
|
by: ganesah |
last post by:
hi there,
could anyone please explain me on how to put the functions (e.g create file, open port, getcommstate,DCB, setcommstate, write and read file and commtimeouts in Win32 API) for serial...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |