|
|
| Author |
Message |
zbasicandy
Joined: 26 Jan 2006
Posts: 193
|
|
Posted: 04 April 2006, 1:56 AM Post subject: 'Super Com Z" Com Support Routines "Port parameter |
|
|
These "beta" routines should work for general serial communications using 1 to 4 serial I/O ports. Due to the complex nature of these routines they are subject to change on the minute!
| Description: |
| Com Support routines for the "Super Comm Z" with 4 serial ports. |
|
 Download |
| Filename: |
ComSupport_R4.bas |
| Filesize: |
28.49 KB |
| Downloaded: |
3356 Time(s) |
|
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 656
|
|
Posted: 04 April 2006, 19:56 PM Post subject: |
|
|
(I've never used BasicX)
Are the unusal codings for PutL and Put floats etc. as they are because of BasicX compatibility?
ZBasic would not need all this arcane code.
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR
|
|
Posted: 04 April 2006, 20:58 PM Post subject: |
|
|
I would suggest the alternate implementations below. Something similar could be used for outputting Single values unless the required format can't be produced by CStr() or Fmt().
| Code: | Public Sub PutStr(ByVal port as Byte, ByRef Tx as STRING)
' Outputs a STRING type to serial port n.
Dim Length as Integer
Dim I as Integer
Length = Len(Tx)
For I = 1 To Length
Call PutByte(port, Asc(Tx, I))
Next I
End Sub
Public Sub PutL(ByVal port as Byte, ByVal Operand as Long)
Dim s as BoundedString(11)
s = CStr(Operand)
Call PutStr(port, s)
End Sub
Public Sub PutUL(ByVal port as Byte, ByVal Operand as UnsignedLong)
Dim s as BoundedString(10)
s = CStr(Operand)
Call PutStr(port, s)
End Sub |
Except for the use of the second parameter on the Asc() function and the syntax for defining the bounded string, the same coding would work for BasicX. An alternate method for fetching string characters in BasicX is:
| Code: | | Call PutByte(port, RamPeek(MemAddress(Tx) + I + 1)) |
|
|
| Back to top |
|
 |
stevech
Joined: 23 Feb 2006
Posts: 656
|
|
Posted: 05 April 2006, 2:27 AM Post subject: |
|
|
| Code: | Public Sub PutL(ByVal port as Byte, ByVal Operand as Long)
Dim s as BoundedString(11)
s = CStr(Operand)
Call PutStr(port, s)
End Sub |
would be useful as a sub if it saved code space, rather than just coding in-line in the application:
call PutStr(port, CStr(number)) // dynamic string allocation in ZBasic
which with the VM, is probably not significantly different, esp. considering that it uses less call/return/parameter passing stack.
|
|
| Back to top |
|
 |
dkinzer Site Admin
Joined: 03 Sep 2005
Posts: 2493
Location: Portland, OR
|
|
Posted: 05 April 2006, 2:48 AM Post subject: |
|
|
| Code: | | Call PutStr(port, CStr(number)) |
You are correct that this consumes less stack space than allocating the bounded string. I should have made that reduction, too.
|
|
| Back to top |
|
 |
|