Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Brian K. White

On 4/21/23 18:15, Brian K. White wrote:


## unk23 is what the old dlplus called "ts-dos mystery command"
## it's unknown what it *really* means, but it's a reliable way to 
tell the difference between TPDD1 and TPDD2  without locking up the 
drive by giving an invalid command to the wrong drive.
## when you issue a certain request, the real drive gives back this 
response, and it's always the same response for all TPDD1 drives.
## so if you issue the request and get the expected response, the 
drive is a TPDD1, otherwise it's a TPDD2, and in either case it 
doesn't lock up the drive.


another correction, right idea just backwards tpdd1 vs tpdd2

# TS-DOS mystery TPDD2 detection - some versions of TS-DOS send this
# TPDD2 gives this response. TPDD1 does not respond.
# request: 5A 5A 23 00 DC
# return : 14 0F 41 10 01 00 50 05 00 02 00 28 00 E1 00 00 00 2A

There is also a similar 0x11 command where like 0x23, TPDD2 responds 
with something and TPDD1 does not respond (but also does not get freaked 
out and lock up)


Client sends 0x11  (0x5A 0x5A 0x11 0x00 0x##)  ## = checksum
TPDD2 responds: 3A 06 80 13 05 00 10 E1 36
TPDD1 does not respond

and 0x33 is apparently a synonym for 0x11
if the client sends an 0x33 request, TPDD2 responds the same way as for 0x11

No version of TS-DOS uses 0x11 or 0x33 that I have found, I found it by 
just feeding all possible commands to a drive to see what it did.

Not all versions of TS-DOS use 0x23 either.

I don't know if all tpdd2 drives respond with the same value like they 
do for 0x23


dlplus emulates all of these, which tell TS-DOS it can use some 
TPDD2-only commands
or can be told specifically *not* to, to more accurately emulate a 
TPDD1, which allows some TPDD1-only client software to work that would 
otherwise get screwed up by unexpected responses because the client 
software was from before TPDD2 or desklink existed.


--
bkw

Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Brian K. White

On 4/21/23 18:15, Brian K. White wrote:

## The Sardine dictionary disk uses 128byte sectors



correction, must be 256, given the actual transaction shown

--
bkw



Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Brian K. White

Ok here is a break down of a transaction to read a single logical sector.

It's pdd.sh with debug level 4, interspersed with explanations

Below, to cut through everything, all the actual serial port traffic is 
just the tpdd_read() and tpdd_write() commands.
Everything else is just the stuff to arrive at what to send or how to 
interpret what you received.


But every byte that is sent to the drive is sent by tpdd_write(bytes)
And every byte that is read from the drive is read by tpdd_read(# of bytes)

tpdd_write(5A 5A 08 00 F7)  means to send exactly and only those 5 bytes 
0x5A 0x5A 0x08 0x00 0xF7


tpdd_read(2) means to read exactly 2 bytes

---

## launch with DEBUG=4 via environment variable so that it's already in 
effect even before the script gets a chance to parse the command line


bkw@fw:~$ DEBUG=4 pdd

## figure out the tty and set up the serial port settings
get_tpdd_port()
Using port "/dev/ttyUSB0"
open_com()
set_stty()
speed 19200 baud; rows 0; columns 0; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt 
= ^R;

werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 1;
-parenb -parodd -cmspar cs8 hupcl -cstopb cread clocal crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl 
-ixon -ixoff

-iuclc -ixany -imaxbel -iutf8
-opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 
vt0 ff0
-isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop 
-echoprt

echoctl echoke -flusho -extproc


## running just "pdd" with no commandline args tells  the script to 
present a prompt for interactive commands
## This prompt shows the state of the client, what mode the client is in 
and what it thinks the drive is in

## opr = TPDD1 in "operation mode"
## 6.2 = write and expect 6.2 filenames on the drive filename 
(Floppy/TS-DOS compatible)
## F = write and expect "F" for the attribute byte on the drive filename 
(Floppy/TS-DOS compatible)

##
## The command "rl 2 5" means:
## read logical - read a single logical sector
## physical sector 2 (counts from 0 to 79)
## logical sector 5 (counts from 1 to 1, up to 1 to 20, depending on the 
logical sector size, which is determined when the disk is formatted)
## The Sardine dictionary disk uses 128byte sectors, so for that disk, 
the valid values for logical sector are 1-10

##
## The script does some stuff automatically to put the drive into the 
necessary mode for the requested command, so although the command above 
is read-logical 2,5, it will do a bunch of other stuff first now


PDD(opr:6.2,F)> rl 2 5
do_cmd(rl 2 5)
_init()

## fonzie_smack is what I named a sort of joggle routine similar to what 
TS-DOS does on start-up.
## you basically never know what state the drive is in, yet, you always 
need to know that, and there is no really good way to query the drive 
"what state are you in?" nor is there a really good way to tell the 
drive "Whatever state you're in right now, reset and go into state foo"
## The closest is this A>B>A cycle that TS-DOS does where it blindly 
tells the drive to go to OPR mode, then to FDC mode, then back to OPR 
mode. Assuming the drive isn't locked up or in the middle of some 
transaction, then this usually leaves the drive in OPR mode.


fonzie_smack()
tpdd_drain()
tpdd_check()
tpdd_write(4D 31 0D)
tpdd_drain()
tpdd_check()
tpdd_write(5A 5A 08 00 F7)
tpdd_drain()
tpdd_check()
tpdd_write(4D 31 0D)
tpdd_drain()
tpdd_check()


## unk23 is what the old dlplus called "ts-dos mystery command"
## it's unknown what it *really* means, but it's a reliable way to tell 
the difference between TPDD1 and TPDD2  without locking up the drive by 
giving an invalid command to the wrong drive.
## when you issue a certain request, the real drive gives back this 
response, and it's always the same response for all TPDD1 drives.
## so if you issue the request and get the expected response, the drive 
is a TPDD1, otherwise it's a TPDD2, and in either case it doesn't lock 
up the drive.


ocmd_pdd2_unk23()
ocmd_send_req(23)
calc_cksum(23 00):DC
ocmd_send_req: fmt="23" len="00" dat="" chk="DC"
tpdd_write(5A 5A 23 00 DC)
ocmd_read_ret()
ocmd_read_ret: reading 2 bytes (fmt len)
tpdd_read(2)
tpdd_wait()
tpdd_check()
tpdd_check()
Detected TPDD1

## Now we've ensured the drive is in a known state and detected the type 
of drive, so we know we have a TPDD1 and it;s in OPR mode ready for a 
TPDD1 OPR command.

## start the read-logical command

fcmd_read_logical(2 5)

## firs step, since read-logical is an FDC command, switch the drive to 
FDC mode

ocmd_fdc()

## the command for FDC mode is 0x08
ocmd_send_req(08)

## the oxo8 command has no payload, so, payload length 0
## calculate the checksum for two bytes: 0x08 0x00
calc_cksum(08 00):F7

## assemble the tpdd packet from preamble to checksum and send it
## preamble is the same for all packats: 0x5A 0x5A  (aka "ZZ")

Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread majick
April 21, 2023 at 1:25 PM, "Stephen Adolph"  wrote:


> 
> I can't find a python source, only a python executable.  Is there a link to 
> the python source?  Thanks!
> 

You may mean that you can only find the .deb package, which is a binary 
installable package for Debian.  I reassembled the contents of the .deb into a 
tarball and put them herein my S3 bucket, back when Kurt released it:

http://public.nachomountain.com/files/m100/mComm-repackaged.tar.gz

That may make it easier for you to view the scripts.

Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
Actually I figured it out.  .Deb is an archive. I have the python code
now.  Cheers.

On Friday, April 21, 2023, Kurt McCullum  wrote:

> I'll send it your way when I get home tonight. It's in the Python code too
> so if you need it right away you can download that one. It's just the
> responses to read requests, but it will give you the general idea.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 11:18 AM, Stephen Adolph wrote:
>
> Thanks for the offer Kurt.
> I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?
>
> I could also just start writing code to see what works.
>
> ..steve
>
> On Friday, April 21, 2023, Kurt McCullum  wrote:
>
>
> Steve,
>
> The Sardine code in mComm has code for responding to the TPDD1 sectors. I
> also have some old C# code for a TPDD client that I used to make copies of
> some disks. At the time I wrote it I only had a TPDD2 (now sold) so it
> probably isn't what you are looking for, but I could send it your way.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
>
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
>
> Thanks
> Steve
>
>
>
>


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Kurt McCullum
The one in the members file area is a Debian Linux install. I can send the 
individual files later today if that would be easier.

Kurt

On Fri, Apr 21, 2023, at 1:25 PM, Stephen Adolph wrote:
> I can't find a python source, only a python executable.  Is there a link to 
> the python source?  Thanks!
> 
> On Friday, April 21, 2023, Kurt McCullum  wrote:
>> __
>> I'll send it your way when I get home tonight. It's in the Python code too 
>> so if you need it right away you can download that one. It's just the 
>> responses to read requests, but it will give you the general idea.
>> 
>> Kurt
>> 
>> On Fri, Apr 21, 2023, at 11:18 AM, Stephen Adolph wrote:
>>> Thanks for the offer Kurt.
>>> I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?
>>> 
>>> I could also just start writing code to see what works.  
>>> 
>>> ..steve
>>> 
>>> On Friday, April 21, 2023, Kurt McCullum  wrote:
 __
 Steve,
 
 The Sardine code in mComm has code for responding to the TPDD1 sectors. I 
 also have some old C# code for a TPDD client that I used to make copies of 
 some disks. At the time I wrote it I only had a TPDD2 (now sold) so it 
 probably isn't what you are looking for, but I could send it your way.
 
 Kurt
 
 On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
> 
> Thanks
> Steve
 
>> 


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread John R. Hogerhuis
Python is a script language... Programs only exist as source code.

-- John.


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
I can't find a python source, only a python executable.  Is there a link to
the python source?  Thanks!

On Friday, April 21, 2023, Kurt McCullum  wrote:

> I'll send it your way when I get home tonight. It's in the Python code too
> so if you need it right away you can download that one. It's just the
> responses to read requests, but it will give you the general idea.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 11:18 AM, Stephen Adolph wrote:
>
> Thanks for the offer Kurt.
> I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?
>
> I could also just start writing code to see what works.
>
> ..steve
>
> On Friday, April 21, 2023, Kurt McCullum  wrote:
>
>
> Steve,
>
> The Sardine code in mComm has code for responding to the TPDD1 sectors. I
> also have some old C# code for a TPDD client that I used to make copies of
> some disks. At the time I wrote it I only had a TPDD2 (now sold) so it
> probably isn't what you are looking for, but I could send it your way.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
>
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
>
> Thanks
> Steve
>
>
>
>


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
Thanks for the reminder and info Brian, I had forgotten that you had done
this.

I can take a look, thanks.

Steve

On Friday, April 21, 2023, Brian K. White  wrote:

> On 4/21/23 09:50, Stephen Adolph wrote:
>
>> Hi,
>> Does anyone know of an example of tpdd1 sector access code?
>> Thw software manual is ok but actual working code is better.
>>
>> Thanks
>> Steve
>>
>
> The software manual actually lays it all out.
>
> pdd.sh does client-side sector access for both tpdd1 and 2
> https://github.com/bkw777/pdd.sh
>
> dlplus does server-side sector access for both tpdd1 and 2
> https://github.com/bkw777/dlplus
>
> The bash code in pdd.sh is probably hard to read, so I am willing to
> explain it in some other posts or off-list.
>
> Or better yet, write up stuff in the discussions or wiki feature on github.
> like
> https://github.com/bkw777/dlplus/wiki
> or
> https://github.com/bkw777/dlplus/discussions
> That way the documentation that gets written up is still there for others
> later.
>
> enabling debug to higher levels essentially prints the bytes that go over
> the wire so you could then figure out your own way to do the same thing.
> But some of it is timing dependant and some of it involves rules where just
> looking a the traffic doesn't necessarily show what makes some things valid
> vs invalid.
>
> The real drive is a strict and crude state machine with practically no
> give or self-recovery. Once you do almost anything unexpected or illegal,
> it generally just locks up and the only fix is to power-cycle the drive, so
> it means that writing a reliable client involves being super careful to
> never go outside the lines in the first place, since there's no sort of
> reset or retrain command you can send from the client in a lot of cases.
>
> I'll send a separate post with an example and explaination of the sequence
> of a transaction.
>
> --
> bkw
>
>


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
Thank you.  The python is probably good.  I'll take a look!

On Friday, April 21, 2023, Kurt McCullum  wrote:

> I'll send it your way when I get home tonight. It's in the Python code too
> so if you need it right away you can download that one. It's just the
> responses to read requests, but it will give you the general idea.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 11:18 AM, Stephen Adolph wrote:
>
> Thanks for the offer Kurt.
> I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?
>
> I could also just start writing code to see what works.
>
> ..steve
>
> On Friday, April 21, 2023, Kurt McCullum  wrote:
>
>
> Steve,
>
> The Sardine code in mComm has code for responding to the TPDD1 sectors. I
> also have some old C# code for a TPDD client that I used to make copies of
> some disks. At the time I wrote it I only had a TPDD2 (now sold) so it
> probably isn't what you are looking for, but I could send it your way.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
>
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
>
> Thanks
> Steve
>
>
>
>


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Brian K. White

On 4/21/23 09:50, Stephen Adolph wrote:

Hi,
Does anyone know of an example of tpdd1 sector access code?
Thw software manual is ok but actual working code is better.

Thanks
Steve


The software manual actually lays it all out.

pdd.sh does client-side sector access for both tpdd1 and 2
https://github.com/bkw777/pdd.sh

dlplus does server-side sector access for both tpdd1 and 2
https://github.com/bkw777/dlplus

The bash code in pdd.sh is probably hard to read, so I am willing to 
explain it in some other posts or off-list.


Or better yet, write up stuff in the discussions or wiki feature on github.
like
https://github.com/bkw777/dlplus/wiki
or
https://github.com/bkw777/dlplus/discussions
That way the documentation that gets written up is still there for 
others later.


enabling debug to higher levels essentially prints the bytes that go 
over the wire so you could then figure out your own way to do the same 
thing. But some of it is timing dependant and some of it involves rules 
where just looking a the traffic doesn't necessarily show what makes 
some things valid vs invalid.


The real drive is a strict and crude state machine with practically no 
give or self-recovery. Once you do almost anything unexpected or 
illegal, it generally just locks up and the only fix is to power-cycle 
the drive, so it means that writing a reliable client involves being 
super careful to never go outside the lines in the first place, since 
there's no sort of reset or retrain command you can send from the client 
in a lot of cases.


I'll send a separate post with an example and explaination of the 
sequence of a transaction.


--
bkw



Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Kurt McCullum
I'll send it your way when I get home tonight. It's in the Python code too so 
if you need it right away you can download that one. It's just the responses to 
read requests, but it will give you the general idea.

Kurt

On Fri, Apr 21, 2023, at 11:18 AM, Stephen Adolph wrote:
> Thanks for the offer Kurt.
> I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?
> 
> I could also just start writing code to see what works.  
> 
> ..steve
> 
> On Friday, April 21, 2023, Kurt McCullum  wrote:
>> __
>> Steve,
>> 
>> The Sardine code in mComm has code for responding to the TPDD1 sectors. I 
>> also have some old C# code for a TPDD client that I used to make copies of 
>> some disks. At the time I wrote it I only had a TPDD2 (now sold) so it 
>> probably isn't what you are looking for, but I could send it your way.
>> 
>> Kurt
>> 
>> On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
>>> Hi,
>>> Does anyone know of an example of tpdd1 sector access code?
>>> Thw software manual is ok but actual working code is better.
>>> 
>>> Thanks
>>> Steve
>> 


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
Thanks for the offer Kurt.
I'm specifically after TPDD1 stuff, so that might mean mcomm sardine code?

I could also just start writing code to see what works.

..steve

On Friday, April 21, 2023, Kurt McCullum  wrote:

> Steve,
>
> The Sardine code in mComm has code for responding to the TPDD1 sectors. I
> also have some old C# code for a TPDD client that I used to make copies of
> some disks. At the time I wrote it I only had a TPDD2 (now sold) so it
> probably isn't what you are looking for, but I could send it your way.
>
> Kurt
>
> On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
>
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
>
> Thanks
> Steve
>
>
>


Re: [M100] Tpdd1 sector access example code?

2023-04-21 Thread Kurt McCullum
Steve,

The Sardine code in mComm has code for responding to the TPDD1 sectors. I also 
have some old C# code for a TPDD client that I used to make copies of some 
disks. At the time I wrote it I only had a TPDD2 (now sold) so it probably 
isn't what you are looking for, but I could send it your way.

Kurt

On Fri, Apr 21, 2023, at 6:50 AM, Stephen Adolph wrote:
> Hi,
> Does anyone know of an example of tpdd1 sector access code?
> Thw software manual is ok but actual working code is better.
> 
> Thanks
> Steve


[M100] Tpdd1 sector access example code?

2023-04-21 Thread Stephen Adolph
Hi,
Does anyone know of an example of tpdd1 sector access code?
Thw software manual is ok but actual working code is better.

Thanks
Steve