in reply to Re^7: Win32::SerialPort ; close / open problem
in thread Win32::SerialPort ; close / open problem
sub init_FTD { my $FT = Win32::FTDI::FTD2XX->new(); unless( $FT->PFT_STATUS() == FT_OK ) { printf( STDERR "FTD2XX::new() failed: %s (%s)\n", $FT->PFT_STATUS_ +MSG(), $FT->PFT_ERROR() ); return 0; } printf( "FTD2XX::new() allocated PFT_HANDLE: %d\n", $FT->PFT_HANDLE( +) ); # $FT->PFT_DEBUG(1); unless ($FT->OpenByIndex(0)) { print "Problem opening Port 0\n"; return 0; } unless ($FT->SetBreakOn) { print "failed to set brake\n"; } unless ($FT->Purge(FT_PURGE_RX)) { print 'cannot purge'; } unless ($FT->SetBaudRate(FT_BAUD_2400)) { print "Baud is set\n"; return 0; } return $FT; }
|
|---|