티스토리 뷰
void h_TreatSerial(){
if(!RxString_Serial.startsWith("VI")) return;
int Index1 = RxString_Serial.indexOf("/");
if(Index1 < 0) return;
int Index2 = RxString_Serial.indexOf(":");
if(Index1 >= Index2) return;
String VICName = RxString_Serial.substring(0, Index1);
char CommandType0 = RxString_Serial.charAt(Index1+1);
char CommandType1 = RxString_Serial.charAt(Index1+2);
String ValueString = RxString_Serial.substring(Index2+1);
int CommandValue = -1;
char Char1 = ValueString.charAt(0);
if((isDigit(Char1)) || (Char1 == '-')) CommandValue = (ValueString).toInt();
if(VICName.equals(String(DEVICENAME))){
StartTime_LastRequest = millis();
switch(CommandType0){
case 'D': // Data Request ?
{
if(!IsRegistered) return;
if(FixedChannel >= 0){
h_SendData(FixedChannel);
return;
}
switch(CommandType1){
case '?':
h_SendData(-1);
break;
case '0':
case '1':
case '2':
case '3':
h_SendData(int(CommandType1)-0x30);
break;
}
}
break;
case 'A':
if(CommandType1 == 'D'){
if(CommandValue == DeviceAddress) IsRegistered = true;
}
if(CommandType1 == 'N'){
DEVICENAME = ValueString;
}
break;
case 'C': // Clear ...
if(CommandType1 == 'P') h_InitializeDeviceParameters(CommandValue-1);
if(CommandType1 == 'V') h_InitializeDeviceValues(CommandValue-1);
if(CommandType1 == 'A') h_InitializeDeviceAddress();
if(CommandType1 == 'C') b_SetFixedChannel(CommandValue);
if(CommandType1 == '0') MeasuredValues[0].h_InitializeValues(ElapsedMins);
if(CommandType1 == '1') MeasuredValues[1].h_InitializeValues(ElapsedMins);
if(CommandType1 == '2') MeasuredValues[2].h_InitializeValues(ElapsedMins);
if(CommandType1 == '3') MeasuredValues[3].h_InitializeValues(ElapsedMins);
break;
case 'M': // Monitoring
{
int ChannelNo = atoi(CommandType1);
if(ChannelNo < 0) return;
if(ChannelNo >= CHANNELNUMBER) return;
if(CommandValue == 0) MeasuredValues[ChannelNo].IsMonitored = false;
if(CommandValue == 1) MeasuredValues[ChannelNo].IsMonitored = true;
}
break;
case 'P': // Port control
{
int PortNo = 0;
PortNo = (int)(String(CommandType1).toInt());
if(CommandValue == 1) digitalWrite(PortNo, HIGH);
if(CommandValue == 0) digitalWrite(PortNo, LOW);
}
break;
}
}else if(VICName.equals(String(COMMONDEVICENAME))){
switch(CommandType0){
case 'C': // Request initialization
if(CommandType1 == 'P') h_InitializeDeviceParameters(CommandValue-1);
if(CommandType1 == 'V') h_InitializeDeviceValues(CommandValue-1);
if(IsRegistered) break;
if(CommandType1 == 'A') h_InitializeDeviceAddress();
break;
case 'A': // Checking Address
if(CommandType1 == '?') h_ChecknResponse(CommandValue);
break;
}
}
}
반응형
'SWDesk > Firmware' 카테고리의 다른 글
[Arduino] JSON 예제 (0) | 2020.11.25 |
---|---|
[BPM] Firmware Source for Master (0) | 2020.07.19 |
[BMS] Command Process for CD Devices (0) | 2020.07.19 |
[BMS] Command Process for LoRa Device (0) | 2020.07.19 |
[BMS] Command Process for Master (0) | 2020.07.19 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Innovation&Hurdles
- 둎
- 전압
- image
- 티스토리챌린지
- 심심풀이치매방지기
- Innovations
- 전류
- Hurdles
- 치매방지
- 혁신
- 전압전류모니터링
- 오블완
- Decorator
- arduino
- DYOV
- 배프
- Video
- bilient
- 혁신과허들
- 아두이노
- 심심풀이
- BSC
- Innovations&Hurdles
- 절연형
- ServantClock
- 허들
- 치매
- badp
- 빌리언트
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
글 보관함