VB debuged. Now it should be finished! Created a Matlab Script for

testing the VB program
master
mDescape 3 years ago
parent 0b649689cc
commit 5c521a14d4
  1. 11
      Code/Matlab/TCP-Server.m
  2. 54
      Code/Matlab/TCP_Server.m
  3. BIN
      Code/Visual_Basic/C7000_Main/.vs/C7000_Test/v16/.suo
  4. BIN
      Code/Visual_Basic/C7000_Main/.vs/C7000_Test/v16/Server/sqlite3/storage.ide
  5. 24
      Code/Visual_Basic/C7000_Main/C7000_Test/Program.vb
  6. BIN
      Code/Visual_Basic/C7000_Main/C7000_Test/bin/x86/Debug/netcoreapp3.1/C7000_Test.dll
  7. BIN
      Code/Visual_Basic/C7000_Main/C7000_Test/bin/x86/Debug/netcoreapp3.1/C7000_Test.pdb
  8. 47
      Code/Visual_Basic/C7000_Main/C7000_Test/bin/x86/Debug/netcoreapp3.1/SkCommIo.log
  9. BIN
      Code/Visual_Basic/C7000_Main/C7000_Test/obj/x86/Debug/netcoreapp3.1/C7000_Test.dll
  10. BIN
      Code/Visual_Basic/C7000_Main/C7000_Test/obj/x86/Debug/netcoreapp3.1/C7000_Test.pdb
  11. BIN
      Code/Visual_Basic/C7000_Main/C7000_Test/obj/x86/Debug/netcoreapp3.1/C7000_Test.vbprojAssemblyReference.cache

@ -1,11 +0,0 @@
port = 30000;
t = tcpip('0.0.0.0', port, 'NetworkRole', 'Server')
fopen(t);
message_rx = fread(t, 23, 'char');
message_tx = 'Hello from Matlab';
fwrite(t, message_tx, 'char');
message_rx = native2unicode(message_rx, 'UTF-8')
fclose(t);

@ -0,0 +1,54 @@
num_measures = 3; %Num of measures to be made
max_tests = 10;
average_lx = []
max_lx = []
min_lx = []
x = []
tcpObj = tcp_Server_Start();
for num_tests = 1:max_tests
[average, max, min] = C7000_Read(num_measures, tcpObj);
average_lx = [average_lx, average];
max_lx = [max_lx, max-average];
min_lx = [min_lx, average-min];
x = [x, num_tests];
h = errorbar(x, average_lx, min_lx, max_lx, '-o');
refreshdata(h,'caller')
drawnow
end
C7000_End_program(tcpObj);
fclose(tcpObj);
function tcpObj = tcp_Server_Start()
%Opens a TCP/IP server and waits until a client connects to it
port = 30000;
tcpObj = tcpip('0.0.0.0', port, 'NetworkRole', 'Server')
tcpObj.ByteOrder = 'littleEndian';
tcpObj.Timeout = 9999;
fopen(tcpObj); %Wait until the client connects
end
function [average_lx, max_lx, min_lx] = C7000_Read(n, tcpObj)
%Ask the C-7000 to make n measures and returns average, max and min lux
%of all the measures
fwrite(tcpObj, int16(n), 'int16');
average_lx = fread(tcpObj, 1, 'double');
max_lx = fread(tcpObj, 1, 'double');
min_lx = fread(tcpObj, 1, 'double');
end
function C7000_End_program(tcpObj)
fwrite(tcpObj, int16(-1), 'int16'); %Ask the C-7000 to finish the program
end

@ -33,7 +33,7 @@ Module Program
Dim num_measures As Int16 = 0
Dim index As Int16 = 0
Dim mean_lx As Double
Dim average_lx As Double
Dim min_lx As Double
Dim max_lx As Double
@ -70,13 +70,15 @@ Module Program
Dim data_rx(VBClient.ReceiveBufferSize) As Byte
VBClientStream.Read(data_rx, 0, CInt(VBClient.ReceiveBufferSize))
num_measures = BitConverter.ToInt16(data_rx, 0)
Dim Lux(num_measures) As Double 'Array of illuminances mesuared
If -1 = num_measures Then 'If -1 is sent from the server
Exit While 'Finish the program
End If
Dim Lux(num_measures - 1) As Double 'Array of illuminances mesuared
Console.WriteLine("Starting measures...")
Console.WriteLine()
Console.WriteLine("Starting " + Convert.ToString(num_measures) + " measures...")
While num_measures > 0
While True
If True = Check_Status(C7000Device.SK_GetDeviceInfo(DeviceInfo)) Then ' If everything is OK
@ -95,6 +97,9 @@ Module Program
End Select
End If
End While
If "Under" = Result_Illmi Then 'Translate the "too low for reading" to "0"
Result_Illmi = "0"
End If
Lux(index) = CDbl(Result_Illmi) 'Cast from string to Double
Console.WriteLine(" Measure " + Convert.ToString(index + 1) + ": " + Result_Illmi + " lx")
index += 1
@ -103,15 +108,16 @@ Module Program
Console.WriteLine("Measures completed")
Console.WriteLine("")
For i As Int16 = 0 To index
mean_lx += Lux(i)
average_lx = 0
For i As Int16 = 0 To (index - 1)
average_lx += Lux(i)
Next i
mean_lx = mean_lx / index
average_lx = average_lx / index
max_lx = Lux.Max()
min_lx = Lux.Min()
Console.Write("Mean of the measures: ")
Console.WriteLine(mean_lx)
Console.Write("Mean Value: ")
Console.WriteLine(average_lx)
Console.Write("Max Value: ")
Console.WriteLine(max_lx)
Console.Write("Min Value: ")
@ -119,7 +125,7 @@ Module Program
index = 0
'Creation of the packet to be send to the server
Dim mean_byte As Byte() = BitConverter.GetBytes(mean_lx)
Dim mean_byte As Byte() = BitConverter.GetBytes(average_lx)
Dim max_byte As Byte() = BitConverter.GetBytes(max_lx)
Dim min_byte As Byte() = BitConverter.GetBytes(min_lx)
Dim data_tx() As Byte = mean_byte.Concat(max_byte.Concat(min_byte).ToArray).ToArray 'Concatenate the 3 values

@ -738,3 +738,50 @@
[#2020/03/20 12:15:58.223]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 12:15:58.301]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 12:15:58.379]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 14:18:32.782]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:24:59.471]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:25:36.427]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:26:59.477]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:27:38.997]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:29:07.922]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:29:34.668]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:31:03.475]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:32:19.243]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:34:55.492]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:35:43.346]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:37:10.280]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:40:41.985]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:42:00.336]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:47:23.217]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:48:20.133]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:55:50.254]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 14:55:50.266]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 14:55:50.306]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 14:55:50.328]SkCommIo_SendData :Status=0x20210003:GetLastError=0x00000000
[#2020/03/20 14:56:36.577]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:57:09.162]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:58:28.972]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 14:59:39.965]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:00:36.953]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:01:53.531]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:44:02.486]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:45:16.181]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:46:19.758]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:51:07.989]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 15:54:31.032]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:01:01.237]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:03:27.892]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:16:41.714]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:17:32.588]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:18:29.448]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:19:51.068]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:20:19.398]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:46:04.231]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:52:28.331]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:55:18.376]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:57:13.929]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:57:47.445]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:59:05.245]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:59:32.835]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 16:59:59.311]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000
[#2020/03/20 17:03:12.651]SkCommIo_RecvData :Status=0x2021000f:GetLastError=0x00000000

Loading…
Cancel
Save