Difference between revisions of "Mobi8python"
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | < | + | <pre> |
import win32com.client | import win32com.client | ||
Line 24: | Line 24: | ||
#--------------sample data capture of 1000 samples, including printing ---------------- | #--------------sample data capture of 1000 samples, including printing ---------------- | ||
ReceivedSamples=0 | ReceivedSamples=0 | ||
− | DesiredSampleRate=HighestSampleRate/8 | + | DesiredSampleRate=HighestSampleRate/4 # do not use /8, PortiSerial.dll will crash after some time |
mobi8.SampleRate=DesiredSampleRate | mobi8.SampleRate=DesiredSampleRate | ||
error=mobi8.StartAcq(DesiredSampleRate) | error=mobi8.StartAcq(DesiredSampleRate) | ||
Line 43: | Line 43: | ||
print "ended" | print "ended" | ||
− | </ | + | </pre> |
Latest revision as of 09:06, 25 June 2009
import win32com.client #-------------connecting procedure---------------- print 'mobi8 demo interface' print 'W.Pasman 24june 2009' mobi8=win32com.client.Dispatch("PortiSerial.SerialSource") print "connecting with mobi8..." mobi8.ComPort="4" SerialNumber = mobi8.FrontendSerialNumber if SerialNumber==-1: raise Exception("can not open connection with mobi8."+ " Try to reconnect the mobi8 device via bluetooth") NrOfChannels=mobi8.GetFrontendNrOfChannels() HighestSampleRate=mobi8.SampleRate print "mobi8 connected with "+str(NrOfChannels)+" channels, max samplerate="+str(HighestSampleRate) #--------------sample data capture of 1000 samples, including printing ---------------- ReceivedSamples=0 DesiredSampleRate=HighestSampleRate/4 # do not use /8, PortiSerial.dll will crash after some time mobi8.SampleRate=DesiredSampleRate error=mobi8.StartAcq(DesiredSampleRate) f=open('out.txt','w') # dump to file while ReceivedSamples < 1000: Periods,samples=mobi8.GetSampleRecordAsVariant() if (Periods>0): ReceivedSamples = ReceivedSamples+Periods #print samples[0] for sample in samples[0]: # print channel 0 only. printing all is too much print >>f, sample #-----------------disconnect -------------------- error=mobi8.StopAcq() error=mobi8.ReleaseSerialPort() print "ended"