Esempio n. 1
0
static GOOD_OR_BAD LINK_sendback_data(const BYTE * data, BYTE * resp, const size_t size, const struct parsedname *pn)
{
	struct connection_in * in = pn->selected_connection ;
	size_t left = size;
	size_t location = 0 ;
	BYTE buf[1+LINK_SEND_SIZE*2+1+1+in->CRLF_size] ;
	
	if (size == 0) {
		return gbGOOD;
	}
	
	//Debug_Bytes( "ELINK sendback send", data, size) ;
	while (left > 0) {
		// Loop through taking only 32 bytes at a time
		size_t this_length = (left > LINK_SEND_SIZE) ? LINK_SEND_SIZE : left;
		size_t this_length2 = 2 * this_length ; // doubled for switch from hex to ascii
		
		buf[0] = 'b';			//put in byte mode
		bytes2string((char *) &buf[1], &data[location], this_length); // load in data as ascii data
		buf[1+this_length2] = '\r';	// take out of byte mode
		
		// send to LINK
		RETURN_BAD_IF_BAD(LINK_write(buf, 1+this_length2+1, in) ) ;
		
		// read back
		RETURN_BAD_IF_BAD( LINK_readback_data(buf, this_length2, in) ) ;
		
		// place data (converted back to hex) in resp
		string2bytes((char *) buf, &resp[location], this_length);
		left -= this_length;
		location += this_length ;
	}
	//Debug_Bytes( "ELINK sendback get", resp, size) ;
	return gbGOOD;
}
Esempio n. 2
0
		/** Send Data to Debug Server. **/
		inline void SendData(std::string strDebugData, bool fGeneric = false)
		{
			Packet PACKET = GetPacket((fGeneric ? GENERIC_DATA : DEBUG_DATA));
			PACKET.DATA   = string2bytes(strDebugData);
			PACKET.LENGTH = PACKET.DATA.size();
				
			this->WritePacket(PACKET);
		}
Esempio n. 3
0
static ZERO_OR_ERROR FS_redefchar_hex(struct one_wire_query *owq)
{
	struct parsedname *pn = PN(owq);
	BYTE data[LCD_REDEFCHAR_LENGTH] ;
	
	if ( OWQ_size(owq) != LCD_REDEFCHAR_LENGTH * 2 ) {
		return -ERANGE ;
	}
	if ( OWQ_offset(owq) != 0 ) {
		return -ERANGE ;
	}
	string2bytes( OWQ_buffer(owq), data, LCD_REDEFCHAR_LENGTH ) ;
		
	return GB_to_Z_OR_E( OW_redefchar( OWQ_buffer(owq), pn ) ) ;
}
    byte_str GTTPacket::build() const {
        std::stringstream head;

        // First line
        head << protocol << " " << method << String::crlf;

        // Headers
        for (auto it = headers.begin(); it != headers.end(); it++) {
            head << it->first << ": " << it->second << String::crlf;
        }
        if (body.size() > 0) {
            head << "content-length: " << body.size() << String::crlf;
        }
        head << String::crlf;

        // Concatenate headers and content
        std::string header = head.str();
        return string2bytes(header).append(body);
    }
Esempio n. 5
0
py::object workerJobSpec(comms::Worker &worker, uint jobID)
{
  return string2bytes(worker.jobSpec(jobID));
}
Esempio n. 6
0
py::object workerGlobalSpec(comms::Worker &worker)
{
  return string2bytes(worker.globalSpec());
}