1wire cleaning, added 1w UU, renamed some error messages

sipo
Ondřej Hruška 7 years ago
parent 0e378b6547
commit b6f7060516
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 4
      units/1wire/_ow_checksum.c
  2. 2
      units/1wire/_ow_checksum.h
  3. 21
      units/1wire/_ow_search.c
  4. 3
      units/1wire/_ow_search.h
  5. 322
      units/1wire/unit_1wire.c
  6. 65
      units/1wire/unit_1wire.h
  7. 25
      utils/error.h
  8. 6
      vfs/file_stream.c
  9. 18
      vfs/vfs_manager.c

@ -24,10 +24,10 @@ static uint8_t crc8_add(uint8_t cksum, uint8_t byte)
return crc8_bits(byte ^ cksum);
}
uint8_t ow_checksum(const uint8_t *buff, uint16_t len)
uint8_t ow_checksum(const uint8_t *buff, uint32_t len)
{
uint8_t cksum = 0;
for(uint16_t i = 0; i < len; i++) {
for(uint32_t i = 0; i < len; i++) {
cksum = crc8_add(cksum, buff[i]);
}
return cksum;

@ -18,6 +18,6 @@
* @param[in] len - buffer length
* @return checksum
*/
uint8_t ow_checksum(const uint8_t *buf, uint16_t len);
uint8_t ow_checksum(const uint8_t *buf, uint32_t len);
#endif //GEX_F072_OW_CHECKSUM_H

@ -25,12 +25,13 @@ void ow_search_init(Unit *unit, uint8_t command, bool test_checksums)
state->prev_last_fork = 64;
memset(state->prev_code, 0, 8);
state->status = OW_SEARCH_MORE;
state->error = E_SUCCESS;
state->command = command;
state->first = true;
state->test_checksums = test_checksums;
}
uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity)
uint32_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint32_t capacity)
{
if (unit->driver != &UNIT_1WIRE)
trap("Wrong unit type - %s", unit->driver->name);
@ -42,7 +43,7 @@ uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity)
if (state->status != OW_SEARCH_MORE) return 0;
uint16_t found_devices = 0;
uint32_t found_devices = 0;
while (found_devices < capacity) {
uint8_t index = 0;
@ -52,6 +53,7 @@ uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity)
// Start a new transaction. Devices respond to reset
if (!ow_reset(unit)) {
state->status = OW_SEARCH_FAILED;
state->error = E_HW_TIMEOUT;
goto done;
}
// Send the search command (SEARCH_ROM, SEARCH_ALARM)
@ -83,6 +85,7 @@ uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity)
else if (p && n) {
// No devices left connected - this doesn't normally happen
state->status = OW_SEARCH_FAILED;
state->error = E_BUS_FAULT;
goto done;
}
@ -98,12 +101,18 @@ uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity)
memcpy(state->prev_code, code, 8);
if (!state->test_checksums || 0 == ow_checksum(code, 8)) {
// Record a found address
memcpy(codes[found_devices], code, 8);
found_devices++;
if (state->test_checksums) {
if (0 != ow_checksum(code, 8)) {
state->status = OW_SEARCH_FAILED;
state->error = E_CHECKSUM_MISMATCH;
goto done;
}
}
// Record a found address
memcpy(codes[found_devices], code, 8);
found_devices++;
// Stop condition
if (last_fork == -1) {
state->status = OW_SEARCH_DONE;

@ -51,6 +51,7 @@ struct ow_search_state {
enum ow_search_result status;
bool first;
bool test_checksums;
error_t error;
};
/**
@ -76,6 +77,6 @@ void ow_search_init(Unit *unit, uint8_t command, bool test_checksums);
* @param[in] capacity - buffer capacity
* @return number of romcodes found. Search status is stored in state->status
*/
uint16_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint16_t capacity);
uint32_t ow_search_run(Unit *unit, ow_romcode_t *codes, uint32_t capacity);
#endif //GEX_F072_OW_SEARCH_H

@ -98,7 +98,6 @@ static void U1WIRE_TimerCb(TimerHandle_t xTimer)
uint32_t time = PTIM_GetTime();
if (time - priv->busyStart > 1000) {
// dbg("Wait timed out. Stopping polling timer.");
xTimerStop(xTimer, 100);
com_respond_error(priv->busyRequestId, E_HW_TIMEOUT);
priv->busy = false;
@ -176,6 +175,170 @@ static void U1WIRE_deInit(Unit *unit)
// ------------------------------------------------------------------------
/**
* Check if there are any units present on the bus
*
* @param[in,out] unit
* @param[out] presence - any devices present
* @return success
*/
error_t UU_1WIRE_CheckPresence(Unit *unit, bool *presence)
{
CHECK_TYPE(unit, &UNIT_1WIRE);
// reset
*presence = ow_reset(unit);
return E_SUCCESS;
}
/**
* Read a device's address (use only with a single device attached)
*
* @param[in,out] unit
* @param[out] address - the device's address, 0 on error or CRC mismatch
* @return success
*/
error_t UU_1WIRE_ReadAddress(Unit *unit, uint64_t *address)
{
CHECK_TYPE(unit, &UNIT_1WIRE);
*address = 0;
if (!ow_reset(unit)) return E_HW_TIMEOUT;
// command
ow_write_u8(unit, OW_ROM_READ);
// read the ROM code
*address = ow_read_u64(unit);
const uint8_t *addr_as_bytes = (void*)address;
if (0 != ow_checksum(addr_as_bytes, 8)) {
*address = 0;
return E_CHECKSUM_MISMATCH; // checksum mismatch
}
return E_SUCCESS;
}
/**
* Write bytes to a device / devices
*
* @param[in,out] unit
* @param[in] address - device address, 0 to skip match (single device or broadcast)
* @param[in] buff - bytes to write
* @param[in] len - buffer length
* @return success
*/
error_t UU_1WIRE_Write(Unit *unit, uint64_t address, const uint8_t *buff, uint32_t len)
{
CHECK_TYPE(unit, &UNIT_1WIRE);
if (!ow_reset(unit)) return E_HW_TIMEOUT;
// MATCH_ROM+addr, or SKIP_ROM
if (address != 0) {
ow_write_u8(unit, OW_ROM_MATCH);
ow_write_u64(unit, address);
} else {
ow_write_u8(unit, OW_ROM_SKIP);
}
// write the payload;
for (uint32_t i = 0; i < len; i++) {
ow_write_u8(unit, *buff++);
}
return E_SUCCESS;
}
/**
* Read bytes from a device / devices, first writing a query
*
* @param[in,out] unit
* @param[in] address - device address, 0 to skip match (single device ONLY!)
* @param[in] request_buff - bytes to write before reading a response
* @param[in] request_len - number of bytes to write
* @param[out] response_buff - buffer for storing the read response
* @param[in] response_len - number of bytes to read
* @param[in] check_crc - verify CRC
* @return success
*/
error_t UU_1WIRE_Read(Unit *unit, uint64_t address,
const uint8_t *request_buff, uint32_t request_len,
uint8_t *response_buff, uint32_t response_len, bool check_crc)
{
CHECK_TYPE(unit, &UNIT_1WIRE);
if (!ow_reset(unit)) return E_HW_TIMEOUT;
uint8_t *rb = response_buff;
// MATCH_ROM+addr, or SKIP_ROM
if (address != 0) {
ow_write_u8(unit, OW_ROM_MATCH);
ow_write_u64(unit, address);
} else {
ow_write_u8(unit, OW_ROM_SKIP);
}
// write the payload;
for (uint32_t i = 0; i < request_len; i++) {
ow_write_u8(unit, *request_buff++);
}
// read the requested number of bytes
for (uint32_t i = 0; i < response_len; i++) {
*rb++ = ow_read_u8(unit);
}
if (check_crc) {
if (0 != ow_checksum(response_buff, response_len)) {
return E_CHECKSUM_MISMATCH;
}
}
return E_SUCCESS;
}
/**
* Perform a ROM search operation.
* The algorithm is on a depth-first search without backtracking,
* taking advantage of the open-drain topology.
*
* This function either starts the search, or continues it.
*
* @param[in,out] unit
* @param[in] with_alarm - true to match only devices in alarm state
* @param[in] restart - true to restart the search (search from the lowest address)
* @param[out] buffer - buffer for storing found addresses
* @param[in] capacity - buffer capacity in address entries (8 bytes)
* @param[out] real_count - real number of found addresses (for which the CRC matched)
* @param[out] have_more - flag indicating there are more devices to be found
* @return success
*/
error_t UU_1WIRE_Search(Unit *unit, bool with_alarm, bool restart,
uint64_t *buffer, uint32_t capacity, uint32_t *real_count,
bool *have_more)
{
CHECK_TYPE(unit, &UNIT_1WIRE);
struct priv *priv = unit->data;
if (restart) {
uint8_t search_cmd = (uint8_t) (with_alarm ? OW_ROM_ALM_SEARCH : OW_ROM_SEARCH);
ow_search_init(unit, search_cmd, true);
}
*real_count = ow_search_run(unit, (ow_romcode_t *) buffer, capacity);
// resolve the code
switch (priv->searchState.status) {
case OW_SEARCH_MORE:
*have_more = priv->searchState.status == OW_SEARCH_MORE;
case OW_SEARCH_DONE:
return E_SUCCESS;
case OW_SEARCH_FAILED:
return priv->searchState.error;
}
return E_FAILURE;
}
enum PinCmd_ {
CMD_CHECK_PRESENCE = 0, // simply tests that any devices are attached
CMD_SEARCH_ADDR = 1, // perform a scan of the bus, retrieving all found device ROMs
@ -183,29 +346,14 @@ enum PinCmd_ {
CMD_SEARCH_CONTINUE = 3, // continue the previously started scan, retrieving more devices
CMD_READ_ADDR = 4, // read the ROM code from a single device (for single-device bus)
CMD_SKIP_WRITE = 10, // write multiple bytes using the SKIP_ROM command
CMD_SKIP_READ = 11, // write and read multiple bytes using the SKIP_ROM command
CMD_MATCH_WRITE = 12, // write multiple bytes using a ROM address
CMD_MATCH_READ = 13, // write and read multiple bytes using a ROM address
CMD_WRITE = 10, // write multiple bytes using the SKIP_ROM command
CMD_READ = 11, // write multiple bytes using a ROM address
CMD_POLL_FOR_1 = 20,
CMD_TEST = 100,
};
/** send the match-rom with address from a payload parser, or skip-rom */
static void cmd_match_skip(Unit *unit, uint8_t command, PayloadParser *pp)
{
uint64_t addr;
if (command == CMD_MATCH_WRITE || command == CMD_MATCH_READ) {
addr = pp_u64(pp);
ow_write_u8(unit, OW_ROM_MATCH);
ow_write_u64(unit, addr);
}
else {
ow_write_u8(unit, OW_ROM_SKIP);
}
}
/** Handle a request message */
static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command, PayloadParser *pp)
@ -214,62 +362,54 @@ static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command,
bool presence;
uint64_t addr;
int remain;
uint32_t remain;
const uint8_t *tail;
if (priv->busy) return E_BUSY;
uint8_t search_cmd = OW_ROM_SEARCH;
bool with_alarm = false;
bool search_reset = false;
switch (command) {
case CMD_SEARCH_ALARM:
search_cmd = OW_ROM_ALM_SEARCH;
// pass-through
with_alarm = true;
// fall-through
case CMD_SEARCH_ADDR:
ow_search_init(unit, search_cmd, true);
// pass through
search_reset = true;
// fall-through
case CMD_SEARCH_CONTINUE:;
ow_romcode_t *codes = (void *) unit_tmp512;
uint16_t count = ow_search_run(unit, codes, UNIT_TMP_LEN/8);
if (priv->searchState.status == OW_SEARCH_FAILED) {
return E_HW_FAULT;
}
uint32_t found_count = 0;
bool have_more = false;
// First byte of the response is a flag whether there are more devices
// to be found using CMD_SEARCH_CONTINUE
uint8_t status_code = (uint8_t) (priv->searchState.status == OW_SEARCH_MORE);
TRY(UU_1WIRE_Search(unit, with_alarm, search_reset,
(void *) unit_tmp512, UNIT_TMP_LEN/8, &found_count,
&have_more));
// use multipart to avoid allocating extra buffer
uint8_t status_code = (uint8_t) have_more;
TF_Msg msg = {
.frame_id = frame_id,
.type = MSG_SUCCESS,
.len = (TF_LEN) (count * 8 + 1),
.len = (TF_LEN) (found_count * 8 + 1),
};
TF_Respond_Multipart(comm, &msg);
TF_Multipart_Payload(comm, &status_code, 1);
// the codes are back-to-back stored inside the buffer, we send it directly
// (it's already little-endian, as if built by PayloadBuilder)
TF_Multipart_Payload(comm, (uint8_t *) unit_tmp512, (uint32_t) (count * 8));
TF_Multipart_Payload(comm, (uint8_t *) unit_tmp512, found_count * 8);
TF_Multipart_Close(comm);
return E_SUCCESS;
/** Simply check presence of any devices on the bus. Responds with SUCCESS or HW_TIMEOUT */
case CMD_CHECK_PRESENCE:
// reset
presence = ow_reset(unit);
// build response
TRY(UU_1WIRE_CheckPresence(unit, &presence));
com_respond_u8(frame_id, (uint8_t) presence);
return E_SUCCESS;
/** Read address of the single device on the bus - returns u64 */
case CMD_READ_ADDR:
// reset
presence = ow_reset(unit);
if (!presence) return E_HW_FAULT;
// command
ow_write_u8(unit, OW_ROM_READ);
// read the ROM code
addr = ow_read_u64(unit);
TRY(UU_1WIRE_ReadAddress(unit, &addr));
// build response
PayloadBuilder pb = pb_start(unit_tmp512, UNIT_TMP_LEN, NULL);
@ -284,20 +424,10 @@ static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command,
* - Match variant: addr:u64, rest:write_data
* - Skip variant: all:write_data
*/
case CMD_MATCH_WRITE:
case CMD_SKIP_WRITE:
// reset
presence = ow_reset(unit);
if (!presence) return E_HW_FAULT;
// MATCH_ROM+addr, or SKIP_ROM
cmd_match_skip(unit, command, pp);
// write the rest of the payload
remain = pp_length(pp);
for (int i = 0; i < remain; i++) {
ow_write_u8(unit, pp_u8(pp));
}
case CMD_WRITE:
addr = pp_u64(pp);
tail = pp_tail(pp, &remain);
TRY(UU_1WIRE_Write(unit, addr, tail, remain));
return E_SUCCESS;
/**
@ -307,31 +437,19 @@ static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command,
* - Match variant: addr:u64, read_len:u16, rest:write_data
* - Skip variant: read_len:u16, rest:write_data
*/
case CMD_MATCH_READ:
case CMD_SKIP_READ:;
// reset
presence = ow_reset(unit);
if (!presence) return E_HW_FAULT;
// MATCH_ROM+addr, or SKIP_ROM
cmd_match_skip(unit, command, pp);
// paylod prefix - number of bytes to read
case CMD_READ:;
addr = pp_u64(pp);
uint16_t rcount = pp_u16(pp);
bool test_crc = pp_bool(pp);
tail = pp_tail(pp, &remain);
// write the rest of the payload
remain = pp_length(pp);
for (int i = 0; i < remain; i++) {
ow_write_u8(unit, pp_u8(pp));
}
// read the requested number of bytes
for (int i = 0; i < rcount; i++) {
unit_tmp512[i] = ow_read_u8(unit);
}
TRY(UU_1WIRE_Read(unit, addr,
tail, remain,
(uint8_t *) unit_tmp512, rcount,
test_crc));
// build response
com_respond_buf(frame_id, MSG_SUCCESS, (const uint8_t *) unit_tmp512, rcount);
com_respond_buf(frame_id, MSG_SUCCESS, (uint8_t *) unit_tmp512, rcount);
return E_SUCCESS;
/**
@ -341,6 +459,7 @@ static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command,
* Non-parasitic: Returns SUCCESS after device responds '1', HW_TIMEOUT after 1s
*/
case CMD_POLL_FOR_1:
// This can't be exposed via the UU API, due to being async
if (priv->parasitic) {
assert_param(pdPASS == xTimerChangePeriod(priv->busyWaitTimer, 750, 100));
} else {
@ -353,45 +472,6 @@ static error_t U1WIRE_handleRequest(Unit *unit, TF_ID frame_id, uint8_t command,
priv->busyRequestId = frame_id;
return E_SUCCESS; // We will respond when the timer expires
//
// case CMD_TEST:;
// bool presence = ow_reset(unit);
// if (!presence) return E_HW_TIMEOUT;
//
// ow_write_u8(unit, OW_ROM_SKIP);
//
// ow_write_u8(unit, OW_DS1820_CONVERT_T);
// while (!ow_read_bit(unit));
//
// // TODO use knowledge of the use/non-use of parasitic mode to pick the optimal strategy (non-parasitic allows polling)
//
// // osDelay(750);
// // TODO this will be done with an async timer
// // If parasitive power is not used, we could poll and check the status bit
//
// presence = ow_reset(unit);
// if (!presence) return E_HW_TIMEOUT;
// ow_write_u8(unit, OW_ROM_SKIP);
//
// ow_write_u8(unit, OW_DS1820_READ_SCRATCH);
//
// uint16_t temp = ow_read_u16(unit);
// uint16_t threg = ow_read_u16(unit);
// uint16_t reserved = ow_read_u16(unit);
// uint8_t cnt_remain = ow_read_u8(unit);
// uint8_t cnt_per_c = ow_read_u8(unit);
// uint8_t crc = ow_read_u8(unit);
// // TODO check CRC
//
// pb = pb_start(unit_tmp512, UNIT_TMP_LEN, NULL);
// pb_u16(&pb, temp);
// pb_u8(&pb, cnt_remain);
// pb_u8(&pb, cnt_per_c);
//
// dbg("respond ...");
// com_respond_buf(frame_id, MSG_SUCCESS, pb.start, pb_length(&pb));
// return E_SUCCESS;
default:
return E_UNKNOWN_COMMAND;
}

@ -11,4 +11,69 @@
extern const UnitDriver UNIT_1WIRE;
/**
* Check if there are any units present on the bus
*
* @param[in,out] unit
* @param[out] presence - any devices present
* @return success
*/
error_t UU_1WIRE_CheckPresence(Unit *unit, bool *presence);
/**
* Read a device's address (use only with a single device attached)
*
* @param[in,out] unit
* @param[out] address - the device's address, 0 on error or CRC mismatch
* @return success
*/
error_t UU_1WIRE_ReadAddress(Unit *unit, uint64_t *address);
/**
* Write bytes to a device / devices
*
* @param[in,out] unit
* @param[in] address - device address, 0 to skip match (single device or broadcast)
* @param[in] buff - bytes to write
* @param[in] len - buffer length
* @return success
*/
error_t UU_1WIRE_Write(Unit *unit, uint64_t address, const uint8_t *buff, uint32_t len);
/**
* Read bytes from a device / devices, first writing a query
*
* @param[in,out] unit
* @param[in] address - device address, 0 to skip match (single device ONLY!)
* @param[in] request_buff - bytes to write before reading a response
* @param[in] request_len - number of bytes to write
* @param[out] response_buff - buffer for storing the read response
* @param[in] response_len - number of bytes to read
* @param[in] check_crc - verify CRC
* @return success
*/
error_t UU_1WIRE_Read(Unit *unit, uint64_t address,
const uint8_t *request_buff, uint32_t request_len,
uint8_t *response_buff, uint32_t response_len, bool check_crc);
/**
* Perform a ROM search operation.
* The algorithm is on a depth-first search without backtracking,
* taking advantage of the open-drain topology.
*
* This function either starts the search, or continues it.
*
* @param[in,out] unit
* @param[in] with_alarm - true to match only devices in alarm state
* @param[in] restart - true to restart the search (search from the lowest address)
* @param[out] buffer - buffer for storing found addresses
* @param[in] capacity - buffer capacity in address entries (8 bytes)
* @param[out] real_count - real number of found addresses (for which the CRC matched)
* @param[out] have_more - flag indicating there are more devices to be found
* @return success
*/
error_t UU_1WIRE_Search(Unit *unit, bool with_alarm, bool restart,
uint64_t *buffer, uint32_t capacity, uint32_t *real_count,
bool *have_more);
#endif //GEX_F072_UNIT_1WIRE_H

@ -17,25 +17,26 @@
X(INTERNAL_ERROR, NULL) /* a bug */ \
X(LOADING, NULL) /* unit is loading */ \
X(UNKNOWN_COMMAND, NULL) \
X(NOT_IMPLEMENTED, NULL) \
X(NO_SUCH_UNIT, NULL) \
X(BAD_UNIT_TYPE, NULL) \
X(BAD_COUNT, NULL) \
X(MALFORMED_COMMAND, NULL) \
X(NOT_APPLICABLE, NULL) \
X(HW_TIMEOUT, NULL) \
X(HW_FAULT, NULL) \
X(NO_SUCH_UNIT, NULL) \
X(PROTOCOL_BREACH, NULL) /* eating with the wrong spoon */ \
X(BAD_UNIT_TYPE, NULL) \
X(NOT_IMPLEMENTED, NULL) \
X(BUSY, NULL) \
X(HW_TIMEOUT, NULL) /* timed out waiting for response, or received no ACK from hw device */ \
X(BUS_FAULT, NULL) /* further unspecified hardware bus fault */ \
X(CHECKSUM_MISMATCH, NULL) /* bus checksum failed */ \
X(PROTOCOL_BREACH, NULL) /* eating with the wrong spoon */ \
X(BUSY, NULL) /* Unit is busy */ \
\
/* VFS user errors (those are meant to be shown to user) */ \
X(ERROR_DURING_TRANSFER, "Error during transfer") \
X(TRANSFER_TIMEOUT, "Transfer timed out") \
X(OOO_SECTOR, "File sent out of order by PC") \
X(VFS_ERROR_DURING_TRANSFER, "Error during transfer") \
X(VFS_TRANSFER_TIMEOUT, "Transfer timed out") \
X(VFS_OOO_SECTOR, "File sent out of order by PC") \
\
/* File stream errors/status */ \
X(SUCCESS_DONE, NULL) \
X(SUCCESS_DONE_OR_CONTINUE, NULL) \
X(VFS_SUCCESS_DONE, NULL) \
X(VFS_SUCCESS_DONE_OR_MORE, NULL) \
\
/* Unit loading */ \
X(BAD_CONFIG, "Configuration error") \

@ -148,10 +148,10 @@ error_t stream_write(const uint8_t *data, uint32_t size)
// Write to stream
status = current_stream->write(&shared_state, data, size);
if (E_SUCCESS_DONE == status) {
if (E_VFS_SUCCESS_DONE == status) {
vfs_printf("Stream DONE");
stream_state = STREAM_STATE_END;
} else if ((E_SUCCESS_DONE_OR_CONTINUE == status) || (E_SUCCESS == status)) {
} else if ((E_VFS_SUCCESS_DONE_OR_MORE == status) || (E_SUCCESS == status)) {
// Stream should remain in the open state
assert_param(STREAM_STATE_OPEN == stream_state);
vfs_printf("Stream may close or get more data.,,");
@ -226,7 +226,7 @@ static error_t write_conf(void *state, const uint8_t *data, uint32_t size)
ini_parse((const char *) data, size);
return E_SUCCESS_DONE_OR_CONTINUE; // indicate we don't really know if it's over or not
return E_VFS_SUCCESS_DONE_OR_MORE; // indicate we don't really know if it's over or not
// TODO use some marker for EOF in the actual config files
}

@ -727,7 +727,7 @@ static void transfer_update_file_info(vfs_file_t file, uint32_t start_sector, ui
// Check - stream must be the same
if (stream != file_transfer_state.stream) {
vfs_printf(" error: changed types during transfer from %i to %i\r\n", stream, file_transfer_state.stream);
transfer_update_state(E_ERROR_DURING_TRANSFER);
transfer_update_state(E_VFS_ERROR_DURING_TRANSFER);
return;
}
@ -743,7 +743,7 @@ static void transfer_reset_file_info(void)
{
vfs_printf("vfs_manager transfer_reset_file_info()\r\n");
if (file_transfer_state.stream_open) {
transfer_update_state(E_ERROR_DURING_TRANSFER);
transfer_update_state(E_VFS_ERROR_DURING_TRANSFER);
} else {
file_transfer_state = default_transfer_state;
abort_remount();
@ -824,15 +824,15 @@ static void transfer_stream_data(uint32_t sector, const uint8_t *data, uint32_t
status = stream_write((uint8_t *) data, size);
vfs_printf(" stream_write ret=%i\r\n", (int)status);
if (E_SUCCESS_DONE == status) {
// Override status so E_SUCCESS_DONE
if (E_VFS_SUCCESS_DONE == status) {
// Override status so E_VFS_SUCCESS_DONE
// does not get passed into transfer_update_state
status = stream_close();
vfs_printf(" stream_close ret=%i\r\n", (int)status);
file_transfer_state.stream_open = false;
file_transfer_state.stream_finished = true;
file_transfer_state.stream_optional_finish = true;
} else if (E_SUCCESS_DONE_OR_CONTINUE == status) {
} else if (E_VFS_SUCCESS_DONE_OR_MORE == status) {
status = E_SUCCESS;
file_transfer_state.stream_optional_finish = true;
} else {
@ -852,8 +852,8 @@ static void transfer_update_state(error_t status)
bool transfer_must_be_finished;
bool out_of_order_sector;
error_t local_status = status;
assert_param((status != E_SUCCESS_DONE) &&
(status != E_SUCCESS_DONE_OR_CONTINUE));
assert_param((status != E_VFS_SUCCESS_DONE) &&
(status != E_VFS_SUCCESS_DONE_OR_MORE));
if (TRASNFER_FINISHED == file_transfer_state.transfer_state) {
trap("Xfer already closed");
@ -900,13 +900,13 @@ static void transfer_update_state(error_t status)
file_transfer_state.transfer_state = TRASNFER_FINISHED;
} else if (transfer_timeout) {
if (out_of_order_sector) {
local_status = E_OOO_SECTOR;
local_status = E_VFS_OOO_SECTOR;
} else if (!transfer_started) {
local_status = E_SUCCESS;
} else if (transfer_can_be_finished) {
local_status = E_SUCCESS;
} else {
local_status = E_TRANSFER_TIMEOUT;
local_status = E_VFS_TRANSFER_TIMEOUT;
}
file_transfer_state.transfer_state = TRASNFER_FINISHED;

Loading…
Cancel
Save