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.

In reply to Re^6: Win32::SerialPort ; close / open problem by philipMac
in thread Win32::SerialPort ; close / open problem by philipMac

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.