Compare commits

..

No commits in common. "dab42140b873395fe877e9e0bcecf3948f7d593a" and "5955b23617e64f2d75a730406134c46ff9e7d4e0" have entirely different histories.

11 changed files with 63 additions and 136 deletions

View file

@ -25,7 +25,7 @@
*/
#include "ovms_log.h"
static const char *TAG = "canformat-cs11";
static const char *TAG = "canformat-crtd";
#include <errno.h>
#include "pcp.h"

View file

@ -25,44 +25,44 @@
*/
#include "ovms_log.h"
static const char *TAG = "canformat-lawicel";
static const char *TAG = "canformat-lawricel";
#include <errno.h>
#include "pcp.h"
#include "canformat_lawicel.h"
#include "canformat_lawricel.h"
////////////////////////////////////////////////////////////////////////
// Initialisation and Registration
////////////////////////////////////////////////////////////////////////
class OvmsCanFormatLawicelInit
class OvmsCanFormatLawricelInit
{
public: OvmsCanFormatLawicelInit();
} MyOvmsCanFormatLawicelTInit __attribute__ ((init_priority (4505)));
public: OvmsCanFormatLawricelInit();
} MyOvmsCanFormatLawricelTInit __attribute__ ((init_priority (4505)));
OvmsCanFormatLawicelInit::OvmsCanFormatLawicelInit()
OvmsCanFormatLawricelInit::OvmsCanFormatLawricelInit()
{
ESP_LOGI(TAG, "Registering CAN Format: LAWICEL (4505)");
ESP_LOGI(TAG, "Registering CAN Format: LAWRICEL (4505)");
MyCanFormatFactory.RegisterCanFormat<canformat_lawicel>("lawicel");
MyCanFormatFactory.RegisterCanFormat<canformat_lawricel>("lawricel");
}
////////////////////////////////////////////////////////////////////////
// Base GVRET implementation (utility)
////////////////////////////////////////////////////////////////////////
canformat_lawicel::canformat_lawicel(const char* type)
canformat_lawricel::canformat_lawricel(const char* type)
: canformat(type)
{
}
canformat_lawicel::~canformat_lawicel()
canformat_lawricel::~canformat_lawricel()
{
}
std::string canformat_lawicel::get(CAN_log_message_t* message)
std::string canformat_lawricel::get(CAN_log_message_t* message)
{
char buf[CANFORMAT_LAWICEL_MAXLEN];
char buf[CANFORMAT_LAWRICEL_MAXLEN];
if ((message->type != CAN_LogFrame_RX)&&
(message->type != CAN_LogFrame_TX))
@ -87,12 +87,12 @@ std::string canformat_lawicel::get(CAN_log_message_t* message)
return std::string(buf);
}
std::string canformat_lawicel::getheader(struct timeval *time)
std::string canformat_lawricel::getheader(struct timeval *time)
{
return std::string("");
}
size_t canformat_lawicel::put(CAN_log_message_t* message, uint8_t *buffer, size_t len, bool* hasmore, canlogconnection* clc)
size_t canformat_lawricel::put(CAN_log_message_t* message, uint8_t *buffer, size_t len, bool* hasmore, canlogconnection* clc)
{
if (m_buf.FreeSpace()==0) SetServeDiscarding(true); // Buffer full, so discard from now on
if (IsServeDiscarding()) return len; // Quick return if discarding

View file

@ -24,18 +24,18 @@
; THE SOFTWARE.
*/
#ifndef __CANFORMAT_LAWICEL_H__
#define __CANFORMAT_LAWICEL_H__
#ifndef __CANFORMAT_LAWRICEL_H__
#define __CANFORMAT_LAWRICEL_H__
#include "canformat.h"
#define CANFORMAT_LAWICEL_MAXLEN 48
#define CANFORMAT_LAWRICEL_MAXLEN 48
class canformat_lawicel : public canformat
class canformat_lawricel : public canformat
{
public:
canformat_lawicel(const char* type);
virtual ~canformat_lawicel();
canformat_lawricel(const char* type);
virtual ~canformat_lawricel();
public:
virtual std::string get(CAN_log_message_t* message);
@ -43,4 +43,4 @@ class canformat_lawicel : public canformat
virtual size_t put(CAN_log_message_t* message, uint8_t *buffer, size_t len, bool* hasmore, canlogconnection* clc=NULL);
};
#endif // __CANFORMAT_LAWICEL_H__
#endif // __CANFORMAT_LAWRICEL_H__

View file

@ -34,6 +34,7 @@ static const char *TAG = "canlog-tcpclient";
#include "canformat.h"
#include "canlog_tcpclient.h"
#include "ovms_config.h"
#include "ovms_peripherals.h"
canlog_tcpclient* MyCanLogTcpClient = NULL;
@ -163,9 +164,7 @@ bool canlog_tcpclient::Open()
opts.error_string = &err;
if (mg_connect_opt(mgr, m_path.c_str(), tcMongooseHandler, opts) != NULL)
{
// Wait 10s max for connection establishment...
m_connecting.Take(pdMS_TO_TICKS(10*1000));
return m_isopen;
return true;
}
else
{
@ -222,7 +221,7 @@ void canlog_tcpclient::MongooseHandler(struct mg_connection *nc, int ev, void *p
int *success = (int*)p;
ESP_LOGV(TAG, "MongooseHandler(MG_EV_CONNECT=%d)",*success);
if (*success == 0)
{ // Connection successful
{ // Successful connection
OvmsRecMutexLock lock(&m_cmmutex);
ESP_LOGI(TAG, "Connection successful to %s",m_path.c_str());
canlogconnection* clc = new canlogconnection(this, m_format, m_mode);
@ -237,11 +236,11 @@ void canlog_tcpclient::MongooseHandler(struct mg_connection *nc, int ev, void *p
}
}
else
{ // Connection failed
{
// Connection failed
ESP_LOGE(TAG, "Connection failed to %s",m_path.c_str());
m_isopen = false;
}
m_connecting.Give();
}
break;
case MG_EV_CLOSE:

View file

@ -31,7 +31,6 @@
#include "canlog.h"
#include "ovms_netmanager.h"
#include "ovms_mutex.h"
#include "ovms_semaphore.h"
class canlog_tcpclient : public canlog
{
@ -49,7 +48,6 @@ class canlog_tcpclient : public canlog
public:
std::string m_path;
OvmsSemaphore m_connecting;
};
#endif // __CANLOG_TCP_CLIENT_H__

View file

@ -257,7 +257,6 @@ class modemdriver : public InternalRamAllocated
protected:
unsigned int m_powercyclefactor;
modem* m_modem;
int m_statuspoller_step;
};
template<typename Type> modemdriver* CreateCellularModemDriver()

View file

@ -61,7 +61,6 @@ modemdriver::modemdriver()
{
m_modem = MyPeripherals->m_cellular_modem;
m_powercyclefactor = 0;
m_statuspoller_step = 0;
}
modemdriver::~modemdriver()
@ -155,13 +154,11 @@ void modemdriver::StatusPoller()
bool modemdriver::State1Leave(modem::modem_state1_t oldstate)
{
m_statuspoller_step = 0;
return false;
}
bool modemdriver::State1Enter(modem::modem_state1_t newstate)
{
m_statuspoller_step = 0;
return false;
}
@ -172,9 +169,5 @@ modem::modem_state1_t modemdriver::State1Activity(modem::modem_state1_t curstate
modem::modem_state1_t modemdriver::State1Ticker1(modem::modem_state1_t curstate)
{
if (m_statuspoller_step > 0)
{
StatusPoller();
}
return curstate;
}

View file

@ -69,43 +69,17 @@ const char* simcom5360::GetName()
void simcom5360::StatusPoller()
{
if (m_modem->m_mux != NULL)
{
// The ESP32 UART queue has a capacity of 128 bytes, NMEA and PPP data may be
// coming in concurrently, and we cannot use flow control.
// Reduce the queue stress by distributing the status poll:
switch (++m_statuspoller_step)
{
case 1:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+CREG?;+CCLK?;+CSQ\r\n");
// → ~ 55 bytes, e.g.
// +CREG: 1,5 +CCLK: "22/10/02,09:33:27+08" +CSQ: 24,99
break;
case 2:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+CPSI?\r\n");
// → ~ 60 bytes, e.g.
// +CPSI: GSM,Online,262-02,0x011f,14822,4 EGSM 900,-67,0,40-40
break;
case 3:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+COPS?\r\n");
// → ~ 35 bytes, e.g.
// +COPS: 0,0,"vodafone.de Hologram",0
// done, fallthrough:
default:
m_statuspoller_step = 0;
break;
}
}
{ m_modem->muxtx(GetMuxChannelPOLL(), "AT+CREG?;+CCLK?;+CSQ;+CPSI?;+COPS?\r\n"); }
}
bool simcom5360::State1Leave(modem::modem_state1_t oldstate)
{
return modemdriver::State1Leave(oldstate);
return false;
}
bool simcom5360::State1Enter(modem::modem_state1_t newstate)
{
return modemdriver::State1Enter(newstate);
return false;
}
modem::modem_state1_t simcom5360::State1Activity(modem::modem_state1_t curstate)
@ -119,7 +93,7 @@ modem::modem_state1_t simcom5360::State1Activity(modem::modem_state1_t curstate)
return modem::None;
}
return modemdriver::State1Activity(curstate);
return curstate;
}
modem::modem_state1_t simcom5360::State1Ticker1(modem::modem_state1_t curstate)
@ -157,5 +131,5 @@ modem::modem_state1_t simcom5360::State1Ticker1(modem::modem_state1_t curstate)
return modem::None;
}
return modemdriver::State1Ticker1(curstate);
return curstate;
}

View file

@ -91,33 +91,7 @@ void simcom7600::StartupNMEA()
void simcom7600::StatusPoller()
{
if (m_modem->m_mux != NULL)
{
// The ESP32 UART queue has a capacity of 128 bytes, NMEA and PPP data may be
// coming in concurrently, and we cannot use flow control.
// Reduce the queue stress by distributing the status poll:
switch (++m_statuspoller_step)
{
case 1:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+CREG?;+CGREG?;+CEREG?;+CCLK?;+CSQ\r\n");
// → ~ 80 bytes, e.g.
// +CREG: 1,5 +CGREG: 1,5 +CEREG: 1,5 +CCLK: "22/09/09,12:54:41+08" +CSQ: 13,99
break;
case 2:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+CPSI?\r\n");
// → ~ 85 bytes, e.g.
// +CPSI: LTE,Online,262-02,0xB0F5,13179412,448,EUTRAN-BAND1,100,4,4,-122,-1184,-874,9
break;
case 3:
m_modem->muxtx(GetMuxChannelPOLL(), "AT+COPS?\r\n");
// → ~ 35 bytes, e.g.
// +COPS: 0,0,"vodafone.de Hologram",7
// done, fallthrough:
default:
m_statuspoller_step = 0;
break;
}
}
{ m_modem->muxtx(GetMuxChannelPOLL(), "AT+CREG?;+CGREG?;+CEREG?;+CCLK?;+CSQ;+CPSI?;+COPS?\r\n"); }
}
void simcom7600::PowerCycle()
@ -137,12 +111,12 @@ void simcom7600::PowerCycle()
bool simcom7600::State1Leave(modem::modem_state1_t oldstate)
{
return modemdriver::State1Leave(oldstate);
return false;
}
bool simcom7600::State1Enter(modem::modem_state1_t newstate)
{
return modemdriver::State1Enter(newstate);
return false;
}
modem::modem_state1_t simcom7600::State1Activity(modem::modem_state1_t curstate)
@ -156,7 +130,7 @@ modem::modem_state1_t simcom7600::State1Activity(modem::modem_state1_t curstate)
return modem::None;
}
return modemdriver::State1Activity(curstate);
return curstate;
}
modem::modem_state1_t simcom7600::State1Ticker1(modem::modem_state1_t curstate)
@ -182,5 +156,5 @@ modem::modem_state1_t simcom7600::State1Ticker1(modem::modem_state1_t curstate)
return modem::None;
}
return modemdriver::State1Ticker1(curstate);
return curstate;
}

View file

@ -1075,35 +1075,25 @@ OvmsVehicle::vehicle_command_t OvmsVehicle::CommandStat(int verbosity, OvmsWrite
writer->printf("SOC: %s\n", (char*) StdMetrics.ms_v_bat_soc->AsUnitString("-", Native, 1).c_str());
if (StdMetrics.ms_v_bat_range_ideal->IsDefined())
{
const std::string& range_ideal = StdMetrics.ms_v_bat_range_ideal->AsUnitString("-", rangeUnit, 0);
writer->printf("Ideal range: %s\n", range_ideal.c_str());
}
const char* range_ideal = StdMetrics.ms_v_bat_range_ideal->AsUnitString("-", rangeUnit, 0).c_str();
if (*range_ideal != '-')
writer->printf("Ideal range: %s\n", range_ideal);
if (StdMetrics.ms_v_bat_range_est->IsDefined())
{
const std::string& range_est = StdMetrics.ms_v_bat_range_est->AsUnitString("-", rangeUnit, 0);
writer->printf("Est. range: %s\n", range_est.c_str());
}
const char* range_est = StdMetrics.ms_v_bat_range_est->AsUnitString("-", rangeUnit, 0).c_str();
if (*range_est != '-')
writer->printf("Est. range: %s\n", range_est);
if (StdMetrics.ms_v_pos_odometer->IsDefined())
{
const std::string& odometer = StdMetrics.ms_v_pos_odometer->AsUnitString("-", rangeUnit, 1);
writer->printf("ODO: %s\n", odometer.c_str());
}
const char* odometer = StdMetrics.ms_v_pos_odometer->AsUnitString("-", rangeUnit, 1).c_str();
if (*odometer != '-')
writer->printf("ODO: %s\n", odometer);
if (StdMetrics.ms_v_bat_cac->IsDefined())
{
const std::string& cac = StdMetrics.ms_v_bat_cac->AsUnitString("-", Native, 1);
writer->printf("CAC: %s\n", cac.c_str());
}
const char* cac = StdMetrics.ms_v_bat_cac->AsUnitString("-", Native, 1).c_str();
if (*cac != '-')
writer->printf("CAC: %s\n", cac);
if (StdMetrics.ms_v_bat_soh->IsDefined())
{
const std::string& soh = StdMetrics.ms_v_bat_soh->AsUnitString("-", Native, 0);
writer->printf("SOH: %s\n", soh.c_str());
}
const char* soh = StdMetrics.ms_v_bat_soh->AsUnitString("-", Native, 0).c_str();
if (*soh != '-')
writer->printf("SOH: %s\n", soh);
return Success;
}

View file

@ -56,8 +56,8 @@ void OvmsVehicleRenaultZoePh2OBD::IncomingLBC(uint16_t type, uint16_t pid, const
StandardMetrics.ms_v_bat_cac->SetValue(Bat_cell_capacity * CAN_UINT(0) * 0.0001);
//ESP_LOGD(TAG, "9002 LBC mt_bat_lbc_soc: %f", bat_soc);
//ESP_LOGD(TAG, "9002 LBC mt_bat_lbc_soc calculated: %f", bat_soc + (bat_soc * 0.03));
ESP_LOGD(TAG, "9002 LBC mt_bat_lbc_soc: %f", bat_soc);
ESP_LOGD(TAG, "9002 LBC mt_bat_lbc_soc calculated: %f", bat_soc + (bat_soc * 0.03));
break;
}
case 0x9003: { //Battery SOH