42 boost::property_tree::ptree cfg, module_cfg;
44 module_cfg.add(
"port",
"4242");
45 module_cfg.add(
"reader",
"WIEGAND1");
46 module_cfg.add(
"stream_mode",
"true");
48 cfg.add(
"name",
"RPLETH");
49 cfg.add_child(
"module_config", module_cfg);
50 return test_run_module<RplethModule>(&ctx_, pipe, cfg);
54 : w1(ctx_,
"WIEGAND1")
65 ciruclar_buf_.write(
reinterpret_cast<const unsigned char *
>(data.c_str()),
80 std::string connection_identity, data;
82 zmqpp::socket client(ctx_, zmqpp::socket_type::stream);
83 client.connect(
"tcp://127.0.0.1:4242");
86 assert(msg.parts() == 2);
87 msg >> connection_identity;
88 assert(msg.size(1) == 0);
89 return std::move(client);
96 const std::vector<uint8_t> card_binary)
99 std::string connection_identity, data;
102 msg >> connection_identity;
106 ASSERT_TRUE(rpleth_packet.
isGood);
107 ASSERT_EQ(8, +rpleth_packet.
dataLen);
108 ASSERT_EQ(8, +rpleth_packet.
data.size());
110 ASSERT_EQ(card_binary, rpleth_packet.
data);
120 std::vector<uint8_t> out;
121 std::vector<uint8_t> card_binary = {0x00, 0x00, 0x00, 0x00,
122 0xff, 0xff, 0xff, 0xff};
125 ASSERT_EQ(card_binary, out);
127 card_binary = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
129 ASSERT_EQ(card_binary, out);
131 card_binary = {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x85};
133 ASSERT_EQ(card_binary, out);
135 card_binary = {0x00, 0x00, 0x00, 0x00, 0x80, 0x81, 0x61, 0x40};
137 ASSERT_EQ(card_binary, out);
145 zmqpp::socket client = connect_to_rpleth();
148 bus_push_.send(zmqpp::message() <<
"S_WIEGAND1"
150 <<
"ff:ab:cd:ef" << 32);
151 check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0xff, 0xab, 0xcd, 0xef});
157 std::string connection_identity, data;
158 zmqpp::socket client = connect_to_rpleth();
161 bus_push_.send(zmqpp::message() <<
"S_WIEGAND1"
163 <<
"ff:ab:cd:ef" << 32);
164 check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0xff, 0xab, 0xcd, 0xef});
166 bus_push_.send(zmqpp::message() <<
"S_WIEGAND1"
168 <<
"11:22:33:44" << 32);
169 check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44});
171 bus_push_.send(zmqpp::message() <<
"S_WIEGAND1"
173 <<
"80:81:61:40" << 26);
174 check_rpleth_card_msg(client, {0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x05, 0x85});
176 bus_push_.send(zmqpp::message() <<
"S_IGNORED_READER"
178 <<
"11:22:33:44" << 32);
179 std::this_thread::sleep_for(std::chrono::milliseconds(500));
181 ASSERT_FALSE(client.receive(msg,
true));