How to Install and Test PCI 8Photo/8Relay Card on Linux


1.About Install:

(1)Please download driver from as follows:

Kernel 2.2.14 --

Kernel 2.4 --

Kernel 2.4.18 --


(2)Please follow as follows to install:




(3)Please edit /etc/rc.local to add a command line as follows:







(4)Please reboot the machine.

(5)Please use 'lsmod' to check after system started. You can find PCI 8Photo/8Relay.




2.About Test:

(1)The driver includes two test programs. The 'test.c' tests Relay. The 'test1.c' tests Relay/Photo.

Please connect a loopback with PCI 8Photo/8Relay card. About loopback, please refer to:




(2)Please compile test.c as follows:

#cc test.c

(3)Then it will create a 'a.out' file. Please execute it to test Relay. You will see Led light from L1 to L8 on the PCI

8Photo/8Relay card.



The test.c's content is as follows:


#include "dpci8in8out.h"

#include "dpci8in8outlib.c"

#include <stdio.h>

#include <fcntl.h> /* open */

#include <unistd.h> /* exit */


/* Main - Call the ioctl functions */

main()

{

int file_desc, i,count=0;

char buf[255];

char b=1;

char *msg = "Message passed by ioctl\n";


sprintf(buf,"/dev/%s0\0",DEVICE_NAME);

file_desc = open(buf, O_RDONLY);

if (file_desc < 0)

{

printf ("Can't open device file: %s\n", buf);

exit(-1);

}

Write8In8OutPort(file_desc,0x0);

do{

Write8In8OutPort(file_desc,b);

b=b<<1;

count++;

if(count%8==0) b=1;

sleep(1);

} while(count<1000);

close(file_desc);

}


(4)Please compile test1.c as follows:

#cc test1.c

(5)Then it will create a 'a.out' file. Please execute it to test Relay and Photo. The result is as follows:



The test1.c's content is as follows:


#include "dpci8in8out.h"

#include "dpci8in8outlib.c"

#include <stdio.h>

#include <fcntl.h> /* open */

#include <unistd.h> /* exit */

#include <string.h>

#include <sys/select.h>


/*It is a delay function.*/

void mysleep( long sec, long msec){

struct timeval tv;

tv.tv_sec = sec;

tv.tv_usec = msec*1000;

select(0, NULL, NULL, NULL, &tv);

}


/* Main - Call the ioctl functions */

main()

{

int file_desc,data,i,j=0;

unsigned char buf[255];


sprintf(buf,"/dev/%s0\0",DEVICE_NAME);

file_desc = open(buf, O_RDONLY);

if (file_desc < 0)

{

printf ("Can't open device file: %s\n", buf);

exit(-1);

}

Write8In8OutPort(file_desc,0x0);

for(i=1;i<256;i++)

{

Write8In8OutPort(file_desc,i);

printf("I write %d\n", i);

mysleep(0,100);

printf("I read %02x\n",Read8In8OutPort(file_desc));

mysleep(1,100);

}

Write8In8OutPort(file_desc,0x0);

close(file_desc);

}