Jump to content
sparkdrummer

The Compact Computer 40 (CC40)

Recommended Posts

From Discord:

 

Quote

m5dk2nToday at 1:51 AM

The reason is that the whole file content is returned with the first INPUT. This is the desired behaviour to load a file with the OLD command but not for to INPUT a single 'record'. The hex_drv_read has to be extended/modified that both OLD/INPUT are working. We have to find out how much data to send for the actual read. Maybe @sreid1960 has an idea how to do it.(edited)

m5dk2nToday at 9:42 AM

A possible solution could be to add a header with the data length received in the hex_drv_write and prepend it to the data written on disk. So that we can send back exactly that amount of data when hex_drv_read is called. We would do this only for LUN!=0.

NEW

sreid1960Today at 5:00 PM

For programs such as given in the issue, where you are writing out numbers to a normal DISPLAY type file, ASCII data is written... a 1 is written as 20h 31h 20h (an ASCII 1 with a space character before and after). To write true numbers to a file, we had what is known as INTERNAL file format which wrote the data in native form to the file. When read back, the data could be read in native form as well. The Arduino side of the sketch has some internal format implementation, but its definitely not 100%. I can get the first number from a file in this format, but the EOF() test in my test program says I'm at EOF after the first read. The logic analyzer confirms that all the data was returned in the first read. If my memory is correct, there is a way using the VARIABLE option with open to specify the amount of data to read on each operation...

[5:00 PM]

however, different value numbers may take different amount of space.

JIm

Share this post


Link to post
Share on other sites

OK thanks for the update. I might be able to get it to work for numerical values using INTERNAL and a record length of 1. Let me play with this a bit more and see... As for DISPLAY type, there is also a workaround if the data is formatted with pre-defined separators and read back as a single string which can subsequently be sliced into individual values by the program with the understanding that the file could not exceed 255 characters. Ugly, but feasible...

Share this post


Link to post
Share on other sites

So I can get file ops to work with numerical values using the INTERNAL file mode and the VARIABLE x option, with x being the maximum length of the numerical values expected, including the decimal point (if dealing with floats).

For example, if I write a file with numbers for 1 to 10, then to read them I have to specify OPEN #1, "100.TEST",INPUT,INTERNAL,VARIABLE 2

Any value greater than 2 for this data set will yield a data error when read via INPUT #.

Same goes with string data, except here we will omit the INTERNAL specification.

Obviously not an ideal solution if you have unpredictable data element lengths, but should work in most common situations otherwise.

Share this post


Link to post
Share on other sites

If you can redo your app as a "test", I can put it in a tests directory, and we can use it to further develop the code.  LOAD/SAVE was the most important, but we can add additional functionality (I jsut need to understand how it should work).

 

An ideal test would be to open a file, clean it out, store a value or two there, close it, open it again, read the file data, and if the data is as expected, note success.  If not, not what was read versus what was expected.  I can then keep running it over and over until I can get the code to work correctly.

 

Jim

Share this post


Link to post
Share on other sites

Here you go:

 

10 PRINT "NUMERIC DATA TEST":PAUSE
20 PRINT "WRITING DATA":PAUSE 2
30 OPEN #1,"100.NUMTEST",OUTPUT,INTERNAL
35 FOR I=1 TO 10:PRINT #1,I:NEXT I:CLOSE #1
40 PRINT "READING DATA":PAUSE 2
50 OPEN #1,"100.NUMTEST",INPUT,INTERNAL
60 FOR I=1 TO 10:INPUT #1,N
70 IF N<>I THEN PRINT "READ ERROR!":PAUSE:CLOSE #1:STOP
80 NEXT I:CLOSE #1
90 PRINT "PASSED NUMERIC TEST!":PAUSE 2
100 PRINT "STRING DATA TEST":PAUSE
110 PRINT "WRITING DATA":PAUSE 2
120 OPEN #1,"100.STRTEST",OUTPUT
130 FOR V=65 TO 75:PRINT #1,CHR$(V):NEXT V:CLOSE #1
140 PRINT "READING DATA":PAUSE 2
150 OPEN #1,"100.STRTEST",INPUT
160 FOR I=1 TO 10:INPUT #1,S$
170 IF S$<>CHR$(64+I) THEN PRINT "READ ERROR!":PAUSE:CLOSE #1:STOP
180 NEXT I:CLOSE #1
190 PRINT "PASSED STRING TEST!":PAUSE 2
200 PRINT "FILE OPS SUCCESS!":PAUSE

 

  • Like 2

Share this post


Link to post
Share on other sites

I hate to ask, but is there any way I can get the stored copy of this program from your SD card? 🙂

 

Jim

Share this post


Link to post
Share on other sites

Hey Vorticon,

   Arcadeshopper is sending me one of these devices.

   I own a copy of: Data and File Management for the TI-99/4A by John P. Grillo

   I think file I/O is pretty much a new nugget to mine on the CC-40/TI-74 (though there might be some info, in old TI Calculator Newsletters, related to the Mechatronics Drive). Do you have any feel for how close the file I/O commands on the CC-40 to a 99/4a in BASIC?

 

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, dhe said:

Hey Vorticon,

   Arcadeshopper is sending me one of these devices.

   I own a copy of: Data and File Management for the TI-99/4A by John P. Grillo

   I think file I/O is pretty much a new nugget to mine on the CC-40/TI-74 (though there might be some info, in old TI Calculator Newsletters, related to the Mechatronics Drive). Do you have any feel for how close the file I/O commands on the CC-40 to a 99/4a in BASIC?

 

Practically identical with the exception of placing a colon instead of a comma before the list of parameters or variables. For example:

 

CC40: OPEN #1, "100.test", OUTPUT

TI 99/4A: OPEN #1: "DSK1.test", OUTPUT

 

CC40: PRINT #1, I

TI 99/4A: PRINT #1: I

 

So unless the program is using direct access to files via assembly language routines, it should be trivial to convert the file I/O from the TI to the CC40.

  • Thanks 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...