Networking two BasicX Controllers



' Network1.Bas
' 
' Processor #1 opens the network, and sends a value to a specified 
' location in a remote microcontroller's RAM.  Processor #2 continually
' displays this value.  See Network2.Bas below.
'
' Connections necessary for networking are as follows:
'
'	BASICX#1			BASICX#2
'	J15---------------------------------J15
'	J16---------------------------------J16
'	J17---------------------------------J17
'
' copyright, David Seebold, Baltimore, MD, Oct, '99
'---------------------------------------------------

Sub Main()
    
   Dim NodeAddress as Integer, MemoryAddress as Integer, Value as Byte
   Dim Result as Byte, Space as String

   NodeAddress = &H1234
   MemoryAddress = 200
   Space = " "
   Value = 7				' start by sending a 7

   Call OpenSerialPort(2, 9600)		' for local monitoring
   Call OpenNetwork(NodeAddress,200)

   Do 
      ' send to the remote
      Call PutNetwork(NodeAddress, MemoryAddress, Value, Result)

      Call PutB(Value)	' display locally along with result
      Call PutStr(Space)
      Call PutStr(Space)
      Call PutB(Result)
      Call NewLine()
      Call Sleep(1.0)
      Value = Value + 1	' new value to send
	
    Loop

End Sub

'**************************

' Network2.Bas 
'
' Enables a RAM location to be written to remotely by another BasicX.
' 
' Constantly displays value of the RAM location on local Com port.
'
' copyright, David Seebold, Baltimore, MD, Oct, '99

Sub Main()

   Dim Address as Integer
   Dim RemotelyInputValue as Byte
   Call Rampoke(26, 200)	' put the number 26 in location 200

   Call OpenSerialPort(2, 9600)
   Call OpenNetwork(&H1234, 200)

   Do	
	
      RemotelyInputValue = RAMpeek(200) ' fetch value of location 200
					' and display
					
      Call PutB(RemotelyInputValue)
      ' should display 7, 8, 9, etc
      Call NewLine()
      Call Sleep(1.0)
   Loop		

End Sub