<commit_before>from pymoku import Moku
from pymoku.instruments import *
import time, logging

logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(message)s')
logging.getLogger('pymoku').setLevel(logging.DEBUG)

# Use Moku.get_by_serial() or get_by_name() if you don't know the IP
m = Moku.get_by_name('example')

i = m.discover_instrument()

if i is None or i.type != 'oscilloscope':
	print "No or wrong instrument deployed"
	i = Oscilloscope()
	m.attach_instrument(i)
else:
	print "Attached to existing Oscilloscope"

try:
	i.set_defaults()
	i.set_samplerate(100) #10ksps
	i.set_xmode(OSC_ROLL)
	i.commit()

	print i.datalogger_status()
	if i.datalogger_busy():
		print "Stopping previous session"
		i.datalogger_stop()

	i.datalogger_start(start=0, duration=10, use_sd=True, ch1=True, ch2=True, filetype='csv')

	while True:
		time.sleep(1)
		trems, treme = i.datalogger_remaining()
		samples = i.datalogger_samples()
		print "Captured (%d samples); %d seconds from start, %d from end" % (samples, trems, treme)
		# TODO: Symbolic constants
		if i.datalogger_completed():
			break

	e = i.datalogger_error()

	if e:
		print "Error occured: %s" % e

	i.datalogger_stop()
	i.datalogger_upload()
except Exception as e:
	print e
finally:
	m.close()<commit_msg>Datalogger: Simplify basic datalogger example<commit_after>from pymoku import Moku
from pymoku.instruments import *
import time, logging

logging.basicConfig(format='%(asctime)s:%(name)s:%(levelname)s::%(message)s')
logging.getLogger('pymoku').setLevel(logging.DEBUG)

# Use Moku.get_by_serial() or get_by_name() if you don't know the IP
m = Moku.get_by_name('example')

i = Oscilloscope()
m.attach_instrument(i)

try:
	i.set_defaults()
	i.set_samplerate(10)
	i.set_xmode(OSC_ROLL)
	i.commit()

	i.datalogger_stop()

	i.datalogger_start(start=0, duration=10, use_sd=True, ch1=True, ch2=True, filetype='bin')

	while True:
		time.sleep(1)
		trems, treme = i.datalogger_remaining()
		samples = i.datalogger_samples()
		print "Captured (%d samples); %d seconds from start, %d from end" % (samples, trems, treme)

		if i.datalogger_completed():
			break

	e = i.datalogger_error()

	if e:
		print "Error occured: %s" % e

	i.datalogger_stop()
	i.datalogger_upload()
except Exception as e:
	print e
finally:
	m.close()
{'fraction_non_alphanumeric': 0.13479212253829323, 'fraction_numerical': 0.008315098468271335, 'mean_word_length': 5.35, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5258727', 'n_tokens_mistral': 942, 'n_tokens_neox': 907, 'n_words': 202}