The case for the rehabilitation of RamTransfer
nemo (145) 2611 posts |
I have written at great length about the complexities of the Data Transfer Protocol; how it has never been implemented correctly; and how the later addition of That article dismisses To recap: I have argued that Crucial to that argument is this most important sentence from the DTP preamble in the PRMs:
Thus I argued that as
However it now occurs to me that a similar argument can be presented for This would mitigate much of the problems with the It would also allow a non-final Now although this interpretation is very attractive, But it’s not impossible, and the application of The Most Important Sentence to the I’m still of the opinion that RamTransfer is an irrelevant complexity and unnecessary burden on the programmer in the 21st Century, but rehabilitating these messages from badly-thought-out hack to first-class members of the Data Transfer Protocol is attractive. I’d be interested if anyone else cares. [I’m also of the opinion that the Type17/Type18 distinction regarding ongoing versus terminal |
Rick Murray (539) 13907 posts |
I got as far as the Filer and the unsafe flag. I think I’ll stop and go put the kettle on. I have a feeling it will need much tea and a pillow on my desk to make it through the rest of the document. Thank you so much for writing this. And I’m glad I wasn’t the only one confuddled with the your ref my ref bollocks. PS: I added drag to save to Tea (my Freesat programme guide) and after looking at the RAM Transfer stuff in the PRM and noting that it seemed to work perfectly well dragging to Zap using an intermediate file, I thought “sod it, too much bother for no useful gain”. Maybe if Econet, maybe if floppy discs, but that era is now referred to as a “classic music station” 1 so isn’t of much consequence these days… 1 Not “classical”, that’s something else. |
David J. Ruck (33) 1649 posts |
If you ever want even a hint of inter process security in RISC OS, the Wimp_TransferBlock SWI1 has to go, or to be severely restricted to only the addresses specified in the RAM transfer protocol. Luckily RAM transfer was always an optional part of the data save protocol, so could dropped altogether and everything should fall back to file transfer, which isn’t much slower now we have flash storage2. 1 That would result in a problem for other programs such as my WindOpen module which needs to read the text of icons, as for an indirected type the text lives in it’s application’s workspace, and Wimp_TransferBlock is currently the only way to read it. 2 It’s not like in the days of single floppy drive, when you had to dig out the disc with !Scrap on it for file based transfers to work. |
Rick Murray (539) 13907 posts |
Maybe this ought to be entitled “The case for the retirement of RamTransfer”?
This would also impact the ability to create accessibility software such as a screen reader. Perhaps the Wimp ought to have a way of reading the definition of an icon including the indirected data (pasted to the end of the block? 1) which would be less of a problem than furtling around in the memory of another application.
Security? RISC OS? <walks away giggling> 1 There’re actually two bits of data, there’s the indirected icon text, and there’s the validation string, so it might be a two part process, like call once to get the amount of memory to allocate and call again to actually read. If the Wimp is being helpful, it’ll set two registers to directly point to the start of each part so one doesn’t have to mess around to work out where one finishes and the other begins. |
nemo (145) 2611 posts |
Druck ventured
Hence BlockTransfer However,
Which is a point made in the article.
There’s an interesting point to be made here, and I have a nearly-complete module for the purpose – reading the text of an icon is less straightforward than you would think. RO5 provides Wimp_Extend,14 to read the Validation string (which is a partial solution for that problem space) but no similar call for the text buffer – presumably because they think that’s easier, when in fact it’s harder. And if you think an indirected icon tells you how long the text buffer is, you’ve seriously misunderstood icons. That last word is not the length of the buffer, it’s the maximum number of bytes that can be inserted into writeables. It has absolutely no effect on the display of icons, and hence the length of the buffer contents. Reading the text of an icon is therefore the same problem as reading the validation – except you also have to deal with the unterminated unindirected case. Nobody ever gets anything right. Also, whereas an author might use the max field to store their text buffer length (and then again they might not), there’s certainly nowhere to store the length of the validation string buffer, so a technique employed for mutable validations is to pad the validation string, either by semicolons or semicolon-then-spaces. The aforementioned module allows read and write of icon text and validation by using these various methods. Not that the model works in the presence of |
Jean-Michel BRUCK (3009) 369 posts |
Some time ago I started Copy and Paste, I needed it for the !PariGp editor. This one uses two TextAreas. This was not easy. Using this information I built a flowchart, which represents events and the program to test with 2 TextArea. This is a good basis to use and test the protocol and my PariGp application works, but not on a RPi, I have to fix…:-( If it can be useful, the program, its source, the flowcharts, be indulgent:-) |
Matthew Phillips (473) 722 posts |
Not surprising people think it’s the buffer length when PRM 3-101 says it’s the buffer length. So you are saying that RISC OS does not check the buffer length when displaying the contents of the buffer in the icon, but does prevent the user adding more characters to the icon if the length of the text exceeds the declared buffer length (less one for the terminator?)? So you could have a situation where the writable has 40 characters displayed, but a “buffer length” of 20, and the user will find they cannot type anything into the buffer unless they delete 22 characters first. I wonder how many application authors have actually relied on this quirk? |
Rick Murray (539) 13907 posts |
None, I hope, as…
…it is documented as being the buffer length. ;) But as was pointed out, there can be two buffers (icon text, validation string) and only one has a buffer length provided (even if it isn’t really a buffer length, sigh). Lesson kiddies: The importance of accurate documentation. |
Matthew Phillips (473) 722 posts |
I’d just like to record my gratitude to Nemo for a very interesting read. I got right to the end, understood it all (I think) and did not actually swear at any point. I’m not sure I agree about the most important sentence. I think that the person writing that was just saying “look how nice the protocol is: you don’t have to do very much to construct your replies”. You have not considered the word “can” in the article. That implies it’s optional to some extent. I completely agree that without that interpretation, the DataSaved message description is incomplete and less magical than it should be. I think your interpretation is stretching it a bit. The most important sentence is part of a paragraph on PRM 3-252 (printed 1992 edition) which starts “The messages used in the above descriptions are described below.” but the above descriptions do not include DataSaved. So I think that the most important sentence probably was not intended to apply to that message. I agree that implementing it the way you have done would give an extremely nice effect. You won’t therefore be surprised when I say that in my view the most important sentence cannot possibly apply to Message_RAMFetch. The structure of the message is, in any case, just too far different from the core DTP. I really enjoyed all the nooks and crannies of RISC OS your have explored and the historical perspective. The way poor documentation builds up to the car crash of the clipboard is most unexpected, and the prize at the end was excellent! I am going to have to go and look at my applications again and make sure I improve them. I’ll try and add a few comments here later, as I have found some interesting features at times because of how other applications implement the DTP. Ovation Pro and Impression come to mind. |
Alan Williams (2601) 91 posts |
Well that was a very enlightening read! I remember it being very normal to read the doc, conclude it made little sense and hack stuff about until it appeared to work. It also reminds me of trying to write a filecore filing system that supported removable media. The documentation I remember was confusing to say the least about who was who in the contract. Despite the section being labeled writing a driver, I eventually got an email saying yes actually we documented the filecore point of view. |
nemo (145) 2611 posts |
Matthew complained
Repeat after me: “The PRMs were written by mere mortals and are not the irrefutable word of a Deity”. They also used to be regularly corrected with an Errata. Those were the days. Anyway, the so-called “buffer length” only applies to text editing of writables. And these days is only part of the decision as to whether something can be inserted into the buffer – the
Yes. If the ClickType is not 14/15 Writable (and the cursor hasn’t been inserted by other means) that final field is simply not consulted. And, after 35 years now, cannot be.
Every app whose indirected display icons don’t have a sensible value? Can’t be changed now.
That’s a cyclic argument. If viewed as a delta of the DataSave that it is a reply to, then the only fields that are changed are the Handle and Icon/Ref (which are, thanks to the various other protocols that end up becoming these messages, not necessarily window and icon anyway). So the documentation is entirely consistent with the only-change-what-you-need-to design that is explicitly defined in the Most Important Sentence. And I suggest now that the MIS should probably apply to the RAMFetch messages not because I want it to (I want those messages to die) but because I can’t find any logical reason to exclude them. The MIS is not restricted to specific messages but to the whole DTP. That does include the RAMFetches and, as of RO3, DataSaved too. Put it this way (and this is always a useful tool) imagine the opposite – imagine that DataSaved, RamFetch and RamTransmit had been fully documented from day 1 as being fully-fledged DTP messages… would you now be arguing that they ought not to be? No, you absolutely would not. And in particular, both RAMTransmit and DataSaved are rendered valuable and useful by virtue of the other DTP fields (beyond what their subsection documents, which are only the changed fields) – as they include the filetype, filename and unsafe flag from the original message. Without those fields, the messages are rendered much less useful (DataSaved becomes meaningless) and the apps at both ends are forced to cache the rest of the DTP fields because they will be needed when the RAMTransmit or DataSaved is received. It’s painfully obvious they were intended to be there in the first place because of this. [Edit: To clarify the DataSaved point – if you receive a DataSaved without filetype, you have no way of knowing whether your data has been saved – eg if you are a Word Processor and the remote task saves a Plain Text version, then the DataSaved should not result in your document becoming ‘unmodified’, as the remote task has thrown important context away. And the ability to take on the filename under which the data has been saved seems like a most important point]
Wonderful. I keep promising to complete a test harness that would probe every detail of a task’s implementation of the DTP and give a score out of 100… but I suspect nothing would get higher than 15! Getting the messages the correct length without extra junk on the end or omitting fields; with the correct reference; and dealing with bounces correctly is 90% of the job. Actually handling message refs the way that DataSaved requires is the icing on the cake. It’s a lot of faff. But being able to save a file from this app and have the document in that app become ‘unmodified’ and adopt the new filename really is magical – no other OS does that and we really should have worked harder to implement it everywhere in 1991. |