void iec61883_dv_xmit_stop (iec61883_dv_t dv) { assert (dv != NULL); if (dv->synch) raw1394_iso_xmit_sync (dv->handle); raw1394_iso_shutdown (dv->handle); }
void iec61883_dv_recv_stop (iec61883_dv_t dv) { assert (dv != NULL); if (dv->synch) raw1394_iso_recv_flush (dv->handle); raw1394_iso_shutdown (dv->handle); }
firewire_source::~firewire_source() { if (handle_.get()) { envir().taskScheduler().turnOffBackgroundReadHandling( raw1394_get_fd(handle_.get())); // libraw1394 does *not* automatically close the file descriptor // used for isochronous I/O on the new (Juju) firewire stack raw1394_iso_shutdown(handle_.get()); } if (verbose) { printf("INFO: Total length received: %llu\n", total_len_); printf("INFO: Dropped packets: %u\n", dropped_packets_); printf("INFO: Other packets: %u\n", other_packets_); } }
int main(int argc, char **argv) { raw1394handle_t handle; parse_args(argc, argv); fprintf(stderr, "port: %ld\nloops: %ld\nfile: %s\n", which_port, loopcount, filename); handle = raw1394_new_handle(); if (!handle) { if (!errno) fprintf(stderr, "No working kernel driver found.\n"); else perror("raw1394_get_handle"); exit(1); } do { if (raw1394_get_port_info(handle, NULL, 0) <= which_port) { fprintf(stderr, "Port %ld does not exist.\n", which_port); exit(1); } raw1394_set_port(handle, which_port); } while (errno == ESTALE); if (errno) { perror("raw1394_set_port"); exit(1); } if (filename) send_iso_file(handle); fprintf(stderr, "\n"); raw1394_iso_shutdown(handle); raw1394_destroy_handle(handle); return 0; }
/***************************************************************************** * Close: free unused data structures *****************************************************************************/ static void Close( vlc_object_t *p_this ) { access_t *p_access = (access_t*)p_this; access_sys_t *p_sys = p_access->p_sys; if( p_sys->p_ev ) { /* stop the event handler */ vlc_cancel( p_sys->p_ev->thread ); if( p_sys->p_raw1394 ) raw1394_iso_shutdown( p_sys->p_raw1394 ); vlc_join( p_sys->p_ev->thread, NULL ); vlc_mutex_destroy( &p_sys->p_ev->lock ); /* Cleanup frame data */ if( p_sys->p_ev->p_frame ) { block_ChainRelease( p_sys->p_ev->p_frame ); p_sys->p_ev->p_frame = NULL; p_sys->p_ev->pp_last = &p_sys->p_frame; } free( p_sys->p_ev ); } if( p_sys->p_frame ) block_ChainRelease( p_sys->p_frame ); if( p_sys->p_raw1394 ) raw1394_destroy_handle( p_sys->p_raw1394 ); AVCClose( p_access ); vlc_mutex_destroy( &p_sys->lock ); free( p_sys ); }
int main(int argc, char** argv) { int rc; /**< return code */ int port = 0; /*!< fw handle port number */ int nodeid = 0; /*!< arm server node id */ // parse command line (port number) opterr = 0; // getopt no err output const char short_options[] = "hp:n:"; int next_opt; do { next_opt = getopt(argc, argv, short_options); switch(next_opt) { case 'h': print_usage(); return EXIT_SUCCESS; break; case 'p': port = atoi(optarg); break; case 'n': nodeid = atoi(optarg); break; case '?': std::cerr << "Invalid argument" << std::endl; break; default: break; } } while(next_opt != -1); // ----- Get handle and set port for the handle ------- // create handle handle = raw1394_new_handle(); if (handle == NULL) { std::cerr << "**** Error: could not create 1394 handle " << strerror(errno) << std::endl; return EXIT_FAILURE; } // get port number & sanity check int numPorts = raw1394_get_port_info(handle, NULL, 0); if (port < 0 || port >= numPorts) { std::cerr << "Invalid port number" << std::endl; return EXIT_FAILURE; } // let user to choose which port to use rc = raw1394_set_port(handle, port); if (rc) { std::cerr << "**** Error: failed to set port " << strerror(errno) << std::endl; return EXIT_FAILURE; } // -------- Set FireWire bus reset handler -------- // set bus reset handler raw1394_set_bus_reset_handler(handle, my_bus_reset_handler); // ---------------------------------------------------------------------------- // Start tutorial 6 isochronous send // ---------------------------------------------------------------------------- /** * raw1394_iso_xmit_init - initialize isochronous transmission * @handle: libraw1394 handle * @handler: handler function for queueing packets * @buf_packets: number of isochronous packets to buffer * @max_packet_size: largest packet you need to handle, in bytes * (not including the isochronous header) * @channel: isochronous channel on which to transmit * @speed: speed at which to transmit * @irq_interval: maximum latency of wake-ups, in packets (-1 if you don't care) * * Allocates all user and kernel resources necessary for isochronous transmission. * Channel and bandwidth allocation at the IRM is not performed. * * Returns: 0 on success or -1 on failure (sets errno) **/ size_t length; unsigned char channel, tag, sy; unsigned char buffer[BUF_SIZE + BUF_HEAD]; channel = 5; tag = 6; sy = 7; // ----- transmitting end ------------- rc = raw1394_iso_xmit_init(handle, // 1394 handle NULL, // xmit handler BUFFER, // iso packets to buffer MAX_PACKET, // max packet size channel, // just pick 5 for fun RAW1394_ISO_SPEED_400, -1); // irq_interval if (rc) { perror("raw1394_iso_xmit_init"); exit(1); } rc = raw1394_iso_xmit_start(handle, -1, -1); if (rc) { perror("raw1394_iso_xmit_start"); exit(1); } quadlet_t data = 0x0; while (true) { rc = raw1394_iso_xmit_write(handle, (unsigned char *)&data, 4, tag, sy); if (rc) { perror("\nraw1394_iso_xmit_write"); break; } // data++; // std::cout << "data = " << data << std::endl; } // stop, clean up & exit raw1394_iso_stop(handle); raw1394_iso_shutdown(handle); raw1394_destroy_handle(handle); return EXIT_SUCCESS; }
bool firewire_source::try_open() { auto_raw1394 handle(raw1394_new_handle()); if (!handle.get()) return false; raw1394_set_userdata(handle.get(), this); int n_ports = raw1394_get_port_info(handle.get(), NULL, 0); std::vector<raw1394_portinfo> ports(n_ports); if (n_ports > 0) { int n_ports_again = raw1394_get_port_info(handle.get(), &ports[0], n_ports); if (n_ports > n_ports_again) { n_ports = n_ports_again; ports.resize(n_ports); } } if (n_ports == 0) { fprintf(stderr, "ERROR: No Firewire ports accessible\n"); return false; } // Try converting name to an integer char * end; int i = strtoul(port_name_.c_str(), &end, 10); // If we didn't convert the whole string, assume it really is a name if (*end) for (i = 0; i != n_ports; ++i) if (port_name_ == ports[i].name) break; if (i >= n_ports) { fprintf(stderr, "ERROR: %s: not found\n", port_name_.c_str()); return false; } if (verbose) printf("INFO: Reading from Firewire port %s\n", ports[i].name); if (raw1394_set_port(handle.get(), i)) { perror("raw1394_set_port"); return false; } if (raw1394_iso_recv_init(handle.get(), raw_receive, /*buf_packets=*/ 600, /*max_packet_size=*/ CIF_HEADER_SIZE + CIF_PACKET_SIZE + 8, /*channel=*/ 63, /*mode=*/ RAW1394_DMA_DEFAULT, /*irq_interval=*/ 100)) { perror("raw1394_iso_recv_init"); return false; } if (raw1394_iso_recv_start(handle.get(), -1, -1, -1)) { perror("raw1394_iso_recv_start"); raw1394_iso_shutdown(handle.get()); // see comment on destructor return false; } handle_ = handle; return true; }
int main(int argc, char** argv) { int rc; /**< return code */ int port = 0; /*!< fw handle port number */ int nodeid = 0; /*!< arm server node id */ // parse command line (port number) opterr = 0; // getopt no err output const char short_options[] = "hp:n:"; int next_opt; do { next_opt = getopt(argc, argv, short_options); switch(next_opt) { case 'h': print_usage(); return EXIT_SUCCESS; break; case 'p': port = atoi(optarg); break; case 'n': nodeid = atoi(optarg); break; case '?': std::cerr << "Invalid argument" << std::endl; break; default: break; } } while(next_opt != -1); // ----- Get handle and set port for the handle ------- // create handle handle = raw1394_new_handle(); if (handle == NULL) { std::cerr << "**** Error: could not create 1394 handle " << strerror(errno) << std::endl; return EXIT_FAILURE; } // get port number & sanity check int numPorts = raw1394_get_port_info(handle, NULL, 0); if (port < 0 || port >= numPorts) { std::cerr << "Invalid port number" << std::endl; return EXIT_FAILURE; } // let user to choose which port to use rc = raw1394_set_port(handle, port); if (rc) { std::cerr << "**** Error: failed to set port " << strerror(errno) << std::endl; return EXIT_FAILURE; } // -------- Set FireWire bus reset handler -------- // set bus reset handler raw1394_set_bus_reset_handler(handle, my_bus_reset_handler); // ---------------------------------------------------------------------------- // Start tutorial 4 async broadcast // ---------------------------------------------------------------------------- /** * */ // ----- receving end ------------- unsigned char channel = 0x5; raw1394_iso_dma_recv_mode mode = RAW1394_DMA_DEFAULT; raw1394_iso_recv_init(handle, my_iso_recv_handler, BUFFER, // buf_packets PACKET_MAX, // max_packet_size channel, // channel mode, // dma mode -1); // irq_interval // start receiving raw1394_iso_recv_start(handle, -1, -1, 0); while (true) { rc = raw1394_loop_iterate(handle); if (rc) break; } // stop, clean up & exit raw1394_iso_stop(handle); raw1394_iso_shutdown(handle); raw1394_destroy_handle(handle); return EXIT_SUCCESS; }