Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: aa242f7c66cc
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ed9503868180
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on May 29, 2015

  1. Copy the full SHA
    575dfad View commit details
  2. Copy the full SHA
    ed95038 View commit details
Showing with 10 additions and 13 deletions.
  1. +4 −8 artiq/coredevice/comm_generic.py
  2. +1 −1 soc/runtime/flash_storage.c
  3. +5 −4 soc/runtime/session.c
12 changes: 4 additions & 8 deletions artiq/coredevice/comm_generic.py
Original file line number Diff line number Diff line change
@@ -43,9 +43,8 @@ class _D2HMsgType(Enum):
RPC_REQUEST = 10

FLASH_READ_REPLY = 11
FLASH_WRITE_REPLY = 12
FLASH_OK_REPLY = 13
FLASH_ERROR_REPLY = 14
FLASH_OK_REPLY = 12
FLASH_ERROR_REPLY = 13


class UnsupportedDevice(Exception):
@@ -148,14 +147,11 @@ def flash_storage_write(self, key, value):
self.write(b"\x00")
self.write(value)
_, ty = self._read_header()
if ty != _D2HMsgType.FLASH_WRITE_REPLY:
if ty != _D2HMsgType.FLASH_OK_REPLY:
if ty == _D2HMsgType.FLASH_ERROR_REPLY:
raise IOError("Invalid key: not a null-terminated string")
raise IOError("Flash storage is full")
else:
raise IOError("Incorrect reply from device: {}".format(ty))
ret = self.read(1)
if ret != b"\x01":
raise IOError("Flash storage is full")

def flash_storage_erase(self):
self._write_header(9, _H2DMsgType.FLASH_ERASE_REQUEST)
2 changes: 1 addition & 1 deletion soc/runtime/flash_storage.c
Original file line number Diff line number Diff line change
@@ -284,7 +284,7 @@ unsigned int fs_read(char *key, void *buffer, unsigned int buf_len, unsigned int
memcpy(buffer, record.value, min(record.value_len, buf_len));
read_length = min(record.value_len, buf_len);
if(remain)
*remain = max(0, (int)(record.value_len) - (int)buf_len);
*remain = max(0, (int)record.value_len - (int)buf_len);
}
}

9 changes: 5 additions & 4 deletions soc/runtime/session.c
Original file line number Diff line number Diff line change
@@ -112,7 +112,6 @@ enum {
REMOTEMSG_TYPE_RPC_REQUEST,

REMOTEMSG_TYPE_FLASH_READ_REPLY,
REMOTEMSG_TYPE_FLASH_WRITE_REPLY,
REMOTEMSG_TYPE_FLASH_OK_REPLY,
REMOTEMSG_TYPE_FLASH_ERROR_REPLY
};
@@ -259,9 +258,11 @@ static int process_input(void)
value = key + key_len;
ret = fs_write(key, value, value_len);

buffer_out[8] = REMOTEMSG_TYPE_FLASH_WRITE_REPLY;
buffer_out[9] = ret;
submit_output(10);
if(ret)
buffer_out[8] = REMOTEMSG_TYPE_FLASH_OK_REPLY;
else
buffer_out[8] = REMOTEMSG_TYPE_FLASH_ERROR_REPLY;
submit_output(9);
break;
}
case REMOTEMSG_TYPE_FLASH_ERASE_REQUEST: {