diff --git a/test/E220_can/E220_can.ino b/test/E220_can/E220_can.ino index a6de38c..0364c39 100644 --- a/test/E220_can/E220_can.ino +++ b/test/E220_can/E220_can.ino @@ -6,7 +6,7 @@ #define SEND_PERIOD_MS 1000 -E220 e220(0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00 +E220 e220(Serial1,0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00 CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN /*E220configuration diff --git a/test/E220_ground/E220_ground.ino b/test/E220_ground/E220_ground.ino index 63fec3b..bbfc06d 100644 --- a/test/E220_ground/E220_ground.ino +++ b/test/E220_ground/E220_ground.ino @@ -2,7 +2,7 @@ #define SEND_PERIOD_MS 1000 -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 +E220 e220(Serial1,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 /*E220configuration - UARTbaudrate:115200bps diff --git a/test/E220_vertual_rocket/E220_vertual_rocket.ino b/test/E220_vertual_rocket/E220_vertual_rocket.ino index ac8ee08..3bb6b33 100644 --- a/test/E220_vertual_rocket/E220_vertual_rocket.ino +++ b/test/E220_vertual_rocket/E220_vertual_rocket.ino @@ -4,7 +4,7 @@ #define SEND_PERIOD_MS 1000 -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 +E220 e220(Serial1,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 /*E220configuration - UARTbaudrate:115200bps diff --git a/test/MIFE220/MIFcan/MIFcan.ino b/test/MIFE220/MIFcan/MIFcan.ino index 2aac98e..3b00bc7 100644 --- a/test/MIFE220/MIFcan/MIFcan.ino +++ b/test/MIFE220/MIFcan/MIFcan.ino @@ -4,9 +4,9 @@ #define CAN0_CS 0 #define CAN0_INT 1 -#define SEND_PERIOD_MS 1000 +#define PAYLOAD_SIZE 47 +#define ROCKET_INSIDE_PACKET_LETTER 0x4E -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN /*E220configuration @@ -28,8 +28,6 @@ union unionuint32 { byte b[4]; }; - - void setup() { Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする Serial.begin(9600); @@ -39,13 +37,23 @@ void setup() { void loop() { static byte tx_payload[199] = { 0 }; - static bool send_allowed = false; //送信許可 + static byte rocket_inside_packet[200]={0}; static bool payload_semapho = false; //payloadの生成が終わるまで送信を許可しない - static uint32_t latest_send_time = 0; //最後に送信した時間 GeneratePayload(tx_payload, payload_semapho); - - //ToDO:tx_payloadをMain基板に送信する処理を書く - + //tx_payloadをMain基板に送信する処理 + if (payload_semapho == false) { + SendMainDataPacket(tx_payload); + } +} + +void SendMainDataPacket(byte* _tx_payload){ + byte rocket_inside_packet[200]={0}; + rocket_inside_packet[0] = ROCKET_INSIDE_PACKET_LETTER;// Mainマイコンがどっからデータか判断するための識別子 + for (int i = 0; i < PAYLOAD_SIZE; i++) { + rocket_inside_packet[i+1] = _tx_payload[i]; + } + //main基板に送信 + Serial1.write(rocket_inside_packet, 200);//一個目が識別子,後ろがデータ } void GeneratePayload(byte* tx_payload, bool _payload_semapho) { diff --git a/test/MIFE220/MainE220/MainE220.ino b/test/MIFE220/MainE220/MainE220.ino index 8aabb3b..440a67b 100644 --- a/test/MIFE220/MainE220/MainE220.ino +++ b/test/MIFE220/MainE220/MainE220.ino @@ -6,17 +6,11 @@ #define SEND_PERIOD_MS 1000//E220のダウンリンクの周期(ms) -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A -CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN +#define PAYLOAD_SIZE 47 +#define ROCKET_INSIDE_PACKET_LETTER 0x4E -/*E220configuration -- UARTbaudrate:115200bps -- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 -- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 -- target address: 0xFFFF(broradcast) -- power: 13dBm -- SF: 11 -*/ +E220 e220(Serial2,0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A +CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN union unionfloat { @@ -33,7 +27,8 @@ union unionuint32 { void setup() { Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする Serial.begin(9600); - Serial1.begin(115200); //E220のUART + Serial1.begin(115200); //MIFとつながってるUART + Serial2.begin(115200); //E220のUART CCP.begin(); } @@ -41,10 +36,16 @@ void loop() { static byte tx_payload[199] = { 0 };//MIF基板から送られるbyte配列格納先 static bool send_allowed = false; //送信許可 static uint32_t latest_send_time = 0; //最後に送信した時間 + static bool comingdata = false; //MIF基板からデータが来ているか - //TODO:ここにMIF基板からのデータを受け取ってtx_payloadにいれる処理を書く - - if ((millis() - latest_send_time) > SEND_PERIOD_MS) { //前の送信から一定時間経過しているか + //MIF基板からのデータを受け取ってtx_payloadにいれる処理 + if(Serial1.readBytesUntil(ROCKET_INSIDE_PACKET_LETTER,tx_payload,PAYLOAD_SIZE)){ + comingdata = true; + }else{ + comingdata = false; + } + //ここから送信処理 + if (((millis() - latest_send_time) > SEND_PERIOD_MS)&& comingdata) { //前の送信から一定時間経過しているか send_allowed = true; } if (send_allowed == true) { @@ -53,3 +54,5 @@ void loop() { send_allowed = false; } } + + diff --git a/test/formerE220lib/E220/E220.ino b/test/formerE220lib/E220/E220.ino deleted file mode 100644 index 20c6fe4..0000000 --- a/test/formerE220lib/E220/E220.ino +++ /dev/null @@ -1,38 +0,0 @@ -#include - -int count = 0; //for test message - -byte tx_payload[199] = { 0 }; -byte rx_payload[199] = { 0 }; - -E220 e220(0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00 - -void setup() { - Serial1.setFIFOSize(512); //rp2040のとき必要 - Serial.begin(9600); - Serial1.begin(9600); -} - -void loop() { - static int rssi = 0; - if (count > 10) { - count = 0; - } - count++; - int Rxlength = 0; - e220.GenerateTestMsg_2(tx_payload, count, 199); - e220.TransmissionData(tx_payload); - Rxlength = e220.ReceiveData(rx_payload, &rssi); - if (Rxlength == 0) { - Serial.println("No data received"); - } else { - Serial.write(rx_payload, Rxlength); - Serial.println(); - Serial.print("RSSI[dBm]:"); - Serial.println(rssi); - delay(10); - e220.ResetBuff(rx_payload); - e220.ResetBuff(tx_payload); - } - delay(2000); -} diff --git a/test/formerE220lib/E220_can/E220_can.ino b/test/formerE220lib/E220_can/E220_can.ino deleted file mode 100644 index a6de38c..0000000 --- a/test/formerE220lib/E220_can/E220_can.ino +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#define CAN0_CS 0 -#define CAN0_INT 1 - -#define SEND_PERIOD_MS 1000 - -E220 e220(0xFF, 0xFF, 0x00); //TARGETADRESS=0xFFFF,CHANNEL=0x00 -CCP_MCP2515 CCP(CAN0_CS, CAN0_INT); //CAN - -/*E220configuration -- UARTbaudrate:115200bps -- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 -- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 -- target address: 0xFFFF(broradcast) -- power: 13dBm -- SF: TBD -*/ - - -union unionfloat { - float f; - byte b[4]; -}; -union unionuint32 { - uint32_t i; - byte b[4]; -}; - - - -void setup() { - Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする - Serial.begin(9600); - Serial1.begin(115200); //E220のUART - CCP.begin(); -} - -void loop() { - static byte tx_payload[199] = { 0 }; - static bool send_allowed = false; //送信許可 - static bool payload_semapho = false; //payloadの生成が終わるまで送信を許可しない - static uint32_t latest_send_time = 0; //最後に送信した時間 - GeneratePayload(tx_payload, payload_semapho); - if ((millis() - latest_send_time) > SEND_PERIOD_MS) { //前の送信から一定時間経過しているか - send_allowed = true; - } - if (send_allowed == true && payload_semapho == false) { - e220.TransmissionData(tx_payload); - latest_send_time = millis(); //送信済みの時間を記録 - send_allowed = false; - } -} - -void GeneratePayload(byte* tx_payload, bool _payload_semapho) { - _payload_semapho = true; - unionuint32 mcutime_ms; - unionfloat buf; - CCP.read_device(); - mcutime_ms.i = millis(); - byte status_byte = 0x00; - - switch (CCP.id) { - case CCP_nose_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b10000000; - } - break; - case CCP_surface_pressure1_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b01000000; - } - break; - case CCP_surface_pressure2_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b00100000; - } - break; - case CCP_surface_pressure3_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b00010000; - } - break; - case CCP_surface_pressure4_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b00001000; - } - break; - case CCP_surface_pressure5_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b00000100; - } - break; - case CCP_surface_pressure6_status: - if (CCP.str_match("OK", 2)) { - status_byte |= 0b00000010; - } - break; - case CCP_nose_adc://自信ない - //adcの生データを16進数表示の文字列で送信 - for (int i = 0; i < 6; i++) { - tx_payload[i + 5] = CCP.msg.string_msg.string[i]; - } - break; - case CCP_nose_temperature: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 11] = buf.b[i]; - } - break; - case CCP_nose_barometic_pressure: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 15] = buf.b[i]; - } - break; - case CCP_nose_voltage: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 19] = buf.b[i]; - } - break; - case CCP_surface_pressure1_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 23] = buf.b[i]; - } - break; - case CCP_surface_pressure2_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 27] = buf.b[i]; - } - break; - case CCP_surface_pressure3_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 31] = buf.b[i]; - } - break; - case CCP_surface_pressure4_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 35] = buf.b[i]; - } - break; - case CCP_surface_pressure5_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 39] = buf.b[i]; - } - break; - case CCP_surface_pressure6_pressure_pa: - buf.f = CCP.data_float(); - for (int i = 0; i < 4; i++) { - tx_payload[i + 43] = buf.b[i]; - } - break; - default: - break; - } - for (int i = 0; i < 4; i++) { - tx_payload[i] = mcutime_ms.b[i]; - } - tx_payload[4] = status_byte; - _payload_semapho = false; -} diff --git a/test/formerE220lib/E220_ground/E220_ground.ino b/test/formerE220lib/E220_ground/E220_ground.ino deleted file mode 100644 index 00d8cb4..0000000 --- a/test/formerE220lib/E220_ground/E220_ground.ino +++ /dev/null @@ -1,135 +0,0 @@ -#include - -#define SEND_PERIOD_MS 1000 - -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 - -/*E220configuration -- UARTbaudrate:115200bps -- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 -- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 -- target address: 0xFFFF(broradcast) -- power: 13dBm -- SF: TBD -*/ - -/* -------configuration------ -Address(HEX):00 -UARTBaudrate:115200bps -SF:11 -BW:250kHz -SubpacketLength:200bytes -RSSINoise:Not Available -TxPower:0dBm -Channel:10 -RSSIByte:Available -TxMethod:Transparent mode -WORCycle:500ms -------------------------- -*/ - -union unionfloat { - float f; - byte b[4]; -}; -union unionuint32 { - uint32_t i; - byte b[4]; -}; - -void setup() { - Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする - Serial.begin(115200); - Serial1.begin(115200); //E220のUART -} - -void loop() { - static byte rx_payload[199] = { 0 }; - int rssi = 0; - int Rxlength = 0; - Rxlength = e220.ReceiveData(rx_payload, &rssi); - unionuint32 mcutime_ms; - byte nose_adc_raw[6] = { 0x00 }; - unionfloat nose_temperature; - unionfloat nose_barometic_presure; - unionfloat nose_different_pressure; - unionfloat nose_voltage; - unionfloat surface1_pressure; - unionfloat surface2_pressure; - unionfloat surface3_pressure; - unionfloat surface4_pressure; - unionfloat surface5_pressure; - unionfloat surface6_pressure; - byte status = 0x00; - for (int i = 0; i < 4; i++) { - mcutime_ms.b[i] = rx_payload[i]; - } - status = rx_payload[4]; - for (int i = 0; i < 6; i++) { - nose_adc_raw[i] = rx_payload[i + 5]; - } - for (int i = 0; i < 4; i++) { - nose_temperature.b[i] = rx_payload[i + 11]; - } - for (int i = 0; i < 4; i++) { - nose_barometic_presure.b[i] = rx_payload[i + 15]; - } - for (int i = 0; i < 4; i++) { - nose_different_pressure.b[i] = rx_payload[i + 19]; - } - for (int i = 0; i < 4; i++) { - nose_voltage.b[i] = rx_payload[i + 23]; - } - for (int i = 0; i < 4; i++) { - surface1_pressure.b[i] = rx_payload[i + 27]; - } - for (int i = 0; i < 4; i++) { - surface2_pressure.b[i] = rx_payload[i + 31]; - } - for (int i = 0; i < 4; i++) { - surface3_pressure.b[i] = rx_payload[i + 35]; - } - for (int i = 0; i < 4; i++) { - surface4_pressure.b[i] = rx_payload[i + 39]; - } - for (int i = 0; i < 4; i++) { - surface5_pressure.b[i] = rx_payload[i + 43]; - } - for (int i = 0; i < 4; i++) { - surface6_pressure.b[i] = rx_payload[i + 47]; - } - - if (Rxlength > 0) { - Serial.print("RSSI[dBm]:"); - Serial.print(rssi); - Serial.print(",rocket_time_ms:"); - Serial.print(mcutime_ms.i); - Serial.print(",status:"); - Serial.print(status); - Serial.print(","); - for (int i = 0; i < 6; i++) { - Serial.print(nose_adc_raw[i]); - Serial.print(","); - } - Serial.print(nose_temperature.f, 6); - Serial.print(","); - Serial.print(nose_barometic_presure.f, 6); - Serial.print(","); - Serial.print(nose_different_pressure.f, 6); - Serial.print(","); - Serial.print(nose_voltage.f, 6); - Serial.print(","); - Serial.print(surface1_pressure.f, 6); - Serial.print(","); - Serial.print(surface2_pressure.f, 6); - Serial.print(","); - Serial.print(surface3_pressure.f, 6); - Serial.print(","); - Serial.print(surface4_pressure.f, 6); - Serial.print(","); - Serial.println(surface5_pressure.f, 6); - Serial.print(","); - Serial.println(surface6_pressure.f, 6); - } -} \ No newline at end of file diff --git a/test/formerE220lib/E220_vertual_rocket/E220_vertual_rocket.ino b/test/formerE220lib/E220_vertual_rocket/E220_vertual_rocket.ino deleted file mode 100644 index f20a88b..0000000 --- a/test/formerE220lib/E220_vertual_rocket/E220_vertual_rocket.ino +++ /dev/null @@ -1,100 +0,0 @@ -#include -#define CAN0_CS 0 -#define CAN0_INT 1 - -#define SEND_PERIOD_MS 1000 - -E220 e220(0xFF, 0xFF, 0x0A); //TARGETADRESS=0xFFFF,CHANNEL=0x0A=10ch=ARIB 34-35 - -/*E220configuration -- UARTbaudrate:115200bps -- bandwith: 250kHz//審査書の値なので運営からの指示以外変更禁止 -- channel: 0x0A(ARIB 34-35)//審査書の値なので運営からの指示以外変更禁止 -- target address: 0xFFFF(broradcast) -- power: 13dBm -- SF: TBD -*/ - -/*------configuration------ -Address(HEX):00 -UARTBaudrate:115200bps -SF:11 -BW:250kHz -SubpacketLength:200bytes -RSSINoise:Not Available -TxPower:0dBm -Channel:10 -RSSIByte:Available -TxMethod:Transparent mode -WORCycle:500ms --------------------------*/ - -union unionfloat { - float f; - byte b[4]; -}; -union unionuint32 { - uint32_t i; - byte b[4]; -}; - -void setup() { - Serial1.setFIFOSize(512); //E220のサブパケ200byteより大きいサイズにする - Serial.begin(9600); - Serial1.begin(115200); //E220のUART -} -void loop() { - static byte tx_payload[199] = { 0 }; - static bool send_allowed = false; //送信許可 - static bool payload_semapho = false; //payloadの生成が終わるまで送信を許可しない - static uint32_t latest_send_time = 0; //最後に送信した時間 - GeneratePayload(tx_payload, payload_semapho); - if ((millis() - latest_send_time) > SEND_PERIOD_MS) { //前の送信から一定時間経過しているか - send_allowed = true; - } - if (send_allowed == true && payload_semapho == false) { - Serial.println("send!"); - e220.TransmissionData(tx_payload); - latest_send_time = millis(); //送信済みの時間を記録 - send_allowed = false; - } -} - -void GeneratePayload(byte* tx_payload, bool _payload_semapho) { - _payload_semapho = true; - unionuint32 mcutime_ms; - unionfloat buf; - mcutime_ms.i = millis(); - byte status_byte = 0x00; - - buf.f = 1.1111; - tx_payload[11] = buf.b[0]; - tx_payload[12] = buf.b[1]; - tx_payload[13] = buf.b[2]; - tx_payload[14] = buf.b[3]; - - buf.f = 2.2222; - tx_payload[15] = buf.b[0]; - tx_payload[16] = buf.b[1]; - tx_payload[17] = buf.b[2]; - tx_payload[18] = buf.b[3]; - - buf.f = 1.3232; - tx_payload[19] = buf.b[0]; - tx_payload[20] = buf.b[1]; - tx_payload[21] = buf.b[2]; - tx_payload[22] = buf.b[3]; - - buf.f = 0.2; - tx_payload[43] = buf.b[0]; - tx_payload[44] = buf.b[1]; - tx_payload[45] = buf.b[2]; - tx_payload[46] = buf.b[3]; - - tx_payload[0] = mcutime_ms.b[0]; - tx_payload[1] = mcutime_ms.b[1]; - tx_payload[2] = mcutime_ms.b[2]; - tx_payload[3] = mcutime_ms.b[3]; - tx_payload[4] = 0x44; - _payload_semapho = false; -}