I did search the forum but didn't find a solution, but some related information about USB.
I have a Teensy3.0 from which I print ASCII data via Serial (which is the USB connection) and capture the data in TeraTerm. I am intermittently losing small chunks of text. I am unsure as to where in the chain the problem lies, because I read that transfer of "serial" data via USB should be 100% reliable. I realise that the teensy OS code creates a "fake" Serial data stream, which is great for ease of use. I use TeraTerm to capture the text, as it is the simplest thing to do.
Of course I have suffered data loss at high baud rates with genuine hardware serial data transfer (via a FTDI PCB to the USB port of a PC) on a different project, but I was able to solve by implementing hardware handshaking (CTS or whichever signal was needed - I forget now). It was for a Mega2560 and I had to hack the OS code to make it work, by using a spare pin to look at CTS.
The project was started to give me a way to exercise Atari ST 80 track 3.5inch floppy disk drives, in order to diagnose faults with the drive(s). I used a Teensy3.0 because it was to hand. Data to/from the floppy interface is buffered with open-collector TTL. After implementing the basic drive control (motor on, head step, etc.) I wanted to see if I could decode the read data stream. I guess it's the same sort of idea as KyroFlux or Greaseweasel, however I am decoding the data stream on the fly, so the Teensy3.0 is operating more like a regular FDC (floppy disk controller) IC. With my latest code additions, I can read a track of 9 or 10 sectors of the standard 512 bytes into a track buffer (byte array).
I implemented a simple user interface to control the Teensy3.0 using single key commands. When reading a sector I print the 512 bytes of the sector in hex and ASCII. This is useful for confirming correct operation and seeing the disk format and contents. One new command reads all 80 tracks (1 or 2 sides) and dumps all sectors. I capture the text in TeraTerm. I have a simple Perl script which extract the ASCII hex bytes and writes a 360k or 720k binary file. This file can be read by Atari ST emulators.
I am now dumping the data from my collection of old Atari ST disks, which I kept from the 80's. I have thankfully recovered much of my old source code for various projects.
The problem is that there are glitches in the captured data log file, where the serial data stream has gone wrong. It happens about once or twice per disk capture. A small section of around 100(?) bytes is missing and it possibly is replaced with some repeated data. I can go re-read any garbled sector data, and then edit the log file manually, but this is tedious and really slows down the task.
The (occasional) glitch occurs when writing all 9 sectors from the sector buffer to Serial (using Serial.print() ), which is done after every track read. I have tried adding "delay(x)" in various places in the print loop. I have tried using Serial.availableForWrite() to see if this gives an indication of buffer overflow, but nothing appears wrong. I'm unsure as to whether this is the right command or perhaps I am using it incorrectly?
One clue was that if during a disk dump, when TeraTerm is displaying scrolling ASCII text, if I select "File->Show Log Dialog" the screen freezes for a moment until the dialog appears. When I review the final log file, there is always a missing chunk of data, larger than the small glitch, but showing that the Teensy3.0 must still be sending data when TeraTerm is unable to receive/buffer.
Are there some other Serial functions which I can use to help me determine whether more text can be printed?
How does the Teensy3.0 "see" that the sink (TeraTerm) is temporarily unable to take any more data?
thank you for any help.
Here is an example of the data loss caused by the "File->Show Log Dialog". Data from sector 7,8,9 and 0 have been lost. If I can understand how to code to prevent this, it will solve the original data loss problem.
I have a Teensy3.0 from which I print ASCII data via Serial (which is the USB connection) and capture the data in TeraTerm. I am intermittently losing small chunks of text. I am unsure as to where in the chain the problem lies, because I read that transfer of "serial" data via USB should be 100% reliable. I realise that the teensy OS code creates a "fake" Serial data stream, which is great for ease of use. I use TeraTerm to capture the text, as it is the simplest thing to do.
Of course I have suffered data loss at high baud rates with genuine hardware serial data transfer (via a FTDI PCB to the USB port of a PC) on a different project, but I was able to solve by implementing hardware handshaking (CTS or whichever signal was needed - I forget now). It was for a Mega2560 and I had to hack the OS code to make it work, by using a spare pin to look at CTS.
The project was started to give me a way to exercise Atari ST 80 track 3.5inch floppy disk drives, in order to diagnose faults with the drive(s). I used a Teensy3.0 because it was to hand. Data to/from the floppy interface is buffered with open-collector TTL. After implementing the basic drive control (motor on, head step, etc.) I wanted to see if I could decode the read data stream. I guess it's the same sort of idea as KyroFlux or Greaseweasel, however I am decoding the data stream on the fly, so the Teensy3.0 is operating more like a regular FDC (floppy disk controller) IC. With my latest code additions, I can read a track of 9 or 10 sectors of the standard 512 bytes into a track buffer (byte array).
I implemented a simple user interface to control the Teensy3.0 using single key commands. When reading a sector I print the 512 bytes of the sector in hex and ASCII. This is useful for confirming correct operation and seeing the disk format and contents. One new command reads all 80 tracks (1 or 2 sides) and dumps all sectors. I capture the text in TeraTerm. I have a simple Perl script which extract the ASCII hex bytes and writes a 360k or 720k binary file. This file can be read by Atari ST emulators.
I am now dumping the data from my collection of old Atari ST disks, which I kept from the 80's. I have thankfully recovered much of my old source code for various projects.
The problem is that there are glitches in the captured data log file, where the serial data stream has gone wrong. It happens about once or twice per disk capture. A small section of around 100(?) bytes is missing and it possibly is replaced with some repeated data. I can go re-read any garbled sector data, and then edit the log file manually, but this is tedious and really slows down the task.
The (occasional) glitch occurs when writing all 9 sectors from the sector buffer to Serial (using Serial.print() ), which is done after every track read. I have tried adding "delay(x)" in various places in the print loop. I have tried using Serial.availableForWrite() to see if this gives an indication of buffer overflow, but nothing appears wrong. I'm unsure as to whether this is the right command or perhaps I am using it incorrectly?
One clue was that if during a disk dump, when TeraTerm is displaying scrolling ASCII text, if I select "File->Show Log Dialog" the screen freezes for a moment until the dialog appears. When I review the final log file, there is always a missing chunk of data, larger than the small glitch, but showing that the Teensy3.0 must still be sending data when TeraTerm is unable to receive/buffer.
Are there some other Serial functions which I can use to help me determine whether more text can be printed?
How does the Teensy3.0 "see" that the sink (TeraTerm) is temporarily unable to take any more data?
thank you for any help.
Here is an example of the data loss caused by the "File->Show Log Dialog". Data from sector 7,8,9 and 0 have been lost. If I can understand how to code to prevent this, it will solve the original data loss problem.
*track 5 side 0 sector 7*
61 00 f5 8c 45 f9 00 00 f6 20 61 00 f5 b2 7e 08 61 00 f6 3e b0 44 67 f6 b0 45 67 f2 41 f9 00 00 * a_..E.__. a_..~_a_.>.Dg..Eg.A.__
82 5c 43 f9 00 00 82 68 74 0b 32 19 b0 18 57 ca ff fa 66 da 41 f9 00 00 f6 20 4e fb 10 fe 47 f9 * .\C.__.ht_2_._W...f.A.__. N._.G.
00 00 9c 06 49 f9 00 00 9c 11 22 68 02 c4 22 8b 22 68 02 dc 22 8c b8 7c 00 15 4e 75 61 e0 67 4c * __._I.__._"h_."."h_."..|__Nua.gL
08 a8 00 07 02 a9 67 06 7e 1c 61 00 fa d8 7e 1d 61 00 fa d2 7e 1e 61 00 fa cc 61 56 60 9e 47 f9 * _.___.g_~_a_..~_a_..~_a_..aV`.G.
00 00 9b f0 49 f9 00 00 9b fc 61 be 66 4a 61 00 f0 8e 67 18 08 e8 00 07 02 a9***** STATUS Sector Order = 01:02:03:04:05:06:07:08:09:*****
***** STATUS Header Crc = dac6(dac6):8f95(8f95):bca4(bca4):2533(2533):1602(1602):4351(4351):7060(7060):605e(605e):536f(536f):*****
***** STATUS Sector Crc = 3392(3392):381b(381b):d816(d816):37d8(37d8):053d(053d):91c1(91c1):fd2f(fd2f):4461(4461):5ed5(5ed5):*****
*track 6 side 1 sector 1*
4f 70 3a 20 50 72 69 6e 74 20 74 65 78 74 00 49 4f 70 3a 20 4d 6f 76 65 20 62 6c 6f 63 6b 00 49 * Op: Print text_IOp: Move block_I
4f 70 3a 20 43 6c 65 61 72 20 62 6c 6f 63 6b 00 49 4f 70 3a 20 53 61 76 65 20 62 6c 6f 63 6b 20 * Op: Clear block_IOp: Save block
61 73 2e 2e 2e 00 49 4f 70 3a 20 50 72 69 6e 74 20 62 6c 6f 63 6b 00 49 4f 70 3a 20 4f 70 65 6e * as..._IOp: Print block_IOp: Open
20 66 69 6c 65 2e 2e 2e 00 49 4f 70 3a 20 4d 65 72 67 65 20 66 69 6c 65 2e 2e 2e 00 49 4f 70 3a * file..._IOp: Merge file..._IOp:
20 52 65 65 6c 69 6d 69 6e 61 74 65 20 74 65 78 74 00 6e 6f 20 69 63 6f 6e 20 6f 70 65 72 61 74 * Reeliminate text_no icon operat
69 6f 6e 73 00 49 4f 70 3a 20 4d 6f 76 65 20 69 63 6f 6e 00 84 8e 94 99 81 9a 4c 6f 61 64 00 53 * ions_IOp: Move icon_......Load_S
61 76 65 00 4e 65 77 20 70 61 67 65 20 6c 65 6e 67 74 68 3a 00 4e 65 77 20 6c 69 6e 65 20 6c 65 * ave_New page length:_New line le
6e 67 74 68 3a 00 54 6f 20 70 61 67 65 3a 00 54 6f 20 6c 69 6e 65 3a 00 5b 33 5d 5b 53 79 6e 74 * ngth:_To page:_To line:_[3][Synt
61 78 20 65 72 72 6f 72 21 5d 5b 43 61 6e 63 65 6c 5d 5b 33 5d 5b 4e 75 6d 62 65 72 20 3e 20 32 * ax error!][Cancel][3][Number > 2
35 35 20 28 24 31 30 30 29 20 21 5d 5b 43 61 6e 63 65 6c 5d 5b 33 5d 5b 4d 75 6c 74 69 70 6c 65 * 55 ($100) !][Cancel][3][Multiple
20 64 65 66 69 6e 69 74 69 6f 6e 21 5d 5b 43 61 6e 63 65 6c 5d 5b 33 5d 5b 49 6e 73 74 61 6c 6c * definition!][Cancel][3][Install
61 74 69 6f 6e 20 74 6f 6f 20 62 69 67 21 5d 5b 43 61 6e 63 65 6c 5d 50 52 45 41 4d 42 4c 45 00 * ation too big!][Cancel]PREAMBLE_
50 4f 53 54 41 4d 42 4c 45 00 45 4e 44 4c 49 4e 45 00 42 45 46 4f 52 45 4c 49 4e 45 00 42 45 46 * POSTAMBLE_ENDLINE_BEFORELINE_BEF
4f 52 45 50 41 47 45 00 41 46 54 45 52 50 41 47 45 00 3a 3d 00 43 72 6f 73 73 20 72 65 66 65 72 * OREPAGE_AFTERPAGE_:=_Cross refer
65 6e 63 65 20 6c 69 73 74 20 66 6f 72 20 03 00 04 20 54 6f 74 61 6c 3a 20 31 32 33 34 35 36 37 * ence list for ___ Total: 1234567
38 00 00 44 49 53 4b 20 44 52 49 56 45 00 50 52 49 4e 54 45 52 00 42 4c 4f 43 4b 20 52 45 47 49 * 8__DISK DRIVE_PRINTER_BLOCK REGI
*end*
*loop*