EASy68K
http://easy68k.com/EASy68Kforum/

Serial input/output function
http://easy68k.com/EASy68Kforum/viewtopic.php?f=9&t=668
Page 1 of 1

Author:  Dan [ Sat Jun 06, 2009 9:04 pm ]
Post subject:  Serial input/output function

I need a Serial Port that I can connect a smart terminal such as a Televideo 905 or a Wyse 50.
Dan

Author:  profkelly [ Fri Oct 02, 2009 11:04 pm ]
Post subject: 

Serial I/O will be in EASy68K v4.8
(available for download)

Here are the new trap tasks:

Edit 10-5-2009 Changed the return codes.

Code:
-SERIAL I/O-
The success of the calls below is determined from D0.W in each case. A value
of zero indicates success.

40 : INIT PORT. This should be called once for each COM port to be used
     before any other serial I/O function.
     The port defaults to 9600 baud, 8 Databits, No parity, One stop bit
     Pre:
       High 16 bits of D0 contain port identifier PID, (0 through 15).
       The comm port identifier is used to identify the comm port in all other
       comm tasks. It is not used to specify the comm port number,
       (e.g. A PID of 4 does not mean the same thing as COM4)
       (A1) name of serial port as null terminated string (e.g. COM4).
     Post:
       D0.W is 0 on success, 1 on invalid PID, 2 on error.
41 : SET PORT PARAMETERS
     Pre:
       High 16 bits of D0 contain port identifier PID, (0 through 15).
       D1.B port speed: 0=default, 1=110 baud, 2=300, 3=600,
            4=1200, 5=2400, 6=4800, 7=9600, 8=19200, 9=38400,
            10=56000, 11=57600, 12=115200, 13=128000, 14=256000.
            8 Databits, No parity, One stop bit is assumed.
       The higher bits of D1.L are reserved for future use.
     Post:
       D0.W is 0 on success, 1 on invalid PID, 2 on error,
       3 on port not initialized.
42 : READ STRING.
     Pre:
       PID required as used in 40.
       (A1) buffer address,
       D1.B number of characters to read.
       If no char has been received it will timeout.
     Post:
       D0.W is 0 on success, 1 on invalid PID, 2 on error
       3 on port not initialized, 4 on timeout.
       D1.B number of characters read.
       (A1) null terminated string of characters
43 : SEND STRING.
     Pre:
       PID required as used in 40.
       (A1) buffer address,
       D1.B number of characters to send.
       If unable to send characters it will timeout.
     Post:
       D0.W is 0 on success, 1 on invalid PID, 2 on error
       3 on port not initialized, 4 on timeout.
       D1.B number of characters sent


I wrote a dumb terminal program to test it. Here is that code:
Code:
*-----------------------------------------------------------
* Program    : Dumb Term
* Written by : Chuck Kelly
* Date       : Oct-2-2009
* Description: Used to test serial I/O trap tasks
*-----------------------------------------------------------
   ORG   $1000
START:            ; first instruction of program

    move.l  #40,d0  ; init serial port PID 0
    lea     COMn,A1 ; name of port
    trap    #15     ; D0=0 on success, 1 on invalid PID, 2 on error
    if d0 <ne> #0 then.s
      bra   Fail
    endi
   
    ; turn off keyboard echo
    move.b  #12,d0
    move.b  #0,d1
    trap    #15
   
loop
    move.l  #7,d0   ; check for keyboard input
    trap    #15     ; d1.b set too 1 if input pending else 0
    if.b d1 <eq> #1 then.s  ; if input pending
      move.b #5,d0  ; get keypress
      trap  #15
     
      ; send keypress
      move.b d1,buf ; save keypress
      lea    buf,a1
      move.b #1,d1  ; send 1 char
      move.l #43,d0 ; send string
      trap   #15    ; 2 on error
      if.b d0 <eq> #2 then.s
        bra  Fail
      endi
    endi
   
    ; check for receive
    lea     buf,a1
    move.b  #255,d1 ; max chars to read
    move.l  #42,d0
    trap    #15     ; 2 on error
    if.b d0 <eq> #2 then.s
      bra  Fail
    endi
   
    if.b d1 <hi> #0 then.s  ; if characters received
      move.b #1,d0   ; display n chars without CR,LR
      lea    buf,a1
      trap   #15
    endi
   
    bra     loop     

Fail
    lea     ERROR,A1
    move.b  #13,d0
    trap    #15     ; display error message
   
    MOVE.B   #9,D0
    TRAP   #15      ; halt simulator



* Variables and Strings
COMn   dc.b 'COM5',0
ERROR  dc.b 'Error',0
BUF    ds.b 256

   END   START      ; last line of source


I used the terminal program to connect to my real 68000 computer which means EASy68K has come full circle. I now have a PC running a 68000 simulator, running a terminal program, connecting to a 68000 computer.

Author:  profkelly [ Tue Oct 27, 2009 3:22 pm ]
Post subject: 

The 4.9 release will support changing Baud rate, Data bits and Stop bits.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/