티스토리 뷰
void h_TreatSerialCommand(){
if(!RxString_Serial.startsWith("CD")) return;
#if(USER_SERIAL == 901)
Serial.println("");
Serial.println(RxString_Serial);
#endif
int Index1 = RxString_Serial.indexOf("/");
if(Index1 < 0) return;
int Index2 = RxString_Serial.indexOf(":");
if(Index1 >= Index2) return;
String DeviceName = RxString_Serial.substring(0, Index1);
char CommandType0 = RxString_Serial.charAt(Index1+1);
char CommandType1 = RxString_Serial.charAt(Index1+2);
int CommandValue = (RxString_Serial.substring(Index2+1)).toInt();
if(DeviceName.equals(String(DEVICENAME))){
StartTime_LastRequest = millis();
switch(CommandType0){
case 'P': // Port control
{
int PortValue = 0;
int PortNo = 0;
if(CommandType1 == 'R'){ // Port control for RELAY
PortNo = PIN_RELAY;
}else if(CommandType1 == 'O'){ // Port control for RELAY
PortNo = PIN_DIGITALOUT;
} else{
PortNo = (int)(String(CommandType1).toInt());
if(PortNo == 0) return;
}
if(CommandValue == 1) digitalWrite(PortNo, HIGH);
if(CommandValue == 0) digitalWrite(PortNo, LOW);
}
break;
case 'A':
if(CommandType1 == 'D'){
if(CommandValue == DeviceAddress) IsRegistered = true;
}
break;
case 'Q': // Request
if(CommandType1 == 'D') h_SendDeviceStatus();
break;
case 'C': // Command
if(CommandType1 == 'I') h_InitializeDeviceParameters(); // Initialize
if(CommandType1 == 'C') h_SetChargeCondition(CommandValue);
if(CommandType1 == 'D') h_SetDischargeCondition(CommandValue);
if(CommandType1 == 'A') AlarmTime_Minute = CommandValue; // Alarm
break;
}
}else if(DeviceName.equals(String(COMMONDEVICENAME))){
switch(CommandType0){
case 'C': // Request initialization
if(CommandType1 == 'P') h_InitializeDeviceParameters();
if(CommandType1 == 'A') h_InitializeDeviceAddress();
break;
case 'A': // Checking Address
if(CommandType1 == '?') h_ChecknResponse(CommandValue);
break;
}
}
}
반응형
'SWDesk > Firmware' 카테고리의 다른 글
[BPM] Firmware Source for Master (0) | 2020.07.19 |
---|---|
[BMS] Command Process for VIC Instrument (0) | 2020.07.19 |
[BMS] Command Process for LoRa Device (0) | 2020.07.19 |
[BMS] Command Process for Master (0) | 2020.07.19 |
[BPM] Firmware Source for Master (0) | 2020.06.15 |
반응형
250x250
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 배프
- BSC
- 치매
- ServantClock
- Video
- 심심풀이치매방지기
- 허들
- Hurdles
- badp
- 둎
- DYOV
- Decorator
- 전압전류모니터링
- 혁신
- Innovations&Hurdles
- 치매방지
- 빌리언트
- 오블완
- image
- 아두이노
- arduino
- 절연형
- 혁신과허들
- 티스토리챌린지
- Innovation&Hurdles
- Innovations
- 전압
- bilient
- 심심풀이
- 전류
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함