diff --git a/cyber/python/examples/py_service.cc b/cyber/python/examples/py_service.cc index 17643a1dbfc9c943cd644c0b37e7814f2ef02fc7..fa9302699c9f33d730f9a6f96eaedf5f0a661eba 100644 --- a/cyber/python/examples/py_service.cc +++ b/cyber/python/examples/py_service.cc @@ -30,15 +30,18 @@ using apollo::cyber::proto::Chatter; using apollo::cyber::message::PyMessageWrap; apollo::cyber::PyService *server = nullptr; int service_callback(const char *channel_name) { - AINFO << "server recv->[ " << channel_name << " ]"; - - if (server) { - Chatter chat; - std::string res = server->read(); - chat.ParseFromString(res); - AINFO << "server read: responese: " << chat.ShortDebugString(); + if (server == nullptr) { + AERROR << "server is null."; + return -1; } + AINFO << "server recv channelname ->[ " << channel_name << " ]"; + + Chatter chat; + std::string res = server->read(); + chat.ParseFromString(res); + AINFO << "server read: responese: " << chat.ShortDebugString(); + Chatter driver_msg; static uint64_t id = 0; ++id; @@ -47,7 +50,7 @@ int service_callback(const char *channel_name) { std::string org_data; driver_msg.SerializeToString(&org_data); server->write(org_data); - return -1; + return 1; } int main(int argc, char *argv[]) {