大季 矢花
/
MB2019_main_alltimes
aa
Communication/RS485/LineHub/LineHub.cpp@60:24ebb611f26e, 2019-12-12 (annotated)
- Committer:
- yabahiro
- Date:
- Thu Dec 12 07:16:20 2019 +0000
- Revision:
- 60:24ebb611f26e
- Parent:
- 21:e3b58d675c1c
aa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
M_souta | 21:e3b58d675c1c | 1 | #include "mbed.h" |
M_souta | 21:e3b58d675c1c | 2 | #include "LineHub.h" |
M_souta | 21:e3b58d675c1c | 3 | #include "../../../CommonLibraries/RingBuffer/RingBuffer.h" |
M_souta | 21:e3b58d675c1c | 4 | #include "../../../System/Process/Process.h" |
M_souta | 21:e3b58d675c1c | 5 | #include "../../../System/Using.h" |
M_souta | 21:e3b58d675c1c | 6 | |
M_souta | 21:e3b58d675c1c | 7 | static char RS485Line[RS485_BUFFER_LINE]; |
M_souta | 21:e3b58d675c1c | 8 | RINGBUFFER::RingBuffer RS485LineBuffer = RINGBUFFER::RingBuffer(RS485Line, RS485_BUFFER_LINE); |
M_souta | 21:e3b58d675c1c | 9 | |
M_souta | 21:e3b58d675c1c | 10 | int lineData[8]; |
M_souta | 21:e3b58d675c1c | 11 | |
M_souta | 21:e3b58d675c1c | 12 | namespace LINEHUB { |
M_souta | 21:e3b58d675c1c | 13 | |
M_souta | 21:e3b58d675c1c | 14 | |
M_souta | 21:e3b58d675c1c | 15 | void LineHub::Initialize() { |
M_souta | 21:e3b58d675c1c | 16 | for(int i = 0; i < 8; i++) { |
M_souta | 21:e3b58d675c1c | 17 | lineData[i] = 0; |
M_souta | 21:e3b58d675c1c | 18 | } |
M_souta | 21:e3b58d675c1c | 19 | |
M_souta | 21:e3b58d675c1c | 20 | } |
M_souta | 21:e3b58d675c1c | 21 | |
M_souta | 21:e3b58d675c1c | 22 | void LineHub::Update() { |
M_souta | 21:e3b58d675c1c | 23 | if(RS485LineBuffer.IsFullup()) { |
M_souta | 21:e3b58d675c1c | 24 | for(int i = 0; i < 8; i++) { |
M_souta | 21:e3b58d675c1c | 25 | lineData[i] = (int)RS485LineBuffer.GetData(); |
M_souta | 21:e3b58d675c1c | 26 | } |
M_souta | 21:e3b58d675c1c | 27 | } |
M_souta | 21:e3b58d675c1c | 28 | } |
M_souta | 21:e3b58d675c1c | 29 | |
M_souta | 21:e3b58d675c1c | 30 | int LineHub::GetPara(int num) { |
M_souta | 21:e3b58d675c1c | 31 | return lineData[num]; |
M_souta | 21:e3b58d675c1c | 32 | } |
M_souta | 21:e3b58d675c1c | 33 | } |