Onto a new issue. I want to beable to control remotely what pool is selected. Since I have 9 rigs I want to do this programatically. I am very knowledable of VB and linux, but am new to JSON/RPC. I would like to be able to send such a command via the network interface using RPC via VBA.net. From looking at the cgminer source RPC/JSON commands are accepted through the use of port 4028. What would be the simpliest way to send an RPC packet from VBA.net to switch to pool 2 and viceversa switch to pool 0.
Any help would be appreciated. I have exhausted the third party addons for JSON serialization and RPC protocal and have not come accross a viable solution.
Thanks,
Mark
Here's how to do it in C# (there are probably other ways as well)
private void sendCommand(string command)
{
try
{
System.Net.Sockets.TcpClient clientSocket = new System.Net.Sockets.TcpClient();
clientSocket.Connect("192.168.10.2", 4028);
NetworkStream serverStream = clientSocket.GetStream();
byte[] outStream = System.Text.Encoding.ASCII.GetBytes(command);
serverStream.Write(outStream, 0, outStream.Length);
serverStream.Flush();
byte[] inStream = new byte[65536];
serverStream.Read(inStream, 0, (int)clientSocket.ReceiveBufferSize);
string returnData = System.Text.Encoding.ASCII.GetString(inStream);
displayMessage(returnData);
clientSocket.Close();
}
catch (Exception exc)
{
}
}
and in VB.net
Private Sub sendCommand(command As String)
Try
Dim clientSocket As New System.Net.Sockets.TcpClient()
clientSocket.Connect("192.168.10.2", 4028)
Dim serverStream As NetworkStream = clientSocket.GetStream()
Dim outStream As Byte() = System.Text.Encoding.ASCII.GetBytes(command)
serverStream.Write(outStream, 0, outStream.Length)
serverStream.Flush()
Dim inStream As Byte() = New Byte(65536) {}
serverStream.Read(inStream, 0, CInt(clientSocket.ReceiveBufferSize))
Dim returnData As String = System.Text.Encoding.ASCII.GetString(inStream)
displayMessage(returnData)
clientSocket.Close()
Catch exc As Exception
End Try
End Sub
Here's a quick little gui exe in the bin folder and the source to send some commands either simple text or json formatted no need for any added library.
Cgminer_RPC