Skip to content

Commit

Permalink
sd card changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Oct 3, 2019
1 parent 5c7bc66 commit f34f093
Show file tree
Hide file tree
Showing 28 changed files with 746 additions and 613 deletions.
130 changes: 109 additions & 21 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -838,11 +838,6 @@
"type": "string",
"defaultValue": "STM32F7"
},
{
"name": "sys.info.ethernet",
"type": "string",
"defaultValue": "Enabled"
},
{
"name": "sys.info.fan.status",
"description": "0: invalid (error)\n1: valid\n2: unsupported\n3: not installed",
Expand Down Expand Up @@ -1739,6 +1734,12 @@
"name": "channel.hasAdvancedOptions",
"type": "boolean",
"defaultValue": "1"
},
{
"name": "sys_info_sdcard",
"type": "enum",
"enumItems": "[\"Unsupported\", \"Present\", \"Not present\", \"No FAT\", \"Failed\", \"Busy\"]",
"defaultValue": "1"
}
],
"actions": [
Expand Down Expand Up @@ -26817,24 +26818,119 @@
"top": 28,
"width": 114,
"height": 28,
"text": "Ethernet:"
"text": "SD card:"
},
{
"type": "Text",
"type": "Select",
"style": {
"inheritFrom": "value_S",
"padding": 0
"inheritFrom": "default"
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
"inheritFrom": "default"
},
"data": "sys.info.ethernet",
"data": "sys_info_sdcard",
"left": 350,
"top": 28,
"width": 122,
"height": 28,
"text": ""
"widgets": [
{
"type": "Text",
"style": {
"inheritFrom": "value_S",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "Unsupported"
},
{
"type": "Text",
"style": {
"inheritFrom": "event_info",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "Present"
},
{
"type": "Text",
"style": {
"inheritFrom": "value_S",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "Not present"
},
{
"type": "Text",
"style": {
"inheritFrom": "event_error",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "No FAT"
},
{
"type": "Text",
"style": {
"inheritFrom": "event_error",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "Failed"
},
{
"type": "Text",
"style": {
"inheritFrom": "event_warning",
"padding": 0
},
"activeStyle": {
"inheritFrom": "default",
"padding": 0
},
"left": 0,
"top": 0,
"width": 122,
"height": 28,
"text": "Busy"
}
]
},
{
"type": "List",
Expand Down Expand Up @@ -433080,14 +433176,6 @@
"type": "numeric"
}
},
{
"name": "SYSTem:CPU:INFOrmation:ETHernet:TYPE?",
"helpLink": "EEZ PSU SCPI reference 5.15 - SYSTem.html#syst_cpu_eth_type",
"parameters": [],
"response": {
"type": "numeric"
}
},
{
"name": "SYSTem:CPU:INFOrmation:ONTime:LAST?",
"helpLink": "EEZ PSU SCPI reference 5.15 - SYSTem.html#syst_cpu_ont_last",
Expand Down
1 change: 1 addition & 0 deletions src/eez/apps/psu/dlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

#if OPTION_SD_CARD
#include <eez/apps/psu/psu.h>
#include <eez/libs/sd_fat/sd_fat.h>

#include <math.h>

Expand Down
25 changes: 23 additions & 2 deletions src/eez/apps/psu/gui/data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@
#include <eez/apps/psu/gui/page_user_profiles.h>
#include <eez/apps/psu/gui/psu.h>
#include <eez/gui/dialogs.h>
#if OPTION_SD_CARD
#include <eez/apps/psu/sd_card.h>
#endif

#define CONF_GUI_REFRESH_EVERY_MS 250
#define CONF_LIST_COUNDOWN_DISPLAY_THRESHOLD 5 // 5 seconds
Expand Down Expand Up @@ -2470,12 +2473,30 @@ void data_sys_info_cpu(data::DataOperationEnum operation, data::Cursor &cursor,
}
}

void data_sys_info_ethernet(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
void data_sys_info_sdcard(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
if (operation == data::DATA_OPERATION_GET) {
value = data::Value(getCpuEthernetType());
#if OPTION_SD_CARD
int err;
if (eez::psu::sd_card::isMounted(&err)) {
if (eez::psu::sd_card::isBusy()) {
value = 5; // busy
} else {
value = 1; // present
}
} else if (err == SCPI_ERROR_MISSING_MASS_MEDIA) {
value = 2; // not present
} else if (err == SCPI_ERROR_MASS_MEDIA_NO_FILESYSTEM) {
value = 3; // no FAT
} else {
value = 4; // failed
}
#else
value = 0; // unsupported
#endif
}
}


void data_sys_info_fan_status(data::DataOperationEnum operation, data::Cursor &cursor, data::Value &value) {
if (operation == data::DATA_OPERATION_GET) {
#if OPTION_FAN
Expand Down
7 changes: 3 additions & 4 deletions src/eez/apps/psu/list_program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <eez/apps/psu/trigger.h>
#if OPTION_SD_CARD
#include <eez/apps/psu/sd_card.h>
#include <eez/libs/sd_fat/sd_fat.h>
#endif
#include <eez/apps/psu/io_pins.h>
#include <eez/system.h>
Expand Down Expand Up @@ -209,8 +210,7 @@ bool loadList(int iChannel, const char *filePath, int *err) {
#if OPTION_SD_CARD
Channel &channel = Channel::get(iChannel);

if (!sd_card::isOk()) {
*err = SCPI_ERROR_MASS_STORAGE_ERROR;
if (!sd_card::isMounted(err)) {
return false;
}

Expand Down Expand Up @@ -339,8 +339,7 @@ bool saveList(int iChannel, const char *filePath, int *err) {

Channel &channel = Channel::get(iChannel);

if (!sd_card::isOk()) {
*err = SCPI_ERROR_MASS_STORAGE_ERROR;
if (!sd_card::isMounted(err)) {
return false;
}

Expand Down
35 changes: 19 additions & 16 deletions src/eez/apps/psu/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <eez/apps/psu/trigger.h>
#if OPTION_SD_CARD
#include <eez/apps/psu/sd_card.h>
#include <eez/libs/sd_fat/sd_fat.h>
#endif
#include <eez/scpi/scpi.h>

Expand Down Expand Up @@ -60,19 +61,21 @@ void getChannelProfileListFilePath(Channel &channel, int location, char *filePat
}

void loadProfileList(Parameters &profile, Channel &channel, int location) {
if (!sd_card::isOk()) {
generateError(SCPI_ERROR_MASS_STORAGE_ERROR);
int err;
if (!sd_card::isMounted(&err)) {
if (err != SCPI_ERROR_MISSING_MASS_MEDIA && err != SCPI_ERROR_MASS_MEDIA_NO_FILESYSTEM) {
generateError(err);
}
return;
}

char filePath[MAX_PATH_LENGTH];
getChannelProfileListFilePath(channel, location, filePath);

if (!SD.exists(filePath)) {
if (!sd_card::exists(filePath, &err)) {
return;
}

int err;
if (list::loadList(channel.channelIndex, filePath, &err)) {
if (location == 0) {
list::setListsChanged(channel, false);
Expand Down Expand Up @@ -112,20 +115,24 @@ void deleteProfileList(Channel &channel, int location) {
char filePath[MAX_PATH_LENGTH];
getChannelProfileListFilePath(channel, location, filePath);

if (!SD.exists(filePath)) {
int err;

if (!sd_card::exists(filePath, &err)) {
return;
}

if (!SD.remove(filePath)) {
// TODO more specific error
generateError(SCPI_ERROR_MASS_STORAGE_ERROR);
if (!sd_card::deleteFile(filePath, &err)) {
generateError(err);
}
}

void deleteProfileLists(int location) {
#if OPTION_SD_CARD
if (!sd_card::isOk()) {
generateError(SCPI_ERROR_MASS_STORAGE_ERROR);
int err;
if (!sd_card::isMounted(&err)) {
if (err != SCPI_ERROR_MISSING_MASS_MEDIA && err != SCPI_ERROR_MASS_MEDIA_NO_FILESYSTEM) {
generateError(err);
}
return;
}

Expand Down Expand Up @@ -422,9 +429,7 @@ bool recall(int location, int *err) {

bool recallFromFile(const char *filePath, int *err) {
#if OPTION_SD_CARD
if (!sd_card::isOk()) {
if (err)
*err = SCPI_ERROR_MASS_STORAGE_ERROR;
if (!sd_card::isMounted(err)) {
return false;
}

Expand Down Expand Up @@ -525,9 +530,7 @@ bool saveAtLocation(int location, const char *name) {

bool saveToFile(const char *filePath, int *err) {
#if OPTION_SD_CARD
if (!sd_card::isOk()) {
if (err)
*err = SCPI_ERROR_MASS_STORAGE_ERROR;
if (!sd_card::isMounted(err)) {
return false;
}

Expand Down
8 changes: 0 additions & 8 deletions src/eez/apps/psu/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,14 +891,6 @@ const char *getCpuType() {
#endif
}

const char *getCpuEthernetType() {
#if defined(EEZ_PLATFORM_SIMULATOR)
return "Simulator";
#elif defined(EEZ_PLATFORM_STM32)
return "None";
#endif
}

bool isMaxCurrentLimited() {
return g_maxCurrentLimitCause != MAX_CURRENT_LIMIT_CAUSE_NONE;
}
Expand Down
1 change: 0 additions & 1 deletion src/eez/apps/psu/psu.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ void setOperBits(int bit_mask, bool on);

const char *getCpuModel();
const char *getCpuType();
const char *getCpuEthernetType();

bool isMaxCurrentLimited();
MaxCurrentLimitCause getMaxCurrentLimitCause();
Expand Down
6 changes: 0 additions & 6 deletions src/eez/apps/psu/scpi/syst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,6 @@ scpi_result_t scpi_cmd_systemChannelModelQ(scpi_t *context) {
return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemCpuInformationEthernetTypeQ(scpi_t *context) {
// TODO migrate to generic firmware
SCPI_ResultText(context, getCpuEthernetType());
return SCPI_RES_OK;
}

scpi_result_t scpi_cmd_systemCpuInformationTypeQ(scpi_t *context) {
// TODO migrate to generic firmware
SCPI_ResultText(context, getCpuType());
Expand Down
Loading

0 comments on commit f34f093

Please sign in to comment.