-
Notifications
You must be signed in to change notification settings - Fork 0
E220 can merge #27
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
Open
nihinihikun
wants to merge
17
commits into
main
Choose a base branch
from
E220_can_merge
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
E220 can merge #27
Changes from 15 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
32488c9
Create E220_can.ino
nihinihikun a00e6c9
Update E220_can.ino
nihinihikun 02e3f56
Update E220_can.ino
nihinihikun e8c6fc3
fix spellmiss, add E220_ground
nihinihikun 6a58853
Update E220_ground.ino
nihinihikun feb574f
test-payload sending
nihinihikun 35e495a
Update E220_ground.ino
nihinihikun a535879
fix white space
nihinihikun 901ac3f
refactoring E220_can
nihinihikun a57df0d
seperate roles(can, E220)
nihinihikun 5638d4d
change address, sf, UARTbaudrate
nihinihikun a3cca00
送信関係を修正.送信時間を短縮
nihinihikun 848bb91
Update MainE220.ino
nihinihikun 3b6b1c1
fix for update E220(v2.0.2)
nihinihikun dbb9867
fix white spaces
nihinihikun 992d1ef
コメント対応
nihinihikun 6c77bf6
Update MainE220.ino
nihinihikun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| #include <E220.h> | ||
| #include <CCP.h> | ||
| #include <CCP_MCP2515.h> | ||
| #define CAN0_CS 0 | ||
| #define CAN0_INT 1 | ||
|
|
||
| #define SEND_PERIOD_MS 1000 | ||
|
|
||
| E220 e220(Serial1, 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; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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"); | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[cpplint] reported by reviewdog 🐶
Redundant blank line at the end of a code block should be deleted. [whitespace/blank_line] [3]