Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIF・E220統合 #35

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/arduino_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ jobs:
version: latest
- name: Adafruit LPS35HW
version: latest
- name: E220-900T22S-JP
version: 2.0.2
- source-url: https://github.com/uChip/MCP342X.git
- source-url: https://github.com/core-rocket/CCP.git
- source-url: https://github.com/core-rocket/Opener.git
Expand Down
140 changes: 140 additions & 0 deletions Ground_E220/Ground_E220.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
#include <E220.h>

#define SEND_PERIOD_MS 1000

E220 e220(Serial1, 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.ReceiveDataVariebleLength(rx_payload, 47, &rssi); //surface6_pressureまでの長さ
unionuint32 mcutime_ms;
byte nose_adc_raw[6] = { 0x00 };
unionfloat nose_temperature;
unionfloat nose_barometic_presure;
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_voltage.b[i] = rx_payload[i + 19];
}
for (int i = 0; i < 4; i++) {
surface1_pressure.b[i] = rx_payload[i + 23];
}
for (int i = 0; i < 4; i++) {
surface2_pressure.b[i] = rx_payload[i + 27];
}
for (int i = 0; i < 4; i++) {
surface3_pressure.b[i] = rx_payload[i + 31];
}
for (int i = 0; i < 4; i++) {
surface4_pressure.b[i] = rx_payload[i + 35];
}
for (int i = 0; i < 4; i++) {
surface5_pressure.b[i] = rx_payload[i + 39];
}
for (int i = 0; i < 4; i++) {
surface6_pressure.b[i] = rx_payload[i + 43];
}

if (Rxlength > 0) {
Serial.print("RSSI[dBm]:");
Serial.print(rssi);
Serial.print(",rocket_time_ms:");
Serial.print(mcutime_ms.i);
Serial.print(",status:");
StatusSerialPrint(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_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.print(surface5_pressure.f, 6);
Serial.print(",");
Serial.println(surface6_pressure.f, 6);
}
}

void StatusSerialPrint(byte _status) {
for (int i = 0; i < 8; i++) {
if ((_status >> 7 - i) & 0x01) {
Serial.print("1");
} else {
Serial.print("0");
}
}
}
24 changes: 21 additions & 3 deletions Main/Main.ino
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ String response = "";
bool need_response_usb = false;
bool need_response_es920 = false;

// E220
SerialPIO Serial_E220(E220_TX, E220_RX, 256);

// W25Q128

// Opener
Expand Down Expand Up @@ -130,6 +133,7 @@ void setup() {
Serial_GNSS.begin(9600);
Serial_Valve.begin(115200);
Serial_MIF.begin(921600);
Serial_E220.begin(115200);

opener.init();
}
Expand Down Expand Up @@ -252,6 +256,11 @@ void loop() {
valve_mode = Serial_Valve.read();
}

// E220パススルー
while(Serial_MIF.available()){
//Serial_E220.write(Serial_MIF.read());
Serial_MIF.read();
}

// テレメトリ生成
downlink = "";
Expand Down Expand Up @@ -362,25 +371,34 @@ void loop() {

if (uplink == "mif-on") {
Serial_MIF.print("mif-on\n");
set_response("on");
}
if (uplink == "mif-off") {
Serial_MIF.print("mif-off\n");
set_response("off");
}
if (uplink == "flash-start") {
Serial_MIF.print("flash-start\n");
set_response("start");
}
if (uplink == "flash-stop") {
Serial_MIF.print("flash-stop\n");
set_response("stop");
}
if (uplink == "flash-clear") {
Serial_MIF.print("flash-clear\n");
set_response("clear");
}

float uplink_float = uplink.toFloat();
if (uplink_float != 0) {
opener.set_open_threshold_time_ms(uplink_float * 1000);
response = "open:" + String(static_cast<float>(opener.get_open_threshold_time_ms()) / 1000.0, 2);
need_response_usb = true;
need_response_es920 = true;
set_response("open:" + String(static_cast<float>(opener.get_open_threshold_time_ms()) / 1000.0, 2));
}
}

void set_response(String str) {
response = str;
need_response_usb = true;
need_response_es920 = true;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[cpplint] reported by reviewdog 🐶
Could not find a newline character at the end of the file. [whitespace/ending_newline] [5]

Loading
Loading