Skip to content

Commit

Permalink
Merge f38441b into a89afd1
Browse files Browse the repository at this point in the history
  • Loading branch information
alan-stokes committed Mar 28, 2018
2 parents a89afd1 + f38441b commit 1ff524b
Show file tree
Hide file tree
Showing 29 changed files with 1,773 additions and 215 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ Debug
lastfailed
/.cache
.coverage
.DS_Store
*.o
*.a
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@ dist: trusty

addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libc6:i386
- vera++
- libxml2-utils
- gcc-arm-none-eabi
- libnewlib-arm-none-eabi
- g++-5

cache: pip

Expand Down Expand Up @@ -54,7 +57,9 @@ script:
- find spinn_front_end_common -name '*.xml' | xargs -n 1 support/validate-xml.sh
# C
- make -C c_common
- make -C cpp_common CXX="g++-5"
- support/run-vera.sh c_common
- support/run-vera.sh cpp_common
# Docs
- support/travis-sphinx.sh html -T -E -b html -d _build/doctrees-readthedocsdirhtml -D language=en . _build/html
- support/travis-sphinx.sh json -T -b json -d _build/doctrees-json -D language=en . _build/json
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ static uint32_t infinite_run;
static uint32_t new_sequence_key = 0;
static uint32_t first_data_key = 0;
static uint32_t end_flag_key = 0;
static uint32_t odd_data_packet_key = 0;

//! default seq num
static uint32_t seq_num = FIRST_SEQ_NUM;
Expand All @@ -61,6 +62,13 @@ static uint32_t position_in_store = 0;
//! sdp message holder for transmissions
sdp_msg_pure_data my_msg;

//! human readable definitions of the flags for no payload state machine
typedef enum state_machine_flags {
EMPTY = 0, NEXT_SEQ_NUM_COMING = 1, FIRST_DATA = 2, ODD_DATA_ITEM = 3
} state_machine_flags;

//! variable for determining next action from a no payload command
static uint32_t next_no_payload_command = EMPTY;

//! human readable definitions of each region in SDRAM
typedef enum regions_e {
Expand All @@ -69,12 +77,12 @@ typedef enum regions_e {

//! human readable definitions of the data in each region
typedef enum config_elements {
NEW_SEQ_KEY, FIRST_DATA_KEY, END_FLAG_KEY, TAG_ID
NEW_SEQ_KEY, FIRST_DATA_KEY, END_FLAG_KEY, ODD_DATA_PACKET_KEY, TAG_ID
} config_elements;

//! values for the priority for each callback
typedef enum callback_priorities{
MC_PACKET = -1, SDP = 0, DMA = 0
FR_PACKET = -1, SDP = 0, DMA = 0
} callback_priorities;


Expand Down Expand Up @@ -102,58 +110,90 @@ void send_data(){
// Empty body
}

//log_info("done");
position_in_store = 1;
seq_num += 1;
data[0] = seq_num;
}

void receive_data(uint key, uint payload) {
//log_info("packet!");
if (key == new_sequence_key) {
if (position_in_store != 1) {
void receive_data_no_payload(uint key, uint payload) {
//log_info("received command with key %u", key);
// expecting a new command
use(payload);

if (next_no_payload_command == EMPTY){
if (key == new_sequence_key) {
//log_info("new seq start");
next_no_payload_command = NEXT_SEQ_NUM_COMING;
}
else if (key == end_flag_key){
// set end flag bit in seq num
//log_info("sending end data");
//log_info("position = %d", position_in_store);
data[0] = data[0] + (1 << 31);
send_data();
}
//log_info("finding new seq num %d", payload);
//log_info("position in store is %d", position_in_store);
data[0] = payload;
seq_num = payload;
else if (key == first_data_key){
//log_info("first data start");
next_no_payload_command = FIRST_DATA;
}
else if (key == odd_data_packet_key){
//log_info("odd data start");
next_no_payload_command = ODD_DATA_ITEM;
}
else{
//log_info("strange code, next_no_payload_command is %d",
// next_no_payload_command);
}
} // expecting data from a old command
else if (next_no_payload_command == NEXT_SEQ_NUM_COMING){
//log_info("first data end with key %d", key);
data[0] = key;
seq_num = key;
position_in_store = 1;

if (payload > max_seq_num){
if (key > max_seq_num){
log_error(
"got a funky seq num. max is %d, received %d",
max_seq_num, payload);
max_seq_num, key);
}
} else {
next_no_payload_command = EMPTY;

//log_info(" payload = %d posiiton = %d", payload, position_in_store);
data[position_in_store] = payload;
} else if (next_no_payload_command == FIRST_DATA){
//log_info("resetting seq and position");
seq_num = FIRST_SEQ_NUM;
data[0] = seq_num;
position_in_store = 1;
max_seq_num = key;
next_no_payload_command = EMPTY;

} else if (next_no_payload_command == ODD_DATA_ITEM){
//log_info("odd data process");
data[position_in_store] = key;
position_in_store += 1;
//log_info("payload is %d", payload);

if (key == first_data_key) {
//log_info("resetting seq and position");
seq_num = FIRST_SEQ_NUM;
data[0] = seq_num;
position_in_store = 1;
max_seq_num = payload;
//log_info("position in store %d", position_in_store);
next_no_payload_command = EMPTY;
if (position_in_store == ITEMS_PER_DATA_PACKET) {
send_data();
}

if (key == end_flag_key){
// set end flag bit in seq num
data[0] = data[0] + (1 << 31);
} else{
log_error("Got a strange command in the logic flow."
"next_no_payload_command is %d", next_no_payload_command);
}

// adjust size as last payload not counted
position_in_store = position_in_store - 1;
}

//log_info("position = %d with seq num %d", position_in_store, seq_num);
//log_info("last payload was %d", payload);
send_data();
} else if (position_in_store == ITEMS_PER_DATA_PACKET) {
//log_info("position = %d with seq num %d", position_in_store, seq_num);
//log_info("last payload was %d", payload);
send_data();
}
void receive_data_payload(uint key, uint payload) {
//log_info("next_no_payload_command = %d", next_no_payload_command);
//log_info("payload = %d position = %d", payload, position_in_store);
data[position_in_store] = key;
position_in_store += 1;
data[position_in_store] = payload;
position_in_store += 1;
if (position_in_store == ITEMS_PER_DATA_PACKET) {
//log_info("position = %d with seq num %d", position_in_store, seq_num);
//log_info("last payload was %d", key);
send_data();
}
}

Expand Down Expand Up @@ -181,6 +221,7 @@ static bool initialize(uint32_t *timer_period) {
new_sequence_key = config_address[NEW_SEQ_KEY];
first_data_key = config_address[FIRST_DATA_KEY];
end_flag_key = config_address[END_FLAG_KEY];
odd_data_packet_key = config_address[ODD_DATA_PACKET_KEY];

my_msg.tag = config_address[TAG_ID]; // IPTag 1
my_msg.dest_port = PORT_ETH; // Ethernet
Expand Down Expand Up @@ -216,7 +257,8 @@ void c_main() {
rt_error(RTE_SWERR);
}

spin1_callback_on(FRPL_PACKET_RECEIVED, receive_data, MC_PACKET);
spin1_callback_on(FRPL_PACKET_RECEIVED, receive_data_payload, FR_PACKET);
spin1_callback_on(FR_PACKET_RECEIVED, receive_data_no_payload, FR_PACKET);

// start execution
log_info("Starting\n");
Expand Down
Loading

0 comments on commit 1ff524b

Please sign in to comment.