[Ovmsdev] boot loop with RegisterCommand
Michael Balzer
dexter at expeedo.de
Thu Dec 17 22:17:39 HKT 2020
Do you call OBDInit() after the cmd_xvu init?
Regards,
Michael
Am 17.12.20 um 15:02 schrieb sharkcow:
> Sorry, obviously should have included this. The includes are copied from
> the twizy files.
>
> In my main header file, I have:
>
> class OvmsVehicleVWeUp : public OvmsVehicle
> {
> ...
> protected:
> OvmsCommand *cmd_xvu;
> ...
> public:
> // Shell commands:
> static void shell_obd_request(int verbosity, OvmsWriter* writer,
> OvmsCommand* cmd, int argc, const char* const* argv);
> ...
> }
>
> in the main cpp file:
>
> OvmsVehicleVWeUp::OvmsVehicleVWeUp()
> {
> ...
> // init commands:
> cmd_xvu = MyCommandApp.RegisterCommand("xvu", "VW e-Up");
> ...
> }
>
> in the obd cpp file:
>
> void OvmsVehicleVWeUp::OBDInit()
> {
> ..
> // init commands:
> OvmsCommand* cmd;
> OvmsCommand* obd;
> obd = cmd_xvu->RegisterCommand("obd", "OBD2 tools");
> cmd = obd->RegisterCommand("request", "Send OBD2 request, output
> response");
> cmd->RegisterCommand("device", "Send OBD2 request to a device",
> shell_obd_request, "<txid> <rxid> <request>", 3, 3);
> cmd->RegisterCommand("broadcast", "Send OBD2 request as broadcast",
> shell_obd_request, "<request>", 1, 1);
> cmd->RegisterCommand("01motelec", "Send OBD2 request to ECU01 motor
> electronics", shell_obd_request, "<request>", 1, 1);
> }
>
>
> Am 17.12.20 um 08:54 schrieb Mark Webb-Johnson:
>> Can you post an extract of your command registry code?
>>
>>
>>> On 17 Dec 2020, at 2:50 PM, sharkcow <sharkcow at gmx.de> wrote:
>>>
>>> Hi all,
>>>
>>> I tried to steal some code from the Twizy module but obviously don't
>>> understand how it works... my code results in a boot loop.
>>>
>>> I would like to have a possibility to test OBD codes in the shell
>>> (something I think would be immensely useful as a general function;
>>> that
>>> way, getting started with a new vehicle would be much easier.)
>>>
>>> Anyway, the problem seems to be in the lookup of the command name I'm
>>> trying to register, see stack trace below. Any help is greatly
>>> appreciated!
>>>
>>> Thanks,
>>>
>>> sharkcow
>>>
>>>
>>> 0x400fc115 is in std::_Rb_tree<char const*, std::pair<char const*
>>> const,
>>> OvmsCommand*>, std::_Select1st<std::pair<char const* const,
>>> OvmsCommand*> >, CompareCharPtr, std::allocator<std::pair<char const*
>>> const, OvmsCommand*> > >::find(char const* const&)
>>> (/opt/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_tree.h:663).
>>>
>>> 658 (this->_M_impl._M_header._M_parent);
>>> 659 }
>>> 660
>>> 661 _Link_type
>>> 662 _M_end() _GLIBCXX_NOEXCEPT
>>> 663 { return
>>> reinterpret_cast<_Link_type>(&this->_M_impl._M_header); }
>>> 664
>>> 665 _Const_Link_type
>>> 666 _M_end() const _GLIBCXX_NOEXCEPT
>>> 667 { return
>>> reinterpret_cast<_Const_Link_type>(&this->_M_impl._M_header); }
>>> 0x400fc15c is in OvmsCommandMap::FindCommand(char const*)
>>> (/opt/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/bits/stl_map.h:846).
>>>
>>> 841 * past-the-end ( @c end() ) iterator.
>>> 842 */
>>> 843
>>> 844 iterator
>>> 845 find(const key_type& __x)
>>> 846 { return _M_t.find(__x); }
>>> 847
>>> 848 #if __cplusplus > 201103L
>>> 849 template<typename _Kt>
>>> 850 auto
>>> 0x400fd87e is in OvmsCommand::RegisterCommand(char const*, char const*,
>>> void (*)(int, OvmsWriter*, OvmsCommand*, int, char const* const*), char
>>> const*, int, int, bool, int (*)(OvmsWriter*, OvmsCommand*, int, char
>>> const* const*, bool))
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/main/ovms_command.cpp:542).
>>>
>>> 537 return m_parent;
>>> 538 }
>>> 539
>>> 540 OvmsCommand* OvmsCommand::FindCommand(const char* name)
>>> 541 {
>>> 542 return m_children.FindCommand(name);
>>> 543 }
>>> 544
>>> 545 void help(int verbosity, OvmsWriter* writer, OvmsCommand*
>>> cmd, int
>>> argc, const char* const* argv)
>>> 546 {
>>> 0x401ac67a is in OvmsVehicleVWeUp::OBDInit()
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle_vweup_all/src/vweup_obd.cpp:228).
>>>
>>> 223 // cmd->RegisterCommand("reset", "Reset OVMS DTC statistics",
>>> shell_obd_resetdtc,
>>> 224 // "Resets internal DTC buffer and presence counters.\n"
>>> 225 // "No change is done on the car side.");
>>> 226
>>> 227 OvmsCommand* obd;
>>> 228 obd = cmd_xvu->RegisterCommand("obd", "OBD2 tools");
>>> 229 cmd = obd->RegisterCommand("request", "Send OBD2 request,
>>> output
>>> response");
>>> 230 cmd->RegisterCommand("device", "Send OBD2 request to a
>>> device",
>>> shell_obd_request, "<txid> <rxid> <request>", 3, 3);
>>> 231 cmd->RegisterCommand("broadcast", "Send OBD2 request as
>>> broadcast", shell_obd_request, "<request>", 1, 1);
>>> 232 cmd->RegisterCommand("01motelec", "Send OBD2 request to
>>> ECU01
>>> motor electronics", shell_obd_request, "<request>", 1, 1);
>>> 0x401abd4e is in OvmsVehicleVWeUp::ConfigChanged(OvmsConfigParam*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle_vweup_all/src/vehicle_vweup_all.cpp:210).
>>>
>>> 205 if (vweup_enable_t26)
>>> 206 T26Init();
>>> 207 vweup_con = vweup_enable_obd * 2 + vweup_enable_t26;
>>> 208 // ESP_LOGD(TAG,"vweup_con: %i",vweup_con);
>>> 209 if (vweup_enable_obd || (vweup_modelyear<2020 &&
>>> vweup_modelyear_new>2019) || (vweup_modelyear_new<2020 &&
>>> vweup_modelyear>2019)) // switch between generations: reload OBD
>>> poll list
>>> 210 OBDInit();
>>> 211 if (!vweup_enable_obd)
>>> 212 OBDDeInit();
>>> 213 vweup_modelyear = vweup_modelyear_new;
>>> 214 if (!vweup_con)
>>> 0x401abf5f is in OvmsVehicleVWeUp::OvmsVehicleVWeUp()
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle_vweup_all/src/vehicle_vweup_all.cpp:124).
>>>
>>> 119 {
>>> 120 ESP_LOGI(TAG, "Start VW e-Up vehicle module");
>>> 121
>>> 122 // init configs:
>>> 123 MyConfig.RegisterParam("xvu", "VW e-Up", true, true);
>>> 124 ConfigChanged(NULL);
>>> 125
>>> 126 // if (vweup_con % 2){ // T26A connected
>>> 127 // }
>>> 128 // if (vweup_con > 1){ // OBD connected
>>> 0x401abf9a is in CreateVehicle<OvmsVehicleVWeUp>()
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle/vehicle.h:456).
>>>
>>> 451 virtual bool FormatBmsAlerts(int verbosity, OvmsWriter*
>>> writer,
>>> bool show_warnings);
>>> 452 };
>>> 453
>>> 454 template<typename Type> OvmsVehicle* CreateVehicle()
>>> 455 {
>>> 456 return new Type;
>>> 457 }
>>> 458
>>> 459 class OvmsVehicleFactory
>>> 460 {
>>> 0x401656ff is in OvmsVehicleFactory::NewVehicle(char const*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle/vehicle.cpp:873).
>>>
>>> 868 OvmsVehicle* OvmsVehicleFactory::NewVehicle(const char*
>>> VehicleType)
>>> 869 {
>>> 870 OvmsVehicleFactory::map_vehicle_t::iterator iter =
>>> m_vmap.find(VehicleType);
>>> 871 if (iter != m_vmap.end())
>>> 872 {
>>> 873 return iter->second.construct();
>>> 874 }
>>> 875 return NULL;
>>> 876 }
>>> 877
>>> 0x40165737 is in OvmsVehicleFactory::SetVehicle(char const*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle/vehicle.cpp:900).
>>>
>>> 895 m_currentvehicle->m_ready = false;
>>> 896 delete m_currentvehicle;
>>> 897 m_currentvehicle = NULL;
>>> 898 m_currentvehicletype.clear();
>>> 899 }
>>> 900 m_currentvehicle = NewVehicle(type);
>>> 901 if (m_currentvehicle)
>>> 902 {
>>> 903 m_currentvehicle->m_ready = true;
>>> 904 }
>>> 0x40165825 is in OvmsVehicleFactory::AutoInit()
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/components/vehicle/vehicle.cpp:914).
>>>
>>> 909
>>> 910 void OvmsVehicleFactory::AutoInit()
>>> 911 {
>>> 912 std::string type = MyConfig.GetParamValue("auto",
>>> "vehicle.type");
>>> 913 if (!type.empty())
>>> 914 SetVehicle(type.c_str());
>>> 915 }
>>> 916
>>> 917 OvmsVehicle* OvmsVehicleFactory::ActiveVehicle()
>>> 918 {
>>> 0x400f80f3 is in Housekeeping::Init(std::__cxx11::basic_string<char,
>>> std::char_traits<char>, std::allocator<char> >, void*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/main/ovms_housekeeping.cpp:208).
>>>
>>> 203 ESP_LOGI(TAG, "Auto init modem (free: %zu bytes)",
>>> heap_caps_get_free_size(MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL));
>>> 204 MyPeripherals->m_simcom->AutoInit();
>>> 205 #endif // #ifdef CONFIG_OVMS_COMP_MODEM_SIMCOM
>>> 206
>>> 207 ESP_LOGI(TAG, "Auto init vehicle (free: %zu bytes)",
>>> heap_caps_get_free_size(MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL));
>>> 208 MyVehicleFactory.AutoInit();
>>> 209
>>> 210 #ifdef CONFIG_OVMS_COMP_OBD2ECU
>>> 211 ESP_LOGI(TAG, "Auto init obd2ecu (free: %zu bytes)",
>>> heap_caps_get_free_size(MALLOC_CAP_8BIT|MALLOC_CAP_INTERNAL));
>>> 212 obd2ecuInit.AutoInit();
>>> 0x400f7d06 is in std::_Function_handler<void
>>> (std::__cxx11::basic_string<char, std::char_traits<char>,
>>> std::allocator<char> >, void*), std::_Bind<std::_Mem_fn<void
>>> (Housekeeping::*)(std::__cxx11::basic_string<char,
>>> std::char_traits<char>, std::allocator<char> >, void*)> (Housekeeping*,
>>> std::_Placeholder<1>, std::_Placeholder<2>)>
>>> >::_M_invoke(std::_Any_data
>>> const&, std::__cxx11::basic_string<char, std::char_traits<char>,
>>> std::allocator<char> >&&, void*&&)
>>> (/opt/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/functional:600).
>>>
>>> 595 template<typename... _Args, typename _Req
>>> 596 = _Require<typename _Traits::__lvalue,
>>> 597 _CheckArgs<_Pack<_Args...>>>>
>>> 598 result_type
>>> 599 operator()(_Class* __object, _Args&&... __args) const
>>> 600 { return
>>> (__object->*_M_pmf)(std::forward<_Args>(__args)...); }
>>> 601
>>> 602 // Handle smart pointers, references and pointers to
>>> derived
>>> 603 template<typename _Tp, typename... _Args, typename _Req
>>> 604 = _Require<_NotSame<_Class, _Tp>,
>>> _NotSame<_Class*, _Tp>,
>>> 0x400f457e is in std::function<void (std::__cxx11::basic_string<char,
>>> std::char_traits<char>, std::allocator<char> >,
>>> void*)>::operator()(std::__cxx11::basic_string<char,
>>> std::char_traits<char>, std::allocator<char> >, void*) const
>>> (/opt/esp/xtensa-esp32-elf/xtensa-esp32-elf/include/c++/5.2.0/functional:2271).
>>>
>>> 2266 function<_Res(_ArgTypes...)>::
>>> 2267 operator()(_ArgTypes... __args) const
>>> 2268 {
>>> 2269 if (_M_empty())
>>> 2270 __throw_bad_function_call();
>>> 2271 return _M_invoker(_M_functor,
>>> std::forward<_ArgTypes>(__args)...);
>>> 2272 }
>>> 2273
>>> 2274 #if __cpp_rtti
>>> 2275 template<typename _Res, typename... _ArgTypes>
>>> 0x400f4711 is in OvmsEvents::HandleQueueSignalEvent(event_queue_t*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/main/ovms_events.cpp:229).
>>>
>>> 224 {
>>> 225 for (EventCallbackList::iterator itc=el->begin();
>>> itc!=el->end(); ++itc)
>>> 226 {
>>> 227 m_current_started = monotonictime;
>>> 228 m_current_callback = *itc;
>>> 229 m_current_callback->m_callback(m_current_event,
>>> msg->body.signal.data);
>>> 230 m_current_callback = NULL;
>>> 231 }
>>> 232 }
>>> 233 }
>>> 0x400f47f4 is in OvmsEvents::EventTask()
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/main/ovms_events.cpp:187).
>>>
>>> 182 {
>>> 183 case EVENT_none:
>>> 184 break;
>>> 185 case EVENT_signal:
>>> 186 m_current_event = msg.body.signal.event;
>>> 187 HandleQueueSignalEvent(&msg);
>>> 188 esp_task_wdt_reset(); // Reset WATCHDOG timer for
>>> this task
>>> 189 m_current_event.clear();
>>> 190 break;
>>> 191 default:
>>> 0x400f4859 is in EventLaunchTask(void*)
>>> (/opt/Open-Vehicle-Monitoring-System-3_Unh/vehicle/OVMS.V3/main/ovms_events.cpp:57).
>>>
>>> 52
>>> 53 void EventLaunchTask(void *pvParameters)
>>> 54 {
>>> 55 OvmsEvents* me = (OvmsEvents*)pvParameters;
>>> 56
>>> 57 me->EventTask();
>>> 58 }
>>> 59
>>> 60 void event_trace(int verbosity, OvmsWriter* writer,
>>> OvmsCommand* cmd,
>>> int argc, const char* const* argv)
>>> 61 {
>>>
>>> _______________________________________________
>>> OvmsDev mailing list
>>> OvmsDev at lists.openvehicles.com
>>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.openvehicles.com
>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>
> _______________________________________________
> OvmsDev mailing list
> OvmsDev at lists.openvehicles.com
> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 203 bytes
Desc: OpenPGP digital signature
URL: <http://lists.openvehicles.com/pipermail/ovmsdev/attachments/20201217/c58671c2/attachment-0001.sig>
More information about the OvmsDev
mailing list