def receive(samples):
    """
    Convert an array of voltage samples into a message string.
    """
    # digitize the voltage samples
    d_samples = v_samples_to_d_samples(samples)
    nsamples = len(d_samples)

    # search through the samples starting at the beginning
    message = []
    start = 0
    
    while True:
        # locate sample at middle of next START bit
        start = find_center_of_start_bit(d_samples,start,8)
        if start < 0 or start + 10*8 >= nsamples:
            break  # no START bit found or too near end of samples

        # grab the eight data bits which follow
        bits = decode_data(d_samples,start+8,8,8)
#         print bits

        # first convert bit sequence to an int
        # and then to a character, append to message
        message.append(chr(lab1.bits_to_int(bits)))
        # finally skip to the middle of the STOP bit
        # and start looking for the next START bit
        start += 9*8

    # join all the message characters into a single string
    return "".join(message)
def translateCharacter(recievedSamples,startPosition):
	sequence = numpy.array(recievedSamples[startPosition:startPosition+10])
	tenBitIndex = lab1.bits_to_int(sequence)
	eightBitIndex = lab1.table_10b_8b[tenBitIndex]
	if eightBitIndex == None:
		return None
	character = chr(eightBitIndex)
	return character