I have installed libraw1394 and wrote a program to read and write via firewire. I tested it between a Ubuntu 12.04 box and my redhawk machine. with success. I tried using the same read program to read raw1394 data from a custom piece of hardware with no success. I know the device is spitting out data.
I was told that my redhawk machine needed to use raw1394. So i built the kernel modules for ieee1394 and raw1394 and did an insmod for both of them. Still no success.
Here is the code and output...
#include <stdio.h>
#include <string.h>
#include <libraw1394/raw1394.h>
#include <errno.h>
#include <stdlib.h>
#include <fcntl.h>
#define MAXPORTS 6
unsigned char gBuffer[4096];
int gDataLength;
bool gFlag;
enum raw1394_iso_disposition isoHandler(raw1394handle_t handle,
unsigned char *data,
unsigned int len,
unsigned char channel,
unsigned char tag,
unsigned char sy,
unsigned int cycle,
unsigned int dropped)
{
printf("Iso packet received! Length %08X, tag %08X, sy %08X, cycle %08X dropped: ", len, tag, sy, cycle,dropped);
memcpy(&gBuffer[0],data,len);
gDataLength = len;
for(int i = 0; i<len; i++)
{
printf("%02X ",gBuffer[i]);
if(!(i % 10))
printf("\n");
}
return RAW1394_ISO_OK;
}
int main(int argc, char* argv[]){
raw1394handle_t raw1394_h;
struct raw1394_portinfo pinf[6];
int nports,status;
char resp;
if(!(raw1394_h = raw1394_new_handle())) {
perror("Device1394:
pen_input: raw1394_get_handle");
return 1;
}
int tFwFD = raw1394_get_fd(raw1394_h);
status = fcntl(tFwFD,F_SETFL,O_NONBLOCK);
nports=raw1394_get_port_info(raw1394_h, pinf, MAXPORTS);
printf("%d ports found :\n",nports);
for (int i=0; i< nports; i++)
printf(" port %d: nodecount %d name %s \n",i,pinf[i].nodes,pinf[i].name);
if(raw1394_set_port(raw1394_h, 0) < 0) {
perror("Device1394:
pen_input: raw1394_set_port");
raw1394_destroy_handle(raw1394_h);
return 1;
}
/*
int raw1394_iso_recv_init (raw1394handle_t handle,
raw1394_iso_recv_handler_t handler,
unsigned int buf_packets,
unsigned int max_packet_size,
unsigned char channel,
enum raw1394_iso_dma_recv_mode mode,
int irq_interval);
*/
status = raw1394_iso_recv_init (raw1394_h,isoHandler ,2000, 1000, 62,RAW1394_DMA_DEFAULT, -1);
int temp = raw1394_errcode_to_errno(status);
printf("Receive init. Status = %d\n, errno = %d translated %d\n", status, errno,temp);
perror("rec init - ");
/*
int raw1394_iso_recv_start (raw1394handle_t handle,
int start_on_cycle,
int tag_mask,
int sync);
*/
status = raw1394_iso_recv_start(raw1394_h,-1, -1, 0);
printf("Started isoch receive. Status = %d\n, errno = %d\n", status, errno);
while(1)
{
raw1394_loop_iterate(raw1394_h);
printf("next...\n");
}
return 0;
}
1 ports found :
port 0: nodecount 1 name /dev/fw0
Receive init. Status = 0
, errno = 2 translated 57005
rec init - : No such file or directory
Started isoch receive. Status = 0
, errno = 2
^C
Any help would be appreciated! Thanks!