-
Notifications
You must be signed in to change notification settings - Fork 0
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
Update configuration APIs #6
Conversation
3b68c11
to
0eff0c5
Compare
0eff0c5
to
633ea93
Compare
|
e220/params.go
Outdated
var uartSerialPortRateStrings map[uint8]string = map[uint8]string{ | ||
UartSerialPortRate1200Bps: "UartSerialPortRate1200Bps", | ||
UartSerialPortRate2400Bps: "UartSerialPortRate2400Bps", | ||
UartSerialPortRate4800Bps: "UartSerialPortRate4800Bps", | ||
UartSerialPortRate9600Bps: "UartSerialPortRate9600Bps", | ||
UartSerialPortRate19200Bps: "UartSerialPortRate19200Bps", | ||
UartSerialPortRate38400Bps: "UartSerialPortRate38400Bps", | ||
UartSerialPortRate57600Bps: "UartSerialPortRate57600Bps", | ||
UartSerialPortRate115200Bps: "UartSerialPortRate115200Bps", | ||
} | ||
|
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.
この書き方の場合、 RAM に乗ってしまう (208 byte) ので、 switch case で書いていったほうが良い (※) のかも。
※本当かどうか要調査
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.
調査のために map[uint8]string
に要素を一つ追加して RAM が増加するかを調査した。
結論: 以下の変更により RAM のサイズは変化しなかった
→ map には cap があるためこうなる
(以下 examples/e220/conf
のプログラムを build)
$ tinygo build --size=short -target=feather-m4-can
code data bss | flash ram
76056 3024 6920 | 79080 9944
$ git diff
diff --git a/e220/params.go b/e220/params.go
index a904e83..20aa2a4 100644
--- a/e220/params.go
+++ b/e220/params.go
@@ -159,4 +159,5 @@ var worCycleSettingString map[uint8]string = map[uint8]string{
WorCycleSetting3000ms: "WorCycleSetting3000ms",
WorCycleSetting3500ms: "WorCycleSetting3500ms",
WorCycleSetting4000ms: "WorCycleSetting4000ms",
+ 0xFF: "test",
}
$ tinygo build --size=short -target=feather-m4-can
code data bss | flash ram
76056 3024 6920 | 79080 9944
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.
↑とは逆に1要素削除すると RAM のサイズが減少した。
よって、map を定義しないことで RAM の削減ができるため、RAM に情報を置かない方法で実装するように変更する。
$ git diff
$ tinygo build --size=short -target=feather-m4-can
code data bss | flash ram
76056 3024 6920 | 79080 9944
$ git diff
diff --git a/e220/params.go b/e220/params.go
index a904e83..5156b07 100644
--- a/e220/params.go
+++ b/e220/params.go
@@ -158,5 +158,4 @@ var worCycleSettingString map[uint8]string = map[uint8]string{
WorCycleSetting2500ms: "WorCycleSetting2500ms",
WorCycleSetting3000ms: "WorCycleSetting3000ms",
WorCycleSetting3500ms: "WorCycleSetting3500ms",
- WorCycleSetting4000ms: "WorCycleSetting4000ms",
}
$ tinygo build --size=short -target=feather-m4-can
code data bss | flash ram
76040 2940 6920 | 78980 9860
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.
map を Stringer method 内へ移しただけの ver 3c057a5
RAM から code への移動はできたが、map がスタックに置かれると考えられるため、switch 文へ変更する。
$ tinygo build --size=short -target=feather-m4-can
code data bss | flash ram
77496 1612 6920 | 79108 8532
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.
#6 (comment) 以下より、案 3 を採用する。
|
b1929f2
to
74b8ca7
Compare
74b8ca7
to
2ad2bc8
Compare
案 3 に基づき以下にて変更した。
|
#2 (comment)