Having some fun now. I hacked on my simple VB terminal program and added a few fields, to allow me to enter an IP address as well as a port number to talk to. I then added a button that connected to that port. In particular the port associated with the configurable pins (77F0), I then had it talk to that port and print out some current information: So far it comes back:
Client Socket Program - Server Connected ...
:(5)10 FF 0 0 0
:(5)11 0 0 0 0
:(5)12 FF 0 0 0
:(5)13 DD 0 0 0
The number in () is the number of bytes that were returned for each of the commands I sent. 5 is correct. The first byte returned is the command number followed by 4 bytes of state information.
10 - All IO pins are available (not special purpose)
11 - Direction all IO pins are currently input
12 - Get active levels - all pins are active low
13 - Current status: DD - 2 bits are currently off not sure yet maybe switches.
Next step will to look more at what the sample board has these pins connected to like buttons and LEDs. If connected to LEDS for example will setup simple form to allow me to set them on PC…
In case anyone wants to see the VB code. Here is what runs when I hit the button:
[code] Private Sub Matchport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Matchport.Click
Dim buffSize As Integer
Dim PinGetFunction(9) As Byte
Dim i As Byte
msg(“Client Started”)
clientSocket.Connect(IPAdr.Text, Convert.ToInt32(Port.Text, 16))
AddLineToLBTerminal(“Client Socket Program - Server Connected …”)
Dim serverStream As NetworkStream = clientSocket.GetStream()
PinGetFunction(0) = &H10
For i = 1 To 8
PinGetFunction(i) = 0
Next
serverStream.Write(PinGetFunction, 0, 9)
serverStream.Flush()
Dim cntRead As Int16
Dim inStream(10024) As Byte
buffSize = clientSocket.ReceiveBufferSize
cntRead = serverStream.Read(inStream, 0, buffSize)
AddLineToLBTerminal(":(" + cntRead.ToString+")"+ hex(inStream(0))+" "+hex(inStream(1))+" "+hex(inStream(2))+" "+hex(inStream(3))+" "+hex(inStream(4)))
' now lets try the get direction command...
PinGetFunction(0) = &H11
serverStream.Write(PinGetFunction, 0, 9)
serverStream.Flush()
buffSize = clientSocket.ReceiveBufferSize
cntRead = serverStream.Read(inStream, 0, buffSize)
AddLineToLBTerminal(":(" + cntRead.ToString + ")" + Hex(inStream(0)) + " " + Hex(inStream(1)) + " " + Hex(inStream(2)) + " " + Hex(inStream(3)) + " " + Hex(inStream(4)))
' Likewise get active levels
PinGetFunction(0) = &H12
serverStream.Write(PinGetFunction, 0, 9)
serverStream.Flush()
buffSize = clientSocket.ReceiveBufferSize
cntRead = serverStream.Read(inStream, 0, buffSize)
AddLineToLBTerminal(":(" + cntRead.ToString + ")" + Hex(inStream(0)) + " " + Hex(inStream(1)) + " " + Hex(inStream(2)) + " " + Hex(inStream(3)) + " " + Hex(inStream(4)))
' And current states...
PinGetFunction(0) = &H13
serverStream.Write(PinGetFunction, 0, 9)
serverStream.Flush()
buffSize = clientSocket.ReceiveBufferSize
cntRead = serverStream.Read(inStream, 0, buffSize)
AddLineToLBTerminal(":(" + cntRead.ToString + ")" + Hex(inStream(0)) + " " + Hex(inStream(1)) + " " + Hex(inStream(2)) + " " + Hex(inStream(3)) + " " + Hex(inStream(4)))
' disconnect from socket
clientSocket.Close()
End Sub[/code]
Note: the Close function is the wrong one it causes the next time I try to do a connect to fail, I need to figure out which is correct one…
All for now
Kurt