Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.sys.apple2.programmer > #3253 > unrolled thread

Uthernet II manual - sample code

Started byChris Torrence <gorthmog@gmail.com>
First post2017-02-05 14:16 -0800
Last post2017-02-27 09:58 -0800
Articles 15 — 4 participants

Back to article view | Back to comp.sys.apple2.programmer


Contents

  Uthernet II manual - sample code Chris Torrence <gorthmog@gmail.com> - 2017-02-05 14:16 -0800
    Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-06 03:41 +0000
      Re: Uthernet II manual - sample code Oliver Schmidt <ol.sc@web.de> - 2017-02-06 10:20 +0000
    Re: Uthernet II manual - sample code Oliver Schmidt <ol.sc@web.de> - 2017-02-06 10:28 +0000
      Re: Uthernet II manual - sample code Chris Torrence <gorthmog@gmail.com> - 2017-02-06 17:20 -0800
        Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-07 02:59 +0000
          Re: Uthernet II manual - sample code "Mark D. Overholser" <marko@markoverholser.com> - 2017-02-07 10:33 -0800
            Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-07 21:42 +0000
    Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-12 20:49 +0000
      Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-25 23:29 +0000
        Re: Uthernet II manual - sample code "Mark D. Overholser" <marko@markoverholser.com> - 2017-02-25 21:12 -0800
          Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-26 20:03 +0000
            Re: Uthernet II manual - sample code "Mark D. Overholser" <marko@markoverholser.com> - 2017-02-26 16:26 -0800
              Re: Uthernet II manual - sample code D Finnigan <dog_cow@macgui.com> - 2017-02-27 01:38 +0000
                Re: Uthernet II manual - sample code "Mark D. Overholser" <marko@markoverholser.com> - 2017-02-27 09:58 -0800

#3253 — Uthernet II manual - sample code

FromChris Torrence <gorthmog@gmail.com>
Date2017-02-05 14:16 -0800
SubjectUthernet II manual - sample code
Message-ID<878838ba-6367-4afb-b045-0b6bdb53ec65@googlegroups.com>
Hi all,

I've been working my way through the Uthernet II manual (which is excellent by the way!) and I've encountered a couple of minor bugs with the TCP socket demo code.

In the RXWRAP code, around line 403, it does a DEC ]UPPERSIZE+1, which is the high byte of the number of bytes before the end of the W5100 buffer. It then does a BNE to continue reading the data. However, this gives an off-by-one error: if we have more than 255 bytes we'll decrement to $00, not take the branch, and never read those last 256 bytes. Worse, if the high byte is $00 (i.e. we started out with <256 bytes), then this will wrap around to $FF and erroneously read 255 pages of garbage from the W5100.

The same thing happens in the next block of code where we are reading the rest of the buffer after we've wrapped around. Again, there is a DEC ]UPPERSIZE+1 followed by a BNE.

An easy fix is to do an INC ]UPPERSIZE+1 before we start each of those loops. For example, right after the PHA on line 390, and right after the STA on line 434. I did some tests using a simple netcat (nc -l 20000) and it now works much better and doesn't spew garbage when it wraps.

However, I'm wondering whether the code could be made simpler by completely eliminating the RXWRAP section? Instead, if you notice that you are going to wrap, instead just decrease the number of bytes (GETSIZE/GETSIZE+1) to exactly reach the end, and then just use the regular "no-wrap" code. The next time around the code will notice that there are still bytes remaining to be read, and will just do the normal thing and read them.

I've prototyped the code, and it seems to work fine, but I'm wondering whether anyone (David Finnigan?) sees anything wrong with this approach?

Thanks in advance,
Chris

[toc] | [next] | [standalone]


#3254

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-06 03:41 +0000
Message-ID<dog_cow-1486352616@macgui.com>
In reply to#3253
Chris Torrence wrote:
> Hi all,
> 
> I've been working my way through the Uthernet II manual (which is
> excellent
> by the way!) and I've encountered a couple of minor bugs with the TCP
> socket demo code.
> 

"Fixing bugs in the sample code is an exercise left to the reader."

:-D

Seriously though, thanks for testing the code and reporting what you've
found. I'll be sure to update the manual as soon as I can.

> 
> I've prototyped the code, and it seems to work fine, but I'm wondering
> whether anyone (David Finnigan?) sees anything wrong with this approach?

It's probably good. And since you've tested it, I believe you. The next
approach I found was to take advantage of address wraparound inherent in the
W5100's address space. This technique is documented in a thread somewhere in
this newsgroup.

Finally, I also advise looking at Oliver Schmidt's driver for the W5100 (if
you haven't yet). He has some more technical documentation that isn't in the
manual.

Further reading:
https://github.com/a2retrosystems/uthernet2
https://github.com/a2retrosystems/uthernet2/wiki
https://github.com/burniouf/A2osX/tree/master/DRV
https://github.com/oliverschmidt/ip65/blob/master/drivers/w5100.s

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3255

FromOliver Schmidt <ol.sc@web.de>
Date2017-02-06 10:20 +0000
Message-ID<o79im8$de0$1@news.albasani.net>
In reply to#3254
Hi David,

> The next
> approach I found was to take advantage of address wraparound inherent in the
> W5100's address space. This technique is documented in a thread somewhere in
> this newsgroup.

... and it's mentioned in my Wiki you linked to:

"The pointer auto-increment does a wraparound operation at the end of the
two 8kB memory buffers to their begin. Please note that the pointer
auto-increment does not take care of memory buffer assignment to several
sockets!"

> Finally, I also advise looking at Oliver Schmidt's driver for the W5100 (if
> you haven't yet). 

:-)

Regards,
Oliver

[toc] | [prev] | [next] | [standalone]


#3256

FromOliver Schmidt <ol.sc@web.de>
Date2017-02-06 10:28 +0000
Message-ID<o79j3j$dsm$1@news.albasani.net>
In reply to#3253
Hi Chris,

> [...] to exactly reach the end, and then just use the regular "no-wrap" code. [...]

My driver uses recursion to archive this: After detecting a wrap it jsr at
https://github.com/oliverschmidt/ip65/blob/master/drivers/w5100.s#L471 into
a code block to transmit up to the end that it falls into later to either
transmit the rest (or just everything in the "no-wrap" case).

Regards,
Oliver

[toc] | [prev] | [next] | [standalone]


#3260

FromChris Torrence <gorthmog@gmail.com>
Date2017-02-06 17:20 -0800
Message-ID<52456f9a-dfac-4c2b-adbf-e459915ededd@googlegroups.com>
In reply to#3256
Okay, so I made the code even smaller by just letting the W5100 handle the wraparound automatically. It worked like a charm. I'll paste in my sample code here, and also email it to DF in case you want to include some of it in the next manual update. Thanks for the help!
-Chris

                1    * TCP SOCKET DEMO FOR W5100/UTHERNET II
                2    * BY D. FINNIGAN
                3    * OCTOBER 2015
                4    *
                5    * UPDATE 09 JAN 2016
                6    *
                7    * UPDATE 05 FEB 2017, C. TORRENCE
                8    *  -REMOVED SEPARATE PATH FOR WRAP, ADD DEBUG PRINT
                9    *
                10   *
                11   * SLOT 3 I/O ADDRESSES FOR THE W5100
                12   *
                13   WMODE    EQU   $C0B4      
                14   WADRH    EQU   $C0B5      
                15   WADRL    EQU   $C0B6      
                16   WDATA    EQU   $C0B7      
                17   *
                18   *
                19   * W5100 LOCATIONS
                20   *
                21   MACADDR  EQU   $0009      ; MAC ADDRESS
                22   SRCIP    EQU   $000F      ; SOURCE IP ADDRESS
                23   RMSR     EQU   $001A      ; RECEIVE BUFFER SIZE
                24   *
                25   * SOCKET 0 LOCATIONS
                26   *
                27   S0MR     EQU   $0400      ; SOCKET 0 MODE REGISTER
                28   S0CR     EQU   $0401      ; COMMAND REGISTER
                29   S0IR     EQU   $0402      ; INTERRUPT REGISTER
                30   S0SR     EQU   $0403      ; STATUS REGISTER
                31   S0LOCALPORT EQU $0404     ; LOCAL PORT
                32   S0FORADDR EQU  $040C      ; FOREIGN ADDRESS
                33   S0FORPORT EQU  $0410      ; FOREIGN PORT
                34   S0MSS    EQU   $0412      ; MAX SEGMENT SIZE
                35   S0PROTO  EQU   $0414      ; IP PROTOCOL
                36   S0TOS    EQU   $0415      ; DS/ECN (FORMER TOS)
                37   S0TTL    EQU   $0416      ; IP TIME TO LIVE
                38   S0TXFSR  EQU   $0420      ; TX FREE SIZE REGISTER
                39   S0TXRR   EQU   $0422      ; TX READ POINTER REGISTER
                40   S0TXWR   EQU   $0424      ; TX WRITE POINTER REGISTER
                41   S0RXRSR  EQU   $0426      ; RX RECEIVED SIZE REGISTER
                42   S0RXRD   EQU   $0428      ; RX READ POINTER REGISTER
                43   *
                44   * SOCKET 0 PARAMETERS
                45   *
                46   RXBASE   EQU   $6000      ; SOCKET 0 RX BASE ADDR
                47   RXMASK   EQU   $1FFF      ; SOCKET 0 8KB ADDRESS MASK
                48   TXBASE   EQU   $4000      ; SOCKET 0 TX BASE ADDR
                49   TXMASK   EQU   RXMASK     ; SOCKET 0 TX MASK
                50   *
                51   *
                52   * SOCKET COMMANDS
                53   *
                54   SCOPEN   EQU   $01        ; OPEN
                55   SCLISTEN EQU   $02        ; LISTEN
                56   SCCONNECT EQU  $04        ; CONNECT
                57   SCDISCON EQU   $08        ; DISCONNECT
                58   SCCLOSE  EQU   $10        ; CLOSE
                59   SCSEND   EQU   $20        ; SEND
                60   SCSENDMAC EQU  $21        ; SEND MAC
                61   SCSENDKEEP EQU $22        ; SEND KEEP ALIVE
                62   SCRECV   EQU   $40        ; RECV
                63   *
                64   * SOCKET STATUS
                65   *
                66   STCLOSED EQU   $00        
                67   STINIT   EQU   $13        
                68   STLISTEN EQU   $14        
                69   STESTABLISHED EQU $17     
                70   STCLOSEWAIT EQU $1C       
                71   STUDP    EQU   $22        
                72   STIPRAW  EQU   $32        
                73   STMAXRAW EQU   $42        
                74   STPPOE   EQU   $5F        
                75   *
                76   * MONITOR SUBROUTINES
                77   *
                78   KBD      EQU   $C000      
                79   KBDSTRB  EQU   $C010      
                80   COUT     EQU   $FDED      
                81   PRBYTE   EQU   $FDDA      
                82   PRNTAX   EQU   $F941      
                83   *
                84   * ZERO-PAGE STORAGE
                85   *
                86   PTR      EQU   $06        ; 2 BYTES FOR APPLE BUFFER
                87   GETSIZE  EQU   $08        ; 2 BYTES FOR RX_RSR
                88   GETOFFSET EQU  $0A        ; 2 BYTES FOR OFFSET ADDR
                89   GETSTARTADR EQU $0C       ; 2 BYTES FOR PHYSICAL ADDR
                90   *
                91   *
                92   * RESET AND CONFIGURE W5100
                93   *
                94   *
8000: A9 06     95            LDA   #6         
8002: 85 06     96            STA   PTR        ; RETRIES
                97   RESET                     
8004: A9 80     98            LDA   #$80       ; RESET
8006: 8D B4 C0  99            STA   WMODE      
8009: A9 03     100           LDA   #3         ; CONFIGURE WITH AUTO-INCREMENT
800B: 8D B4 C0  101           STA   WMODE      
                102  *
                103  * ASSIGN MAC ADDRESS
                104  *
800E: A9 00     105           LDA   #>MACADDR  
8010: 8D B5 C0  106           STA   WADRH      
8013: A9 09     107           LDA   #<MACADDR  
8015: 8D B6 C0  108           STA   WADRL      
8018: A2 00     109           LDX   #0         
801A: BD 28 80  110  :L       LDA   MAC,X      
801D: 8D B7 C0  111           STA   WDATA      ; USING AUTO-INCREMENT
8020: E8        112           INX              
8021: E0 06     113           CPX   #6         ; COMPLETED?
8023: D0 F5     114           BNE   :L         
8025: 4C 2E 80  115           JMP   SETSRCADDR 
                116  *
8028: 00 08 DC  117  MAC      HEX   0008DC010203 ; MAC ADDRESS
802B: 01 02 03 
                118  *
                119  *
                120  * ASSIGN A SOURCE IP ADDRESS
                121  *
                122  SETSRCADDR                
802E: A9 0F     123           LDA   #<SRCIP    
8030: 8D B6 C0  124           STA   WADRL      
8033: A2 00     125           LDX   #0         
8035: BD 43 80  126  :L       LDA   SRCADDR,X  
8038: 8D B7 C0  127           STA   WDATA      
803B: E8        128           INX              
803C: E0 04     129           CPX   #4         
803E: D0 F5     130           BNE   :L         
8040: 4C 47 80  131           JMP   SETBUFFERS 
                132  *
8043: 0A 00 01  133  SRCADDR  HEX   0A0001FC   ; 10.0.1.252
8046: FC 
                134  *
                135  *
                136  * CONFIGURE BUFFER SIZES
                137  *
                138  SETBUFFERS                
8047: A9 1A     139           LDA   #<RMSR     
8049: 8D B6 C0  140           STA   WADRL      
804C: A9 03     141           LDA   #3         ; 8KB TO SOCKET 0
804E: 8D B7 C0  142           STA   WDATA      ; SET RECEIVE BUFFER
8051: 8D B7 C0  143           STA   WDATA      ; SET TRANSMIT BUFFER
                144  *
                145  * CONFIGURE SOCKET 0 FOR TCP
                146  *
8054: A9 04     147           LDA   #>S0MR     
8056: 8D B5 C0  148           STA   WADRH      
8059: A9 00     149           LDA   #<S0MR     
805B: 8D B6 C0  150           STA   WADRL      
805E: A9 01     151           LDA   #1         ; TCP MODE
8060: 8D B7 C0  152           STA   WDATA      
                153  *
                154  * SET LOCAL PORT NUMBER
                155  *
8063: A9 04     156           LDA   #<S0LOCALPORT 
8065: 8D B6 C0  157           STA   WADRL      
8068: A9 C0     158           LDA   #$C0       ; HIGH BYTE OF LOCAL PORT
806A: 8D B7 C0  159           STA   WDATA      
806D: A9 00     160           LDA   #0         ; LOW BYTE
806F: 8D B7 C0  161           STA   WDATA      
                162  *
                163  * SET FOREIGN ADDRESS
                164  *
8072: A9 0C     165           LDA   #<S0FORADDR 
8074: 8D B6 C0  166           STA   WADRL      
8077: A2 00     167           LDX   #0         
8079: BD 87 80  168  :L2      LDA   FADDR,X    
807C: 8D B7 C0  169           STA   WDATA      
807F: E8        170           INX              
8080: E0 04     171           CPX   #4         
8082: D0 F5     172           BNE   :L2        
8084: 4C 8B 80  173           JMP   SETFORPORT 
                174  *
8087: 0A 00 01  175  FADDR    HEX   0A000111   ; 10.0.1.17
808A: 11 
                176  *
                177  *
                178  * SET FOREIGN PORT
                179  *
                180  SETFORPORT                
808B: A9 4E     181           LDA   #$4E       ; HIGH BYTE OF FOREIGN PORT
808D: 8D B7 C0  182           STA   WDATA      ; ADDR PTR IS AT FOREIGN PORT
8090: A9 20     183           LDA   #$20       ; LOW BYTE OF PORT
8092: 8D B7 C0  184           STA   WDATA      
                185  *
                186  * OPEN SOCKET
                187  *
8095: A9 01     188           LDA   #<S0CR     
8097: 8D B6 C0  189           STA   WADRL      
809A: A9 01     190           LDA   #SCOPEN    ; OPEN COMMAND
809C: 8D B7 C0  191           STA   WDATA      
                192  *
                193  * CHECK STATUS REGISTER TO SEE IF SUCCEEDED
                194  *
809F: A9 03     195           LDA   #<S0SR     
80A1: 8D B6 C0  196           STA   WADRL      
80A4: AD B7 C0  197           LDA   WDATA      
80A7: C9 13     198           CMP   #STINIT    ; IS IT SOCK_INIT?
80A9: F0 33     199           BEQ   OPENED     
80AB: A0 00     200           LDY   #0         
80AD: B9 B9 80  201  :L       LDA   :SOCKERR,Y 
80B0: F0 06     202           BEQ   :LDONE     
80B2: 20 ED FD  203           JSR   COUT       
80B5: C8        204           INY              
80B6: D0 F5     205           BNE   :L         
80B8: 00        206  :LDONE   BRK              
80B9: D5 D4 C8  207  :SOCKERR ASC   "UTHERNET II: COULD NOT OPEN SOCKET!" 
80BC: C5 D2 CE C5 
80C0: D4 A0 C9 C9 
80C4: BA A0 C3 CF 
80C8: D5 CC C4 A0 
80CC: CE CF D4 A0 
80D0: CF D0 C5 CE 
80D4: A0 D3 CF C3 
80D8: CB C5 D4 A1 
80DC: 8D 00     208           HEX   8D00       ; CR+NULL
                209  *
                210  * TCP SOCKET WAITING FOR NEXT COMMAND
                211  *
                212  OPENED                    
80DE: A9 01     213           LDA   #<S0CR     
80E0: 8D B6 C0  214           STA   WADRL      
80E3: A9 04     215           LDA   #SCCONNECT 
80E5: 8D B7 C0  216           STA   WDATA      
                217  *
                218  * WAIT FOR TCP TO CONNECT AND BECOME ESTABLISHED
                219  *
                220  CHECKTEST                 
80E8: A9 03     221           LDA   #<S0SR     
80EA: 8D B6 C0  222           STA   WADRL      
80ED: AD B7 C0  223           LDA   WDATA      ; GET SOCKET STATUS
80F0: F0 06     224           BEQ   FAILED     ; 0 = SOCKET CLOSED, ERROR
80F2: C9 17     225           CMP   #STESTABLISHED 
80F4: F0 4A     226           BEQ   CHECKRECV  ; SUCCESS
80F6: D0 F0     227           BNE   CHECKTEST  
                228  *
                229  FAILED                    
80F8: C6 06     230           DEC   PTR        
80FA: F0 08     231           BEQ   ERRDONE    ; TOO MANY FAILURES
80FC: A9 AE     232           LDA   #"."       
80FE: 20 ED FD  233           JSR   COUT       
8101: 4C 04 80  234           JMP   RESET      ; TRY AGAIN
                235  *
                236  ERRDONE                   
8104: A0 00     237           LDY   #0         
8106: B9 12 81  238  :L       LDA   ERRMSG,Y   
8109: F0 06     239           BEQ   :DONE      
810B: 20 ED FD  240           JSR   COUT       
810E: C8        241           INY              
810F: D0 F5     242           BNE   :L         
8111: 00        243  :DONE    BRK              
                244  *
8112: D3 CF C3  245  ERRMSG   ASC   "SOCKET COULD NOT CONNECT - CHECK REMOTE HOST" 
8115: CB C5 D4 A0 
8119: C3 CF D5 CC 
811D: C4 A0 CE CF 
8121: D4 A0 C3 CF 
8125: CE CE C5 C3 
8129: D4 A0 AD A0 
812D: C3 C8 C5 C3 
8131: CB A0 D2 C5 
8135: CD CF D4 C5 
8139: A0 C8 CF D3 
813D: D4 
813E: 8D 00     246           HEX   8D00       
                247  *
                248  *
                249  * CHECK FOR ANY RECEIVED DATA
                250  *
                251  CHECKRECV                 
8140: 2C 00 C0  252           BIT   KBD        ; KEYPRESS?
8143: 10 06     253           BPL   :NEXT      
8145: AD 10 C0  254           LDA   KBDSTRB    
8148: 4C FB 81  255           JMP   CLOSECONN  ; CLOSE CONNECTION
                256  :NEXT                     
814B: A9 26     257           LDA   #<S0RXRSR  ; S0 RECEIVED SIZE REGISTER
814D: 8D B6 C0  258           STA   WADRL      
8150: AD B7 C0  259           LDA   WDATA      ; HIGH BYTE OF RECEIVED SIZE
8153: 0D B7 C0  260           ORA   WDATA      ; LOW BYTE
8156: F0 03     261           BEQ   NORECV     ; NO DATA TO READ
8158: 4C 60 81  262           JMP   RECV       ; THERE IS DATA
                263  *
                264  NORECV                    
815B: EA        265           NOP              ; LITTLE DELAY...
815C: EA        266           NOP              
815D: 4C 40 81  267           JMP   CHECKRECV  ; CHECK AGAIN
                268  *
                269  * THERE IS DATA TO READ - COMPUTE THE PHYSICAL ADDRESS
                270  *
                271  RECV                      
8160: A9 26     272           LDA   #<S0RXRSR  ; GET RECEIVED SIZE AGAIN
8162: 8D B6 C0  273           STA   WADRL      
8165: AD B7 C0  274           LDA   WDATA      
8168: 85 09     275           STA   GETSIZE+1  ; HIGH BYTE
816A: AD B7 C0  276           LDA   WDATA      
816D: 85 08     277           STA   GETSIZE    ; LOW BYTE
                278  *
                279  * CALCULATE OFFSET ADDRESS USING READ POINTER AND RX MASK
                280  *
816F: A9 28     281           LDA   #<S0RXRD   
8171: 8D B6 C0  282           STA   WADRL      
8174: AD B7 C0  283           LDA   WDATA      ; HIGH BYTE
8177: 29 1F     284           AND   #>RXMASK   
8179: 85 0B     285           STA   GETOFFSET+1 
817B: AD B7 C0  286           LDA   WDATA      ; LOW BYTE
817E: 29 FF     287           AND   #<RXMASK   
8180: 85 0A     288           STA   GETOFFSET  
                289  *
                290  * CALCULATE PHYSICAL ADDRESS WITHIN W5100 RX BUFFER
                291  *
8182: 18        292           CLC              
8183: A5 0A     293           LDA   GETOFFSET  
8185: 69 00     294           ADC   #<RXBASE   
8187: 85 0C     295           STA   GETSTARTADR 
8189: A5 0B     296           LDA   GETOFFSET+1 
818B: 69 60     297           ADC   #>RXBASE   
818D: 85 0D     298           STA   GETSTARTADR+1 
                299  *
                300  * SET BUFFER ADDRESS ON APPLE
                301  *
818F: A9 00     302           LDA   #0         ; LOW BYTE OF BUFFER
8191: 85 06     303           STA   PTR        
8193: A9 50     304           LDA   #$50       ; HIGH BYTE
8195: 85 07     305           STA   PTR+1      
                306  *
                307  * SET BUFFER ADDRESS ON W5100
                308  *
                309  * JSR   DEBUG   ; UNCOMMENT FOR W5100 DEBUG INFO
8197: A5 0D     310           LDA   GETSTARTADR+1 ; HIGH BYTE FIRST
8199: 8D B5 C0  311           STA   WADRH      
819C: A5 0C     312           LDA   GETSTARTADR 
819E: 8D B6 C0  313           STA   WADRL      
                314  *
                315  * BEGIN COPY
                316  *
81A1: A0 00     317           LDY   #0         
81A3: A6 09     318           LDX   GETSIZE+1  
81A5: F0 10     319           BEQ   :LAST      ; LESS THAN 256 BYTES
81A7: AD B7 C0  320  :L       LDA   WDATA      
81AA: 91 06     321           STA   (PTR),Y    
                322  *
81AC: 20 1D 82  323           JSR   CLEANOUT   ; DEBUG PRINT
                324  *
81AF: C8        325           INY              
81B0: D0 F5     326           BNE   :L         
81B2: E6 07     327           INC   PTR+1      ; Y WRAPPED TO 0, GO TO NEXT PAGE
81B4: CA        328           DEX              
81B5: D0 F0     329           BNE   :L         
                330  :LAST                     
81B7: A6 08     331           LDX   GETSIZE    
81B9: AD B7 C0  332  :L2      LDA   WDATA      
81BC: 91 06     333           STA   (PTR),Y    
                334  *
81BE: 20 1D 82  335           JSR   CLEANOUT   ; DEBUG PRINT
                336  *
81C1: C8        337           INY              
81C2: CA        338           DEX              
81C3: D0 F4     339           BNE   :L2        
                340  *
81C5: A9 8D     341           LDA   #$8D       ; <CR>
81C7: 20 ED FD  342           JSR   COUT       ; DEBUG PRINT
                343  *
                344  *
                345  * UPDATE RXRD TO REFLECT DATA WE JUST READ
                346  *
                347  UPDATERXRD                
81CA: 18        348           CLC              
81CB: A9 04     349           LDA   #>S0RXRD   ; NEED HIGH BYTE HERE
81CD: 8D B5 C0  350           STA   WADRH      
81D0: A9 28     351           LDA   #<S0RXRD   
81D2: 8D B6 C0  352           STA   WADRL      
81D5: AD B7 C0  353           LDA   WDATA      ; HIGH BYTE
81D8: A8        354           TAY              ; SAVE
81D9: AD B7 C0  355           LDA   WDATA      ; LOW BYTE
81DC: 65 08     356           ADC   GETSIZE    ; ADD LOW BYTE OF RECEIVED SIZE
81DE: AA        357           TAX              ; SAVE
81DF: 98        358           TYA              ; GET HIGH BYTE BACK
81E0: 65 09     359           ADC   GETSIZE+1  ; ADD HIGH BYTE OF RECEIVED SIZE _
81E2: A8        360           TAY              ; SAVE
81E3: A9 28     361           LDA   #<S0RXRD   
81E5: 8D B6 C0  362           STA   WADRL      
81E8: 8C B7 C0  363           STY   WDATA      ; SEND HIGH BYTE
81EB: 8E B7 C0  364           STX   WDATA      ; SEND LOW BYTE
                365  *
                366  * SEND THE RECV COMMAND
                367  *
81EE: A9 01     368           LDA   #<S0CR     
81F0: 8D B6 C0  369           STA   WADRL      
81F3: A9 40     370           LDA   #SCRECV    
81F5: 8D B7 C0  371           STA   WDATA      
                372  *
                373  *
                374  *
81F8: 4C 40 81  375           JMP   CHECKRECV  
                376  *
                377  *
                378  * CLOSE TCP CONNECTION
                379  *
                380  CLOSECONN                 
81FB: A9 04     381           LDA   #>S0CR     ; HIGH BYTE NEEDED
81FD: 8D B5 C0  382           STA   WADRH      
8200: A9 01     383           LDA   #<S0CR     
8202: 8D B6 C0  384           STA   WADRL      
8205: A9 08     385           LDA   #SCDISCON  ; DISCONNECT
8207: 8D B7 C0  386           STA   WDATA      ; SEND COMMAND
                387  *
                388  * CHECK FOR CLOSED STATUS
                389  *
                390  CHECKCLOSED               
820A: A2 00     391           LDX   #0         
820C: A9 03     392  :L       LDA   #<S0SR     
820E: 8D B6 C0  393           STA   WADRL      
8211: AD B7 C0  394           LDA   WDATA      
8214: F0 06     395           BEQ   ISCLOSED   
8216: EA        396           NOP              
8217: EA        397           NOP              
8218: EA        398           NOP              
8219: E8        399           INX              
821A: D0 F0     400           BNE   :L         ; DON'T WAIT FOREVER
                401  ISCLOSED                  
821C: 60        402           RTS              ; SOCKET IS CLOSED
                403  *
                404  *
                405  * SUPPORT SUBROUTINE: CLEANOUT
                406  * "CLEANS UP" OUTPUT FOR THE APPLE BY
                407  * SETTING THE HIGH BIT AND DOING SOME SUBSTITUTIONS
                408  CLEANOUT                  
821D: 09 80     409           ORA   #%10000000 ; SET HIGH BIT
821F: C9 8A     410           CMP   #$8A       ; NEWLINE?
8221: D0 02     411           BNE   :OUT       
8223: A9 8D     412           LDA   #$8D       ; CONVERT TO <CR>
                413  :OUT                      
8225: 4C ED FD  414           JMP   COUT       ; THIS WILL DO THE RTS
                415  *
                416  * DEBUG - PRINT W5100 STARTADR AND SIZE
                417  *
                418  DEBUG                     
8228: A9 A0     419           LDA   #" "       
822A: 20 ED FD  420           JSR   COUT       
822D: A9 A4     421           LDA   #"$"       
822F: 20 ED FD  422           JSR   COUT       
8232: A5 0D     423           LDA   GETSTARTADR+1 
8234: A6 0C     424           LDX   GETSTARTADR 
8236: 20 41 F9  425           JSR   PRNTAX     
8239: A9 A0     426           LDA   #" "       
823B: 20 ED FD  427           JSR   COUT       
823E: A9 A4     428           LDA   #"$"       
8240: 20 ED FD  429           JSR   COUT       
8243: A5 09     430           LDA   GETSIZE+1  
8245: A6 08     431           LDX   GETSIZE    
8247: 20 41 F9  432           JSR   PRNTAX     
824A: A9 8D     433           LDA   #$8D       
824C: 4C ED FD  434           JMP   COUT       ; THIS WILL DO THE RTS
                435  *
 
 
--End assembly, 591 bytes, Errors: 0 

[toc] | [prev] | [next] | [standalone]


#3261

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-07 02:59 +0000
Message-ID<dog_cow-1486436452@macgui.com>
In reply to#3260
Chris Torrence wrote:
> Okay, so I made the code even smaller by just letting the W5100 handle the
> wraparound automatically. It worked like a charm. 

That's what I ended up doing in Marina, but the caveat is that, to the best
of my knowledge, you can only use socket 0. If you want to use more than one
socket, you have to think about wraparound in your code. But I'm not certain
on this, so it's worth experimenting with.

> code here, and also email it to DF in case you want to include some of it
> in the next manual update. Thanks for the help!
>

Got it. As I said in my reply to your email, I'll run it through Merlin, see
how it goes, then update the manual.

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3262

From"Mark D. Overholser" <marko@markoverholser.com>
Date2017-02-07 10:33 -0800
Message-ID<6d25aa6f-533b-7a87-073c-c8173b9bf94e@markoverholser.com>
In reply to#3261
On 06-Feb-17 18:59, D Finnigan wrote:
> Chris Torrence wrote:
>> Okay, so I made the code even smaller by just letting the W5100 handle the
>> wraparound automatically. It worked like a charm.
>
> That's what I ended up doing in Marina, but the caveat is that, to the best
> of my knowledge, you can only use socket 0. If you want to use more than one
> socket, you have to think about wraparound in your code. But I'm not certain
> on this, so it's worth experimenting with.
>

This is my understanding of the Documentation too...  The Auto-Wrap 
feature Only works on the Whole Buffer...  So if your limiting yourself 
to Only using One Socket, it won't matter, but for flexibility, you 
should develop the Code to handle the Buffer Wrap on your own..



>> code here, and also email it to DF in case you want to include some of it
>> in the next manual update. Thanks for the help!
>>
>
> Got it. As I said in my reply to your email, I'll run it through Merlin, see
> how it goes, then update the manual.
>


Thanks David!!!!  ( and Chris )


MarkO

[toc] | [prev] | [next] | [standalone]


#3263

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-07 21:42 +0000
Message-ID<dog_cow-1486503828@macgui.com>
In reply to#3262
Mark D. Overholser wrote:
> On 06-Feb-17 18:59, D Finnigan wrote:
>>
>>
>> Got it. As I said in my reply to your email, I'll run it through Merlin,
>> see
>> how it goes, then update the manual.
>>
>  
> Thanks David!!!!  ( and Chris )
>

I assembled the modified code this morning and updated my Merlin source
file. I will merge the code into the manual either later today or tomorrow.

By the way the Uthernet II W5100 sample source code is on the Marina source
disk:
http://marina.a2hq.com/files/src/MarinaIP%20-%2014%20Jun%2016.2mg.gz

(not updated yet, but I'm mentioning it so people know)

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3274

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-12 20:49 +0000
Message-ID<dog_cow-1486932677@macgui.com>
In reply to#3253
Chris Torrence wrote:
> Hi all,
> 
> I've been working my way through the Uthernet II manual (which is
> excellent
> by the way!) and I've encountered a couple of minor bugs with the TCP
> socket demo code.
> 

Updated manual is now online. I added your code + A2osX in the Software
section.

Get it at the a2RetroSystems site.


-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3295

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-25 23:29 +0000
Message-ID<dog_cow-1488065465@macgui.com>
In reply to#3274
D Finnigan wrote:
> Chris Torrence wrote:
>> Hi all,
>> 
>> I've been working my way through the Uthernet II manual (which is
>> excellent
>> by the way!) and I've encountered a couple of minor bugs with the TCP
>> socket demo code.
>> 
> 
> Updated manual is now online. I added your code + A2osX in the Software
> section.
> 
> Get it at the a2RetroSystems site.
>

The manual is now updated again with another correction from Chris Torrence.

Visit http://a2retrosystems.com/ and click the manual download link

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3296

From"Mark D. Overholser" <marko@markoverholser.com>
Date2017-02-25 21:12 -0800
Message-ID<5316554a-98bf-b213-dcb4-2080ea09c9db@markoverholser.com>
In reply to#3295
On 2/25/2017 15:29, D Finnigan wrote:
> D Finnigan wrote:
>> Chris Torrence wrote:
>>> Hi all,
>>>
>>> I've been working my way through the Uthernet II manual (which
>>> is excellent by the way!) and I've encountered a couple of minor
>>> bugs with the TCP socket demo code.
>>>
>>
>> Updated manual is now online. I added your code + A2osX in the
>> Software section.
>>
>> Get it at the a2RetroSystems site.
>>
>
> The manual is now updated again with another correction from Chris
> Torrence.
>
> Visit http://a2retrosystems.com/ and click the manual download link
>


DogCow;


Any "hints" as to what Chris' Corrections are???   Or do we have to
check all 17 pages of Source Code??

MarkO

[toc] | [prev] | [next] | [standalone]


#3297

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-26 20:03 +0000
Message-ID<dog_cow-1488139548@macgui.com>
In reply to#3296
Mark D. Overholser wrote:
> On 2/25/2017 15:29, D Finnigan wrote:
>>
>> The manual is now updated again with another correction from Chris
>> Torrence.
>>
>> Visit http://a2retrosystems.com/ and click the manual download link
>>
> 
> Any "hints" as to what Chris' Corrections are??? 

The TCP Demo listing beginning on page 23.

[toc] | [prev] | [next] | [standalone]


#3298

From"Mark D. Overholser" <marko@markoverholser.com>
Date2017-02-26 16:26 -0800
Message-ID<3dfa5743-613b-fffd-42b1-8a69309c5799@markoverholser.com>
In reply to#3297
On 2/26/2017 12:03, D Finnigan wrote:
> Mark D. Overholser wrote:
>> On 2/25/2017 15:29, D Finnigan wrote:
>>>
>>> The manual is now updated again with another correction from Chris
>>> Torrence.
>>>
>>> Visit http://a2retrosystems.com/ and click the manual download link
>>>
>>
>> Any "hints" as to what Chris' Corrections are???
>
> The TCP Demo listing beginning on page 23.
>


Your Not making this Easy....  Are You?

Your going to Make Me, Print Out ALL the Source code and go through it 
Line by Line.....


MarkO

[toc] | [prev] | [next] | [standalone]


#3299

FromD Finnigan <dog_cow@macgui.com>
Date2017-02-27 01:38 +0000
Message-ID<dog_cow-1488159618@macgui.com>
In reply to#3298
Mark D. Overholser wrote:
> On 2/26/2017 12:03, D Finnigan wrote:
>> Mark D. Overholser wrote:
>>> On 2/25/2017 15:29, D Finnigan wrote:
>>>>
>>>> The manual is now updated again with another correction from Chris
>>>> Torrence.
>>>>
>>>> Visit http://a2retrosystems.com/ and click the manual download link
>>>>
>>>
>>> Any "hints" as to what Chris' Corrections are???
>>
>> The TCP Demo listing beginning on page 23.
>>
> 
> 
> Your Not making this Easy....  Are You?
> 
> Your going to Make Me, Print Out ALL the Source code and go through it 
> Line by Line.....

Sure, why not.... or use diff. ;-P

Seriously though, the TCP Demo got a lot shorter as the send/receive
algorithms were simplified. An off-by-one error was fixed. The program now
makes 5 or 6 tries to initialize the W5100 and TCP connection instead of
giving up so quickly. There is also an attached Applesoft program to set the
source and destination IP addresses in the binary.

-- 
]DF$
The Marina IP stack for Apple II--
http://marina.a2hq.com/

[toc] | [prev] | [next] | [standalone]


#3300

From"Mark D. Overholser" <marko@markoverholser.com>
Date2017-02-27 09:58 -0800
Message-ID<f117c0cd-79ed-1573-1804-f8b0428699d5@markoverholser.com>
In reply to#3299
On 26-Feb-17 17:38, D Finnigan wrote:
> Mark D. Overholser wrote:
>> On 2/26/2017 12:03, D Finnigan wrote:
>>> Mark D. Overholser wrote:
>>>> On 2/25/2017 15:29, D Finnigan wrote:
>>>>>
>>>>> The manual is now updated again with another correction from Chris
>>>>> Torrence.
>>>>>
>>>>> Visit http://a2retrosystems.com/ and click the manual download link
>>>>>
>>>>
>>>> Any "hints" as to what Chris' Corrections are???
>>>
>>> The TCP Demo listing beginning on page 23.
>>>
>>
>>
>> Your Not making this Easy....  Are You?
>>
>> Your going to Make Me, Print Out ALL the Source code and go through it
>> Line by Line.....
>
> Sure, why not.... or use diff. ;-P
>

I haven't tried DIFF on PDFs....

> Seriously though, the TCP Demo got a lot shorter as the send/receive
> algorithms were simplified. An off-by-one error was fixed. The program now
> makes 5 or 6 tries to initialize the W5100 and TCP connection instead of
> giving up so quickly. There is also an attached Applesoft program to set the
> source and destination IP addresses in the binary.
>


When looking through the Code, it seemed like that there could be some 
Code Condensing..

Chris noted the Off By One Error, earlier....

I saw the Init of the Retry Counter....

I will look for the AppleSoft program...


Thanks for ALL your work.....   You Rock!!!!!


MarkO

[toc] | [prev] | [standalone]


Back to top | Article view | comp.sys.apple2.programmer


csiph-web