aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs')
-rw-r--r--Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs104
1 files changed, 104 insertions, 0 deletions
diff --git a/Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs b/Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs
new file mode 100644
index 000000000..75224ed24
--- /dev/null
+++ b/Software/Stubs Collection/stubs/Scripts/BTSR/15_CONFIGURATION_SET.cs
@@ -0,0 +1,104 @@
+using System;
+using System.Text;
+using System.Linq;
+using System.Drawing;
+using System.Diagnostics;
+using System.Windows.Forms;
+using System.Threading;
+using System.Threading.Tasks;
+using System.Collections.Generic;
+using Tango.PMR.Stubs;
+using Tango.Stubs;
+const byte YES = 0x01;
+const byte NO = 0x00;
+
+byte FLIP_DISPLAY = 0x00;
+
+//--------------------------------------------------------------------------------------------------------------
+// ------ Request Parameters ------
+const byte CODE_STRING = 0x01;//BTSR ID
+
+const byte FUNCTION_STRING = 0x36;
+
+const Int32 Auto_Calc_CheckSum = YES;//1 YES, 0 NO //if YES Don't send the checksum Bytes!!!!
+
+// ------ Response Parameters ------
+const Int32 BytesToRead = 1;//Number of the expected Bytes to read (iclude CHECK_STRING if available)
+const Int32 Verify_Received_CheckSum = NO;//1 YES, 0 NO --- TBD NA ---
+//--------------------------------------------------------------------------------------------------------------
+int BTSR_Write_and_Read()
+{
+ StubI2CWriteBytesRequest stubI2CWriteBytesRequest = new StubI2CWriteBytesRequest();
+ stubI2CWriteBytesRequest.I2CId = 0xFEED; // - Don't Change!! BTSR FEEDR (Script identification)
+ stubI2CWriteBytesRequest.SlaveAddress = Auto_Calc_CheckSum;
+
+ UInt32 uInt32 = new UInt32();
+ //--------------------------------------------------------------
+ stubI2CWriteBytesRequest.BytesTWrite.Add(CODE_STRING);//Byte 0 to write CODE_STRING
+
+ stubI2CWriteBytesRequest.BytesTWrite.Add(FUNCTION_STRING);//Byte 1 to write FUNCTION_STRING
+
+
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//1° BYTE CONFIGURATION BYTE
+
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//2° BYTE STOP OUTPUT
+ stubI2CWriteBytesRequest.BytesTWrite.Add(FLIP_DISPLAY);//3° BYTE INPUT CONFIGURATION ----- D6 ‘1’ FLIP DISPLAY (0x40 / 0x00)
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//4° BYTE EDITOR
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//5° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//6° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//7° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//8° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//9° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//10° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//11° STRETCH VALUE (LSB)
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//12° STRETCH VALUE (MSB)
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//13° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//14° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//15° SPARE
+ stubI2CWriteBytesRequest.BytesTWrite.Add(0);//16° SPARE
+
+ var response = stubManager.Run<StubI2CWriteBytesResponse>(stubI2CWriteBytesRequest);
+
+ return 1;
+}
+
+
+int BTSR_Get()
+{
+ int i = 0;
+ StubI2CReadBytesRequest stubI2CReadBytesRequest = new StubI2CReadBytesRequest();
+ stubI2CReadBytesRequest.I2CId = 0xFEED; // - Don't Change!! BTSR FEEDR (Script indentify)
+ stubI2CReadBytesRequest.SlaveAddress = Verify_Received_CheckSum;
+ stubI2CReadBytesRequest.NumberOfBytesToRead = BytesToRead + Verify_Received_CheckSum;
+
+ var response1 = stubManager.Run<StubI2CReadBytesResponse>(stubI2CReadBytesRequest);
+ uint temph=0;
+
+ for(i=0; i<stubI2CReadBytesRequest.NumberOfBytesToRead - Verify_Received_CheckSum;i++)
+ {
+ temph=response1.ReadBytes[i];
+ stubManager.WriteLineHex(temph,2);
+ }
+ if((Verify_Received_CheckSum == YES) && (response1.ReadBytes[i] != 0))//use the next byte to return the checksum status
+ {
+ stubManager.WriteLine("\n --- Received Wrong CheckSum !!! --- \n");
+ }
+
+
+ return 1;
+}
+
+
+public void OnExecute(StubManager stubManager)
+{
+ var response = stubManager.ShowResponseWindow("FLIP DISPLAY ? Y/N", "Y");
+ if(( response == "Y") || ( response == "y"))
+ FLIP_DISPLAY = 0x40;
+ else
+ FLIP_DISPLAY = 0x00;
+
+ BTSR_Write_and_Read();
+ Thread.Sleep(15); //wait 10mSec in the embedded to read all at once so this value must be > 10 milli.
+ stubManager.WriteLine("\n --- CONFIGURATION SET --- \n");
+ BTSR_Get();
+} \ No newline at end of file