Skip to content

Commit

Permalink
API v028
Browse files Browse the repository at this point in the history
  • Loading branch information
Libelium committed May 11, 2017
1 parent 7ba8a3c commit 5ded843
Show file tree
Hide file tree
Showing 21 changed files with 664 additions and 292 deletions.
78 changes: 37 additions & 41 deletions libraries/CAN/WaspCAN.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! \file WaspCAN.cpp
\brief Library for managing CAN Bus modules
*
* Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
* Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
* http://www.libelium.com
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -17,7 +17,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 3.0
* Version: 3.1
* Design: David Gascon
* Implementation: Luis Antonio Martin Nuez & Ahmad Saad
*/
Expand Down Expand Up @@ -506,11 +506,11 @@ unsigned int WaspCAN::getEngineCoolantTemp()
//! Name: getFuelPressure()
//! Description: Fuel pressure
//! Param : void
//! Returns: unsigned int: Fuel pressure (0 - 765 Kpa)
//! Returns: uint16_t: Fuel pressure (0 - 765 Kpa)
//!*************************************************************
unsigned int WaspCAN::getFuelPressure()
uint16_t WaspCAN::getFuelPressure()
{
unsigned int data;
uint16_t data;

CiARequest(FUEL_PRESSURE);

Expand All @@ -530,11 +530,11 @@ unsigned int WaspCAN::getFuelPressure()
//! Name: getIntakeMAPressure()
//! Description: Intake manifold absolute pressure
//! Param : void
//! Returns: unsigned int: absolute pressure (0 - 255 Kpa)
//! Returns: uint16_t: absolute pressure (0 - 255 Kpa)
//!*************************************************************
unsigned int WaspCAN::getIntakeMAPressure()
uint16_t WaspCAN::getIntakeMAPressure()
{
unsigned int data;
uint16_t data;

CiARequest(INTAKE_M_A_PRESSURE);

Expand All @@ -556,12 +556,12 @@ unsigned int WaspCAN::getIntakeMAPressure()
//! Name: getEngineRPM()
//! Description: Engine RPM
//! Param : void
//! Returns: unsigned int: Engine RPM (0 - 16,383 RPM)
//! Returns: uint16_t: Engine RPM (0 - 16,383 RPM)
//!*************************************************************
unsigned int WaspCAN::getEngineRPM()
uint16_t WaspCAN::getEngineRPM()
{

unsigned int data;
uint16_t data;

CiARequest(ENGINE_RPM);

Expand All @@ -583,9 +583,9 @@ unsigned int WaspCAN::getEngineRPM()
//! Param : void
//! Returns: unsigned int: Vehicle speed (0 - 255)
//!*************************************************************
unsigned int WaspCAN::getVehicleSpeed()
uint16_t WaspCAN::getVehicleSpeed()
{
unsigned int data;
uint16_t data;

CiARequest(VEHICLE_SPEED);

Expand All @@ -608,9 +608,9 @@ unsigned int WaspCAN::getVehicleSpeed()
//! Param : void
//! Returns: unsigned int: Time (-64 - 63.5)
//!*************************************************************
unsigned int WaspCAN::getTimingAdvance()
uint16_t WaspCAN::getTimingAdvance()
{
unsigned int data;
uint16_t data;

CiARequest(TIMING_ADVANCE);

Expand All @@ -629,11 +629,11 @@ unsigned int WaspCAN::getTimingAdvance()
//! Name: getIntankeAirTemp()
//! Description: Intake air temperature
//! Param : void
//! Returns: unsigned int: Intake air temperature(-40 - 215)
//! Returns: uint8_t: Intake air temperature(-40 - 215)
//!*************************************************************
unsigned int WaspCAN::getIntankeAirTemp()
uint16_t WaspCAN::getIntankeAirTemp()
{
unsigned int data;
uint16_t data;

CiARequest(INTAKE_AIR_TEMP);

Expand All @@ -653,11 +653,11 @@ unsigned int WaspCAN::getIntankeAirTemp()
//! Name: getMAFairFlowRate()
//! Description: MAF air flow rate
//! Param : void
//! Returns: unsigned int: air flow rate (0 - 655.35 g/s)
//! Returns: uint8_t: air flow rate (0 - 655.35 g/s)
//!*************************************************************
unsigned int WaspCAN::getMAFairFlowRate()
uint16_t WaspCAN::getMAFairFlowRate()
{
unsigned int data;
uint16_t data;

CiARequest(MAF_AIR_FLOW_RATE);

Expand All @@ -669,20 +669,19 @@ unsigned int WaspCAN::getMAFairFlowRate()
#endif
}

return data;

return data;
}


//!*************************************************************
//! Name: getThrottlePosition()
//! Description: Throttle position
//! Param : void
//! Returns: unsigned int: Throttle position (0 - 100%)
//! Returns: uint8_t: Throttle position (0 - 100%)
//!*************************************************************
unsigned int WaspCAN::getThrottlePosition()
uint8_t WaspCAN::getThrottlePosition()
{
unsigned int data;
uint16_t data;

CiARequest(THROTTLE_POSITION);

Expand All @@ -694,21 +693,19 @@ unsigned int WaspCAN::getThrottlePosition()
#endif
}

return data;


return (uint8_t)data;
}


//!*************************************************************
//! Name: getFuelLevel()
//! Description: Fuel Level Input
//! Param : void
//! Returns: unsigned int: Fuel Level Input (0 - 100%)
//! Returns: uint8_t: Fuel Level Input (0 - 100%)
//!*************************************************************
unsigned int WaspCAN::getFuelLevel()
uint8_t WaspCAN::getFuelLevel()
{
unsigned int data;
uint16_t data;

CiARequest(FUEL_LEVEL);

Expand All @@ -720,7 +717,7 @@ unsigned int WaspCAN::getFuelLevel()
#endif
}

return data;
return (uint8_t)data;

}

Expand All @@ -729,11 +726,11 @@ unsigned int WaspCAN::getFuelLevel()
//! Name: getBarometricPressure()
//! Description: Barometric pressure
//! Param : void
//! Returns: unsigned int: Barometric pressure (0 - 255 Kpa)
//! Returns: uint8_t: Barometric pressure (0 - 255 Kpa)
//!*************************************************************
unsigned int WaspCAN::getBarometricPressure()
uint8_t WaspCAN::getBarometricPressure()
{
unsigned int data;
uint16_t data;

CiARequest(BAROMETRIC_PRESSURE);

Expand All @@ -745,7 +742,7 @@ unsigned int WaspCAN::getBarometricPressure()
#endif
}

return data;
return (uint8_t)data;
}


Expand All @@ -755,9 +752,9 @@ unsigned int WaspCAN::getBarometricPressure()
//! Param : void
//! Returns: unsigned int: Engine fuel rate (0 - 3212 L/h)
//!*************************************************************
unsigned int WaspCAN::getEngineFuelRate()
uint16_t WaspCAN::getEngineFuelRate()
{
unsigned int data;
uint16_t data;

CiARequest(ENGINE_FUEL_RATE);

Expand All @@ -769,8 +766,7 @@ unsigned int WaspCAN::getEngineFuelRate()
#endif
}

return data;

return data;
}


Expand Down
30 changes: 15 additions & 15 deletions libraries/CAN/WaspCAN.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*! \file WaspCAN.h
\brief Library for managing CAN Bus modules
Copyright (C) 2016 Libelium Comunicaciones Distribuidas S.L.
Copyright (C) 2017 Libelium Comunicaciones Distribuidas S.L.
http://www.libelium.com
This program is free software: you can redistribute it and/or modify
Expand All @@ -17,7 +17,7 @@
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Version: 3.0
Version: 3.1
Design: David Gascón
Implementation: Luis Antonio Martín Nuez & Ahmad Saad
*/
Expand Down Expand Up @@ -490,19 +490,19 @@ class WaspCAN
CAN in Automation (CiA)
***********************************************************************/

unsigned int getEngineLoad();
unsigned int getEngineCoolantTemp();
unsigned int getFuelPressure();
unsigned int getIntakeMAPressure();
unsigned int getEngineRPM();
unsigned int getVehicleSpeed();
unsigned int getTimingAdvance();
unsigned int getIntankeAirTemp();
unsigned int getMAFairFlowRate();
unsigned int getThrottlePosition();
unsigned int getFuelLevel();
unsigned int getBarometricPressure();
unsigned int getEngineFuelRate();
uint16_t getEngineLoad();
uint16_t getEngineCoolantTemp();
uint16_t getFuelPressure();
uint16_t getIntakeMAPressure();
uint16_t getEngineRPM();
uint16_t getVehicleSpeed();
uint16_t getTimingAdvance();
uint16_t getIntankeAirTemp();
uint16_t getMAFairFlowRate();
uint8_t getThrottlePosition();
uint8_t getFuelLevel();
uint8_t getBarometricPressure();
uint16_t getEngineFuelRate();

// General Function
void CiARequest(uint8_t PID);
Expand Down
16 changes: 13 additions & 3 deletions libraries/Frame/WaspFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* Version: 3.1
* Version: 3.2
* Design: David Gascón
* Implementation: Yuri Carmona, Javier Siscart, Joaquín Ruiz
*/
Expand Down Expand Up @@ -2866,13 +2866,23 @@ int8_t WaspFrame::addTimestamp()
/*
* setTinyLength
*
* Set the maximum payload of the tiny frames.
* Range: 10 to 100 Bytes
*
*/
void WaspFrame::setTinyLength(uint8_t length)
{

if (length > sizeof(bufferTiny))
{
// max range
_maxTinyLength = sizeof(bufferTiny);
}
else if (length < 10)
{
// min range
_maxTinyLength = 10;
}
else
{
_maxTinyLength = length;
Expand All @@ -2889,8 +2899,8 @@ uint8_t WaspFrame::generateTinyFrame()
memset(bufferTiny, 0x00, sizeof(bufferTiny));
lengthTiny = 0;

// insert data in Sigfox frame with the following format:
// [seq]+ [length] + [sensor_1] + ... + [sensor_N]
// insert data in tiny frame with the following format:
// S + [sensor_1] + ... + [sensor_N]
// where [sensor_x] is composed of [id]+[data]
bufferTiny[0] = readSequence() - 1;
lengthTiny++;
Expand Down
Loading

0 comments on commit 5ded843

Please sign in to comment.