Что-то как-то не идёт
Поглядите код, пожалуйста
отправляет
/* For "devctl()" */
#include <devctl.h>
#include <sys/dcmd_chr.h>
/* For "open()" */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "PCI429_3_QNX.h"
union buffer
{
unsigned short int dataInt[0x210 ];
unsigned long int dataUlong[ 0x100];
} ;
union buffer u;
int main(int argc, char *argv[])
{
int hARINC;
int pid;
int i, nbytes;
//***Открытие устройства***
hARINC=open("/dev/PCI429_0",0);
printf (" hARINC = %xh \n", hARINC);
if (hARINC == -1)
return 0;
//***Передача драйверу идентификатора процесса***
pid = getpid();
devctl(hARINC,pci429_setEvent , &pid , sizeof( pid ), NULL);
//Первоначальная настройка параметров адаптера
devctl(hARINC, pci429_RESET , &u , 2, NULL);
printf (" rid = %xh \n", u.dataInt[0] );
//***Инициализация адаптера
u.dataInt[0] = 0xf88;
u.dataInt[1] = 0;
for (i=0; i<16; i++) u.dataInt[2+i] = 2;
devctl(hARINC, pci429_INIT , &u ,36, NULL);
//***Подготовка буфера выходных каналов (файловый режим)
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 1;
u.dataInt[2] = 255;
u.dataInt[3] = 1;
u.dataInt[4] = 0;
u.dataInt[5] = 0;
u.dataInt[6] = 0;
u.dataInt[7] = 0x55;
nbytes = (7+1)*2;
devctl(hARINC, pci429_TAB_SO_F , &u , nbytes, NULL);
//***Запись выходного параметра(файловый режим вых. канала)
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 1;
for (i=1; i<=0x100; i++)
{
u.dataInt[2] = i;
u.dataUlong[2] =((i-1)&0xff)|((4)<<8)|(((~(i-1))&0xff)<<16)|(((~4)&0xff)<<24);
devctl(hARINC,pci429_WRITE_PRM_F, &u , 12, NULL);
//printf (" %d %8x \n",u.dataInt[2], u.dataUlong[2] );
}
//***Пуск выходного канала
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 0x0;
u.dataInt[2] = 0;
devctl(hARINC, pci429_puskSO , &u , 6, NULL);
printf ("\n---> %d \n", u.dataInt[0] );
//Останов вых. канала
u.dataInt[0] = atoi(argv[1]);
devctl(hARINC, pci429_stopSO , &u , 2, NULL);
//Останов адаптера
devctl(hARINC, pci429_STOP , NULL , 0, NULL);
//***Закрытие устройства***
close(hARINC);
return 1;
}
прием
/* For "devctl()" */
#include <devctl.h>
#include <sys/dcmd_chr.h>
/* For "open()" */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include "PCI429_3_QNX.h"
union buffer
{
unsigned short int dataInt[0x210 ];
unsigned long int dataUlong[ 0x100];
} ;
union buffer u;
int main(int argc, char *argv[])
{
int hARINC;
int pid;
int i, nbytes;
//***Открытие устройства***
hARINC=open("/dev/PCI429_0",0);
printf (" hARINC = %xh \n", hARINC);
if (hARINC == -1)
return 0;
//***Передача драйверу идентификатора процесса***
pid = getpid();
devctl(hARINC,pci429_setEvent , &pid , sizeof( pid ), NULL);
//Первоначальная настройка параметров адаптера
devctl(hARINC, pci429_RESET , &u , 2, NULL);
printf (" rid = %xh \n", u.dataInt[0] );
//***Инициализация адаптера
u.dataInt[0] = 0xf88;
u.dataInt[1] = 0;
for (i=0; i<16; i++) u.dataInt[2+i] = 2;
devctl(hARINC, pci429_INIT , &u ,36, NULL);
//***Подготовка буфера входного канала для режима ПСС
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 2;
u.dataInt[2] = 0;
u.dataInt[3] = 0;
u.dataInt[4] = 0x100;
for (i=0; i<0x100; i++)
u.dataInt[5+i] = i;
nbytes =(5+0x100)*2;
devctl(hARINC, pci429_TAB_SI_SS , &u , nbytes, NULL);
printf ("\n---> %d \n", u.dataInt[0] );
//Пуск входного канала
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 0xb2;
devctl(hARINC, pci429_puskSI , &u , 4, NULL);
printf ("\n---> %d \n", u.dataInt[0] );
//Чтение входного параметра в защищенном режиме
for (i1=0; i1<0x2; i1++)
{
for (i=0; i<0x100; i++)
{
u.dataInt[0] = atoi(argv[1]);
u.dataInt[1] = 2;
u.dataInt[2] = i;
devctl(hARINC, pci429_READ_PRM_SS_nc, &u , 6, NULL);
printf (" %8x ", u.dataUlong[0] );
}
printf ("\n" );
}
//Останов входного канала
u.dataInt[0] = atoi(argv[1]);
devctl(hARINC, pci429_stopSI , &u , 2, NULL);
//Останов адаптера
devctl(hARINC, pci429_STOP , NULL , 0, NULL);
//***Закрытие устройства***
close(hARINC);
return 1;
}