Alright, so I am working my way through the Win32::FTDI::FTD2XX stuff, and I have narrowed it down, again, to a single problem.
Say I boot the machine, open a port, start reading stuff in, everything is fine. There is no problem.
Then say I unplug the device, I see this, catch it, and try to re init a new port and it will never work. If I close the program, and restart the program, it will never come back. All the data that comes in unpacks to rubbish.
Then, this is where its interesting, then I open the port in RealTerm or some Win app, and something is reset. I can then close RealTerm, and restart my program and everything works perfectly... until I unplug the device again.
So, there is clearly something odd going on. Like I said, even my closing the program, and restarting it cannot get my data coming in sensibly, it is always trash, _until_ I open the port with RealTerm. Once I reset it with RealTerm I can perform whatever operation on the device I feel like, and it always comes back to me, still running.
Ie, I can
$FTD->StopInTask;
$FTD->Purge;
#$FTD->SetResetPort;
#$FTD->ResetDevice;
$FTD->CyclePort;
sleep(9);
#get stat, create new $FTD, read data;
and so on and so forth. I have tried pretty much... (over the last three weeks) every combination and incantation of the various reseting type of commands, I can never get the data coming in properly again until I "reset" something with RealTerm.
I would really like to know what RealTerm is doing that I am failing on.
Edit; in fact I was slightly incorrect here.
I said if I booted the machine, and plugged in the USB, or let it boot with the USB connect it will _not_ work properly.
So, it seems that in all cases I must first open the port in say RealTerm, even just loading RealTerm and killing it, even without setting Baud, simply opening the program and closing it resets port, and it will work perfectly. Up until this point, it will appear to work properly, until I actually look at the data coming in, and see that it is rubbish.
Also, there is also an odd number of bytes coming in until the RealTerm gets loaded. There should be 9 bytes every second or so. Unless realTerm is loaded its ~always some other number, often 10 or 11.