Commit 7a53b981 authored by captainwong's avatar captainwong

工程主机串口通信协议.md working...

parent e237ecd8
# 工程主机串口通信协议
## EB B1 命令内报警码与安定宝事件码对照表
9600, N, 8, 1
SUM = DATA(N) = DATA(0) + DATA(1) + ... + DATA(N-1)
## EB AB addr data sum
* PC到主机,按键
* addr: PC模拟键盘地址,1~4,暂时固定为3
* data: 按键码
|按键码|按键|
|-----|----|
|00|无按键动作|
|01|1|
|02|2|
|03|3|
|04|4|
|05|5|
|06|6|
|07|7|
|08|8|
|09|9|
|0A|0|
|0B|*|
|0C|#|
|0D|布防|
|0E|半布防|
|0F|撤防|
|10|紧急报警|
|11|录音|
|12|放音|
|13|停止|
## EB B1 data0 data1 data2 code data4 sum
* data0: 命令字总字长,固定为8
* data1: 防区号高位
* data2: 防区号低位
* data4: 00 表示data1与data2为主机直属防区号,01~F0 表示data1与data2为分机防区号(已废弃),EE 表示分机自身状态(已废弃 )
* code: 报警码
* 报警码与安定宝事件码对照表
|报警码|安定宝事件码|含义|
|------|----------|----|
......
......@@ -3,6 +3,7 @@
#include "../../include/ademco_event.h"
#define ENABLE_COMMON_MACHINE_TYPE_TO_STRING
#define ENABLE_COMMON_ZONE_PROPERTY_TO_STRING
#define ENABLE_G250_KEY_TO_STRING
#include "../../include/hb_detail.h"
#include "../../include/hb_helper.h"
#include <jlib/win32/UnicodeTool.h>
......@@ -371,12 +372,39 @@ void print_available_zone_props()
void print_g250_alarm_codes()
{
printf("## EB B1 命令内报警码与安定宝事件码对照表\n\n");
using namespace g250;
printf("# 工程主机串口通信协议\n\n");
printf("9600, N, 8, 1\n\n");
printf("SUM = DATA(N) = DATA(0) + DATA(1) + ... + DATA(N-1)\n\n");
// 按键码
printf("\n\n## EB AB addr data sum\n");
printf("* PC到主机,按键\n");
printf("* addr: PC模拟键盘地址,1~4,暂时固定为3\n");
printf("* data: 按键码\n\n");
printf("|按键码|按键|\n");
printf("|-----|----|\n");
for (Key k = Key::Key_NULL; k <= Key::Key_STOP_ALARM; k = Key(k + 1)) {
auto s = keyToString(k);
if (s) {
printf("|%02X|%s|\n", k, jlib::win32::utf16_to_mbcs(s).c_str());
}
}
// EB B1 报警码
printf("\n\n## EB B1 data0 data1 data2 code data4 sum\n");
printf("* data0: 命令字总字长,固定为8\n");
printf("* data1: 防区号高位\n");
printf("* data2: 防区号低位\n");
printf("* data4: 00 表示data1与data2为主机直属防区号,01~F0 表示data1与data2为分机防区号(已废弃),EE 表示分机自身状态(已废弃)\n");
printf("* code: 报警码\n");
printf("* 报警码与安定宝事件码对照表\n\n");
printf("|报警码|安定宝事件码|含义|\n");
printf("|------|----------|----|\n");
using namespace g250;
static Char codes[] = {
g250::MachineStatus::Arm,
......@@ -415,22 +443,29 @@ void print_g250_alarm_codes()
int main()
{
printf("### 主机状态\n\n");
printEvents(statusEvents, _countof(statusEvents));
if (0) {
printf("### 主机状态\n\n");
printEvents(statusEvents, _countof(statusEvents));
printf("### 防区报警\n\n");
printEvents(alarmEvents, _countof(alarmEvents));
printf("### 防区异常\n\n");
printEvents(excepEvents, _countof(excepEvents));
printf("### 防区报警\n\n");
printEvents(alarmEvents, _countof(alarmEvents));
printf("### *恒博私有事件码*\n\n");
printEvents(privateEvents, _countof(privateEvents));
printf("### 防区异常\n\n");
printEvents(excepEvents, _countof(excepEvents));
print_machineTypes();
print_imgs();
printf("### *恒博私有事件码*\n\n");
printEvents(privateEvents, _countof(privateEvents));
print_available_zone_props();
print_machineTypes();
print_imgs();
print_available_zone_props();
} else {
print_g250_alarm_codes();
}
print_g250_alarm_codes();
}
\ No newline at end of file
......@@ -1283,6 +1283,30 @@ inline char keyToPrintableChar(Key key) {
}
}
#ifdef ENABLE_G250_KEY_TO_STRING
inline const wchar_t* keyToString(Key key) {
static wchar_t s[2] = { L'\0' };
switch (key) {
case Key_1: case Key_2: case Key_3:
case Key_4: case Key_5:
case Key_6: case Key_7:
case Key_8: case Key_9: s[0] = static_cast<wchar_t>(key + L'0'); return s;
case Key_0: return L"0";
case Key_ASTERISK: return L"*";
case Key_SHARP: return L"#";
case Key_ARM: return L"布防";
case Key_HALF_ARM: return L"半布防";
case Key_DISARM: return L"撤防";
case Key_EMERGENCY: return L"紧急报警";
case Key_RECORD_SOUND: return L"录音";
case Key_PLAY_SOUND: return L"放音";
case Key_STOP_SOUND: return L"停止";
case Key_NULL: return L"无按键动作";
default: return nullptr;
}
}
#endif
//! PC的模拟键盘序号为3
static constexpr Char PC_KEYBOARD_IDX = 3;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment