mirror of
https://github.com/intrepidcs/libicsneo.git
synced 2026-08-05 09:28:40 +02:00
Device: Add logical disk size accessor
This commit is contained in:
@@ -17,11 +17,12 @@ enum class Command : uint8_t {
|
||||
UpdateLEDState = 0xA7,
|
||||
SetDefaultSettings = 0xA8, // Follow up with SaveSettings to write to EEPROM
|
||||
GetSecondaryVersions = 0xA9, // Previously known as RED_CMD_PERIPHERALS_APP_VERSION_REQ, versions other than the main chip
|
||||
GetLogicalDiskInfo = 0xBB, // Previously known as RED_CMD_GET_SDCARD_INFO
|
||||
RequestStatusUpdate = 0xBC,
|
||||
ReadSettings = 0xC7, // Previously known as 3G_READ_SETTINGS_EX
|
||||
SetVBattMonitor = 0xDB, // Previously known as RED_CMD_CM_VBATT_MONITOR
|
||||
RequestBitSmash = 0xDC, // Previously known as RED_CMD_CM_BITSMASH
|
||||
GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST
|
||||
GetVBattReq = 0xDF, // Previously known as RED_CMD_VBATT_REQUEST
|
||||
MiscControl = 0xE7,
|
||||
Extended = 0xF0,
|
||||
FlexRayControl = 0xF3,
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "icsneo/communication/packet.h"
|
||||
#include "icsneo/communication/message/callback/messagecallback.h"
|
||||
#include "icsneo/communication/message/serialnumbermessage.h"
|
||||
#include "icsneo/communication/message/logicaldiskinfomessage.h"
|
||||
#include "icsneo/device/deviceversion.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include "icsneo/communication/packetizer.h"
|
||||
@@ -56,7 +57,8 @@ public:
|
||||
bool getSettingsSync(std::vector<uint8_t>& data, std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||
std::shared_ptr<SerialNumberMessage> getSerialNumberSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||
optional< std::vector< optional<DeviceAppVersion> > > getVersionsSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||
|
||||
std::shared_ptr<LogicalDiskInfoMessage> getLogicalDiskInfoSync(std::chrono::milliseconds timeout = std::chrono::milliseconds(50));
|
||||
|
||||
int addMessageCallback(const MessageCallback& cb);
|
||||
bool removeMessageCallback(int id);
|
||||
std::shared_ptr<Message> waitForMessageSync(
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#ifndef __LOGICALDISKINFOMESSAGE_H_
|
||||
#define __LOGICALDISKINFOMESSAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/message.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
class LogicalDiskInfoMessage : public Message {
|
||||
public:
|
||||
LogicalDiskInfoMessage(bool isConnected, uint32_t numSectors, uint32_t numHidden, uint32_t sectorSize) :
|
||||
Message(Message::Type::LogicalDiskInfo), connected(isConnected), sectors(numSectors),
|
||||
hiddenSectors(numHidden), bytesPerSector(sectorSize) {}
|
||||
|
||||
const bool connected;
|
||||
const uint32_t sectors;
|
||||
const uint32_t hiddenSectors;
|
||||
const uint32_t bytesPerSector;
|
||||
|
||||
uint64_t getReportedSize() const { return uint64_t(sectors) * bytesPerSector; }
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -27,6 +27,7 @@ public:
|
||||
Main51 = 0x8005,
|
||||
FlexRayControl = 0x8006,
|
||||
EthernetPhyRegister = 0x8007,
|
||||
LogicalDiskInfo = 0x8008,
|
||||
};
|
||||
|
||||
Message(Type t) : type(t) {}
|
||||
|
||||
@@ -117,6 +117,7 @@ public:
|
||||
HSCAN7 = 97,
|
||||
LIN6 = 98,
|
||||
LSFTCAN2 = 99,
|
||||
LogicalDiskInfo = 187,
|
||||
EthPHYControl = 239,
|
||||
FlexRayControl = 243,
|
||||
HW_COM_Latency_Test = 512,
|
||||
@@ -271,6 +272,7 @@ public:
|
||||
case NetID::FlexRayControl:
|
||||
case NetID::Main51:
|
||||
case NetID::ReadSettings:
|
||||
case NetID::LogicalDiskInfo:
|
||||
case NetID::EthPHYControl:
|
||||
case NetID::NeoMemorySDRead:
|
||||
return Type::Internal;
|
||||
@@ -507,6 +509,8 @@ public:
|
||||
return "LIN 6";
|
||||
case NetID::LSFTCAN2:
|
||||
return "LSFTCAN 2";
|
||||
case NetID::LogicalDiskInfo:
|
||||
return "Logical Disk Information";
|
||||
case NetID::EthPHYControl:
|
||||
return "Ethernet PHY Register Control";
|
||||
case NetID::FlexRayControl:
|
||||
@@ -907,6 +911,7 @@ private:
|
||||
#define ICSNEO_NETID_HSCAN7 97
|
||||
#define ICSNEO_NETID_LIN6 98
|
||||
#define ICSNEO_NETID_LSFTCAN2 99
|
||||
#define ICSNEO_NETID_LOGICAL_DISK_INFO 187
|
||||
#define ICSNEO_NETID_ETH_PHY_CONTROL 239
|
||||
#define ICSNEO_NETID_FLEXRAY_CONTROL 243
|
||||
#define ICSNEO_NETID_HW_COM_LATENCY_TEST 512
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
#ifndef __LOGICALDISKINFOPACKET_H__
|
||||
#define __LOGICALDISKINFOPACKET_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "icsneo/communication/message/logicaldiskinfomessage.h"
|
||||
#include "icsneo/api/eventmanager.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace icsneo {
|
||||
|
||||
#pragma pack(push,2)
|
||||
struct LogicalDiskInfoPacket {
|
||||
static std::shared_ptr<LogicalDiskInfoMessage> DecodeToMessage(const std::vector<uint8_t>& bytestream);
|
||||
|
||||
uint16_t isConnected;
|
||||
uint32_t numSectors;
|
||||
uint32_t hiddenSectors;
|
||||
uint32_t bytesPerSector;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif
|
||||
@@ -176,6 +176,28 @@ public:
|
||||
optional<uint64_t> writeLogicalDisk(uint64_t pos, const uint8_t* from, uint64_t amount,
|
||||
std::chrono::milliseconds timeout = Disk::DefaultTimeout);
|
||||
|
||||
/**
|
||||
* Check if the logical disk is connected. This means the disk is inserted,
|
||||
* and if required (for instance for multi-card configurations), configured
|
||||
* properly.
|
||||
*
|
||||
* This method is synchronous and contacts the device for the latest status.
|
||||
*
|
||||
* `icsneo::nullopt` will be returned if the device does not respond in a
|
||||
* timely manner.
|
||||
*/
|
||||
optional<bool> isLogicalDiskConnected();
|
||||
|
||||
/**
|
||||
* Get the size of the connected logical disk in bytes.
|
||||
*
|
||||
* This method is synchronous and contacts the device for the latest status.
|
||||
*
|
||||
* `icsneo::nullopt` will be returned if the device does not respond in a
|
||||
* timely manner, or if the disk is disconnected/improperly configured.
|
||||
*/
|
||||
optional<uint64_t> getLogicalDiskSize();
|
||||
|
||||
/**
|
||||
* Retrieve the number of Ethernet (DoIP) Activation lines present
|
||||
* on this device.
|
||||
|
||||
Reference in New Issue
Block a user