97 {
99 AINFO <<
"Send thread starting...";
101 CanClient *client = param->can_client;
102 std::vector<CanFrame> frames;
104
105 int32_t count = 0;
106 int32_t start_id = 0;
107 int32_t end_id = 0;
108 int32_t id = 0;
109 if (param->is_first_agent) {
110 start_id = 1;
111 end_id = 128;
112 } else {
113 start_id = 129;
114 end_id = start_id + 127;
115 }
116 id = start_id;
117 int32_t send_id = id;
118 AINFO <<
"port:" << param->conf.ShortDebugString()
119 << ", start_id:" << start_id << ", end_id:" << end_id;
120
121
123 std::this_thread::yield();
124 }
126 while (true) {
127
128 if (count >= FLAGS_agent_mutual_send_frames) {
129 break;
130 }
132
133 send_id = id;
134 frames[i].id = id;
135 frames[i].len = 8;
136 frames[i].data[7] = static_cast<uint8_t>(count % 256);
137 for (uint8_t j = 0; j < 7; ++j) {
138 frames[i].data[j] = j;
139 }
140 ++count;
141 ++id;
142 if (id > end_id) {
143 id = start_id;
144 }
145 }
147 if (client->Send(frames, &frame_num) != ErrorCode::OK) {
149 AERROR <<
"send_thread send msg failed!, id:" << send_id
150 << ", conf:" << param->conf.ShortDebugString();
151 } else {
152 param->send_cnt += frame_num;
154 AINFO <<
"send_frames: " << frame_num <<
"send_frame#"
155 << frames[0].CanFrameString()
157 << ", conf:" << param->conf.ShortDebugString();
158 }
159 }
161 param->send_time = static_cast<int32_t>(end - start);
162
163 sleep(2);
164 AINFO <<
"Send thread stopping..." << param->conf.ShortDebugString();
166 return;
167 }
const int32_t MAX_CAN_SEND_FRAME_LEN