/*Function to set contrast of GLCD*/ void GLCD::GLCD_contrast(char val) { static char checksum; checksum = WRITE_CONTRAST ^ val; tx_data(WRITE_CONTRAST); tx_data(val); tx_data(checksum); }
/*Function to send string to GLCD*/ void GLCD::GLCD_write_str(char cmd, char str_index, char *str) { static char checksum; uint8_t len; len = strlen(str); tx_data(cmd); tx_data(str_index); checksum = (cmd ^ str_index ^ len); tx_data(len); for (int i = 0; str[i] != '\0'; i++) { tx_data(str[i]); //Send every character from string checksum ^= str[i]; } tx_data(checksum); }
// net_tx_task - send network messages void tx_net_task() { volatile uint8_t counter = 0; volatile uint8_t tx_data_flag; // print task pid printf("tx_net PID: %d.\r\n", nrk_get_pid()); // Wait until bmac has started. This should be called by all tasks // using bmac that do not call bmac_init(). while(!bmac_started ()) { nrk_wait_until_next_period (); } // loop forever while(1) { // increment counter and set flags counter++; tx_data_flag = counter % NODE_TX_DATA_FLAG; // if data shoudl be transmitted, then call the tx_data() helper if (TRANSMIT == tx_data_flag) { tx_data(); counter = 0; } else { tx_cmds(); } // nrk_kprintf(PSTR("OUT\r\n")); nrk_wait_until_next_period(); } nrk_kprintf(PSTR("Fallthrough: tx_net_task\r\n")); }
/*Function to send float to string object of GLCD*/ void GLCD::GLCD_write_float(char cmd, char str_index, float val, uint8_t precision) { static char checksum; uint8_t len; char str[12]; sprintf(str,"%.*f",precision,val); len = strlen(str); tx_data(cmd); tx_data(str_index); checksum = (cmd ^ str_index ^ len); tx_data(len); for (int i = 0; str[i] != '\0'; i++) { tx_data(str[i]); //Send every character from string checksum ^= str[i]; } tx_data(checksum); }
bool leveldb_common::save_transaction(leveldb_transaction_batch& batch, uint32_t block_height, uint32_t tx_index, const hash_digest& tx_hash, const transaction_type& block_tx) { if (duplicate_exists(tx_hash, block_height, tx_index)) return true; data_chunk tx_data(8 + satoshi_raw_size(block_tx)); // Serialize tx. auto serial = make_serializer(tx_data.begin()); serial.write_4_bytes(block_height); serial.write_4_bytes(tx_index); // Actual tx data. auto end_iter = satoshi_save(block_tx, serial.iterator()); BITCOIN_ASSERT( std::distance(tx_data.begin(), end_iter) == 8 + satoshi_raw_size(block_tx)); // Save tx to leveldb batch.tx.Put(slice(tx_hash), slice(tx_data)); // Add inputs to spends database. // Coinbase inputs do not spend anything. if (!is_coinbase(block_tx)) for (uint32_t input_index = 0; input_index < block_tx.inputs.size(); ++input_index) { const transaction_input_type& input = block_tx.inputs[input_index]; const input_point inpoint{tx_hash, input_index}; if (!mark_spent_outputs(batch.spend, input.previous_output, inpoint)) return false; if (!add_debit(batch.debit, input, {tx_hash, input_index}, block_height)) return false; } // Save address -> output mappings. for (uint32_t output_index = 0; output_index < block_tx.outputs.size(); ++output_index) { const transaction_output_type& output = block_tx.outputs[output_index]; if (!add_credit(batch.credit, output, {tx_hash, output_index}, block_height)) return false; } return true; }
/*Function to send value for particular object to GLCD*/ void GLCD::GLCD_write(char cmd, char obj_id, char obj_index, char data_msb, char data_lsb) { static char checksum; checksum = cmd ^ obj_id ^ obj_index ^ data_msb ^ data_lsb; tx_data(cmd); tx_data(obj_id); tx_data(obj_index); tx_data(data_msb); tx_data(data_lsb); tx_data(checksum); }
bool leveldb_common::save_transaction(leveldb_transaction_batch& batch, uint32_t block_height, uint32_t tx_index, const hash_digest& tx_hash, const transaction_type& block_tx) { if (is_special_duplicate(block_height, tx_index)) return true; data_chunk tx_data(8 + satoshi_raw_size(block_tx)); // Serialize tx. auto serial = make_serializer(tx_data.begin()); serial.write_4_bytes(block_height); serial.write_4_bytes(tx_index); // Actual tx data. auto end_iter = satoshi_save(block_tx, serial.iterator()); BITCOIN_ASSERT( tx_data.begin() + 8 + satoshi_raw_size(block_tx) == end_iter); // Save tx to leveldb batch.tx.Put(slice(tx_hash), slice(tx_data)); // Add inputs to spends database. // Coinbase inputs do not spend anything. if (!is_coinbase(block_tx)) for (uint32_t input_index = 0; input_index < block_tx.inputs.size(); ++input_index) { const transaction_input_type& input = block_tx.inputs[input_index]; const input_point inpoint{tx_hash, input_index}; if (!mark_spent_outputs(batch.spend, input.previous_output, inpoint)) return false; if (!add_debit(batch.debit, input, {tx_hash, input_index}, block_height)) return false; } // A stack of size 1. Keep the stealth_data from // one iteration to the next. data_chunk stealth_data_store; auto unload_stealth_store = [&]() { return std::move(stealth_data_store); }; // Save address -> output mappings. for (uint32_t output_index = 0; output_index < block_tx.outputs.size(); ++output_index) { const transaction_output_type& output = block_tx.outputs[output_index]; // If a stealth output then skip processing. if (process_stealth_output_info(output, stealth_data_store)) continue; data_chunk stealth_data = unload_stealth_store(); // Try to extract an address. payment_address address; if (!extract(address, output.script)) continue; // Process this output. if (!stealth_data.empty()) add_stealth_info(stealth_data, address, tx_hash, *db_stealth_); if (!add_credit(batch.credit, address, output.value, {tx_hash, output_index}, block_height)) return false; } return true; }