| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Jdas_Mbic
- {
- public enum Bluepro_t
- {
- bluecell_header0 = 0,
- bluecell_header1,
- bluecell_header2,
- bluecell_header3,
- bluecell_type,
- bluecell_length_h,
- bluecell_length_l,
- bluecell_updatecnt_h,
- bluecell_updatecnt_l,
- bluecell_data,
- };
- public enum Updateseq
- {
- Bluecell_Reset = 0,
- Bluecell_Firmupdate_start,
- Bluecell_Firmupdate_sending,
- Bluecell_Firmupdate_end,
- };
- enum Bluecell_ProtIndex_p
- {
- Bluecell_Header = 0,
- Bluecell_Type,
- Bluecell_Length,
- Bluecell_CrcIndex,
- Bluecell_data,
- }
- enum Bluecell_Prot_t{
- TYPE_BLUECELL_RESET = 0,
- TYPE_BLUECELL_SET = 1,
- TYPE_BLUECELL_GET = 2,
- TYPE_BLUECELL_SAVE = 3,
- TYPE_BLUECELL_ACK = 4,
- };
- struct BLUESTATUS_st
- {
- byte bluecell_header;
- byte bluecell_type;
- byte bluecell_length;
- byte bluecell_crcindex;
- byte Selftest0;
- byte Selftest1;
- byte Selftest2;
- byte Selftest3;
- byte ATT_DL1_PATH;
- byte ATT_DL2_PATH;
- byte ATT_DL3_PATH;
- byte ATT_DL4_PATH;
- byte ATT_UL1_PATH;
- byte ATT_UL2_PATH;
- byte ATT_UL3_PATH;
- byte ATT_UL4_PATH;
- byte ATT_DL1_H;
- byte ATT_DL1_L;
- byte ATT_DL2_H;
- byte ATT_DL2_L;
- byte ATT_DL3_H;
- byte ATT_DL3_L;
- byte ATT_DL4_H;
- byte ATT_DL4_L;
- byte ATT_UL1_H;
- byte ATT_UL1_L;
- byte ATT_UL2_H;
- byte ATT_UL2_L;
- byte ATT_UL3_H;
- byte ATT_UL3_L;
- byte ATT_UL4_H;
- byte ATT_UL4_L;
- byte DET_DL1_IN_H;
- byte DET_DL1_IN_L;
- byte DET_DL2_IN_H;
- byte DET_DL2_IN_L;
- byte DET_DL3_IN_H;
- byte DET_DL3_IN_L;
- byte DET_DL4_IN_H;
- byte DET_DL4_IN_L;
- byte DET_UL1_IN_H;
- byte DET_UL1_IN_L;
- byte DET_UL2_IN_H;
- byte DET_UL2_IN_L;
- byte DET_UL3_IN_H;
- byte DET_UL3_IN_L;
- byte DET_UL4_IN_H;
- byte DET_UL4_IN_L;
- byte DET_TEMP_H;
- byte DET_TEMP_L;
- byte ATT_AGC1_ONOFF;
- byte ATT_ALC1_ONOFF;
- byte ATT_AGC2_ONOFF;
- byte ATT_ALC2_ONOFF;
- byte ATT_AGC3_ONOFF;
- byte ATT_ALC3_ONOFF;
- byte ATT_AGC4_ONOFF;
- byte ATT_ALC4_ONOFF;
- byte ATT_AGC1_H;
- byte ATT_AGC1_L;
- byte ATT_ALC1_H;
- byte ATT_ALC1_L;
- byte ATT_AGC2_H;
- byte ATT_AGC2_L;
- byte ATT_ALC2_H;
- byte ATT_ALC2_L;
- byte ATT_AGC3_H;
- byte ATT_AGC3_L;
- byte ATT_ALC3_H;
- byte ATT_ALC3_L;
- byte ATT_AGC4_H;
- byte ATT_AGC4_L;
- byte ATT_ALC4_H;
- byte ATT_ALC4_L;
- byte bluecell_crc;
- };
- class Bluecell_BootProtocol
- {
- public enum DATATYPE
- {
- ATTSET = 0x11,
- ATT_DL1_PATH = 0x12,
- ATT_UL1_PATH = 0x16,
- ATT_SelfTest1 = 0x18,
- ATT_DL2_PATH = 0x22,
- ATT_UL2_PATH = 0x26,
- ATT_SelfTest2 = 0x28,
- ATT_DL3_PATH = 0x32,
- ATT_UL3_PATH = 0x36,
- ATT_SelfTest3 = 0x38,
- ATT_DL4_PATH = 0x42,
- ATT_UL4_PATH = 0x46,
- ATT_SelfTest4 = 0x48,
- ALC1_EN = 0x51,
- ALC2_EN = 0x52,
- ALC3_EN = 0x53,
- ALC4_EN = 0x54,
- AGC1_EN = 0x61,
- AGC2_EN = 0x62,
- AGC3_EN = 0x63,
- AGC4_EN = 0x64,
- ATT_TableSet = 0x70,
- ATT_TableGet = 0x71,
- Bluecell_StatusReq = 0x77,
- Bluecell_StatusSave = 0x78,
- Bluecell_DL1_USER = 0x80,
- Bluecell_DL2_USER = 0x81,
- Bluecell_DL3_USER = 0x82,
- Bluecell_DL4_USER = 0x83,
- Bluecell_UL1_USER = 0x84,
- Bluecell_UL2_USER = 0x85,
- Bluecell_UL3_USER = 0x86,
- Bluecell_UL4_USER = 0x87,
- Bluecell_TEMP_USER = 0x88,
- };
- Serial serial;
- /*bluecell Header*/
- public const byte Bluecell_Header0 = 0x42;//ASCII : B
- public const byte Bluecell_Header1 = 0x4C;//ASCII : L
- public const byte Bluecell_Header2 = 0x55;//ASCII : U
- public const byte Bluecell_Header3 = 0x45;//ASCII : E
- /*bluecell type*/
- public const int bluecell_Firmupdate_sendlength = 1024;
- Crc16 crc16 = new Crc16();
- public const byte BLUECELL_HEADER = 0xBE;
- public const byte BLUECELL_TAILER = 0xEB;
- const byte BLUECELL_RESET_LENGTH = 6;
- const byte BLUECELL_FIX_DATA_LENGTH = 3;
-
- public void Bluecell_Reset(object serial)
- {
- this.serial = (Serial)serial;
- byte[] temp_buf = new byte[BLUECELL_RESET_LENGTH];
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (byte)Bluecell_Prot_t.TYPE_BLUECELL_RESET;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = BLUECELL_RESET_LENGTH - BLUECELL_FIX_DATA_LENGTH;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = (byte)Bluecell_ProtIndex_p.Bluecell_data;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data] = crc16.STH30_CreateCrc(temp_buf, BLUECELL_RESET_LENGTH - 3);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
- this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
- }
- public void Bluecell_RF_Status_Req(object serial)
- {
- Crc16 crc16 = new Crc16();
- this.serial = (Serial)serial;
- byte[] temp_buf = new byte[6];
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Header] = BLUECELL_HEADER;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Type] = (int)DATATYPE.Bluecell_StatusReq;
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_Length] = Convert.ToByte(temp_buf.Length - 3);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_CrcIndex] = Convert.ToByte(temp_buf.Length - 2);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 0] = crc16.STH30_CreateCrc(temp_buf, temp_buf[2]);
- temp_buf[(int)Bluecell_ProtIndex_p.Bluecell_data + 1] = BLUECELL_TAILER;
- this.serial.Serial_DataSend(temp_buf, temp_buf.Length);
- }
- public const byte bluecell_length = 2;
- public const byte bluecell_updatecnt = 2;
- public const byte bluecell_crc16 = 2;
- private const byte BLUECELL_TYPE = 1;
- JdasMbic main_Form;
- const byte BLUECELL_DATA_SET_LENGTH = 56;
- public void Bluecell_RF_Status_Get(object serial, object main_form, byte[] temp_buf)
- {
- this.main_Form = (JdasMbic)main_form;
- this.serial = (Serial)serial;
- byte type = temp_buf[BLUECELL_TYPE];
- // main_Form.Invoke(new ByteSend(this.main_Form.ReSetting_Values),(temp_buf));
- switch (type)
- {
- case (byte)Bluecell_BootProtocol.DATATYPE.Bluecell_StatusReq:
- this.main_Form.GUIDataStatusSet(temp_buf);
- break;
- case (byte)Bluecell_BootProtocol.DATATYPE.ATT_TableGet:
- this.main_Form.TableDataStatusSet(temp_buf);
- break;
- //case (byte)Bluecell_Prot_t.TYPE_BLUECELL_ACK:
- //this.main_Form.Message_Box_Open();
- // break;
- // case (byte)Bluecell_Prot_t.TYPE_BLUECELL_ERROR:
- //this.main_Form.Message_Box_Error_Open(temp_buf);
- // break;
- }
- //Debug.Invoke(new StringSend(Debug.Data_Recv_Str), data);
- //main_Form.label1_8GHz_DL_OUT.Text = Convert.ToString(temp_val);
- }
- #if false
- public int Bluecell_Firmupdate_sendlength() {
- return bluecell_Firmupdate_sendlength;
- }
- private void BootHeaderput(ref byte[] fix_data)
- {
- fix_data[(int)Bluepro_t.bluecell_header0] = Bluecell_Header0;
- fix_data[(int)Bluepro_t.bluecell_header1] = Bluecell_Header1;
- fix_data[(int)Bluepro_t.bluecell_header2] = Bluecell_Header2;
- fix_data[(int)Bluepro_t.bluecell_header3] = Bluecell_Header3;
- }
- public byte[] Boot_Reset(object serial,byte[] Updatedata)
- {
- this.serial = (Serial)serial;
- byte[] fix_data = new byte[11];
- //Array.Clear(data, 0, data.Length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Reset;
- fix_data[(int)Bluepro_t.bluecell_length_h] = 0;
- fix_data[(int)Bluepro_t.bluecell_length_l] = 5;
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((Updatedata.Length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((Updatedata.Length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_data + 0] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_data + 1] = Convert.ToByte((crc16.CRC16_Generate(fix_data, fix_data.Length - 4) & 0x00FF));
- this.serial.Serial_DataSend(fix_data, fix_data.Length);
- return fix_data;
- }
-
- public byte[] Boot_DataSending(byte[] update_data,UInt16 length, UInt16 updatacnt)
- {
- //Array.Clear(data, 0, data.Length);
- byte[] fix_data = new byte[bluecell_Firmupdate_sendlength];
- //BootHeaderput(ref fix_data);
- //length += 5;
- Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_sending;
- fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = Convert.ToByte((updatacnt & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = Convert.ToByte((updatacnt & 0x00FF));
- //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
- fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
- fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
- return fix_data;
- }
- public byte[] Boot_DataEnd(byte[] update_data, int length)
- {
- //Array.Clear(data, 0, data.Length);
- byte[] fix_data = new byte[11];
- Array.Copy(update_data, (int)Bluepro_t.bluecell_data, fix_data, (int)Bluepro_t.bluecell_data, length);
- BootHeaderput(ref fix_data);
- fix_data[(int)Bluepro_t.bluecell_type] = (byte)Updateseq.Bluecell_Firmupdate_end;
- fix_data[(int)Bluepro_t.bluecell_length_h] = Convert.ToByte((length & 0xFF00) >> 8);
- fix_data[(int)Bluepro_t.bluecell_length_l] = Convert.ToByte((length & 0x00FF));
- fix_data[(int)Bluepro_t.bluecell_updatecnt_h] = 0;
- fix_data[(int)Bluepro_t.bluecell_updatecnt_l] = 0;
- //Array.Copy(update_data, 0, fix_data, (int)Bluepro_t.bluecell_data, length-3);
- fix_data[length + 9] = Convert.ToByte((crc16.CRC16_Generate(fix_data, length + 5) & 0xFF00) >> 8);
- fix_data[length + 10] = Convert.ToByte(crc16.CRC16_Generate(fix_data, length + 5) & 0x00FF);
- return fix_data;
- }
- #endif
- }
- }
|