Hello,
I have an arduino mega device with ethernet shield, user may send commands through USB or Ethernet connection then direct these commands to command handler, the problem is i want to direct results from command handler to its source(SendStreamMessage sub), for example how can I send this to both USB and ethernet.
private Sub GetUSBstream(Buffer() As Byte)
CommandHandler(Buffer,SYS_STREAM_SOURCE_USB)
End Sub
Private Sub GetEthernetStream (Buffer() As Byte)
CommandHandler(Buffer,SYS_STREAM_SOURCE_ETHERNET)
End Sub
private Sub CommandHandler(Buffer () As Byte, StreamSource As Byte)
'execute command and send result to SendStreamMessage
End Sub
private Sub SendStreamMessage(Message As String, StreamSource As Byte)
Select StreamSource
Case SYS_STREAM_SOURCE_USB
Case SYS_STREAM_SOURCE_ETHERNET '????
End Select
End Sub
private Sub SendStreamMessage(Message As String, StreamSource As Byte)
Select StreamSource
Case SYS_STREAM_SOURCE_USB
USBstream.Write(...
Case SYS_STREAM_SOURCE_ETHERNET
EthernetStream.Write(...
End Select
End Sub
private Sub SendStreamMessage(Message() As Byte , StreamSource As Byte)
Select StreamSource
Case SYS_STREAM_SOURCE_USB
USBstream.Write(Message)
Case SYS_STREAM_SOURCE_ETHERNET
EthernetStream.Write(Message)
End Select
End Sub
and passed data like this:
B4X:
SendStreamMessage(Array As Byte (0x02,CMD_READ,REG_DATE_TIME,0x0C,Years - 2000,Months,DayOfMonth,DayOfWeek,Hours,Minutes,Seconds,0x04),
SYS_STREAM_SOURCE_ETHERNET
)