~ubuntu-branches/ubuntu/trusty/psychtoolbox-3/trusty-proposed

« back to all changes in this revision

Viewing changes to Psychtoolbox/PsychTests/DaqTest.m

  • Committer: Package Import Robot
  • Author(s): Yaroslav Halchenko
  • Date: 2013-11-19 23:34:50 UTC
  • mfrom: (3.1.4 experimental)
  • Revision ID: package-import@ubuntu.com-20131119233450-f7nf92vb8qavjmk8
Tags: 3.0.11.20131017.dfsg1-3
Upload to unsable since fresh glew has arrived to sid!

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        end
102
102
      end
103
103
      numTries = numTries+1;
104
 
      if numTries > 1 & ~TheLEDBlinked
 
104
      if numTries > 1 && ~TheLEDBlinked
105
105
        ConfirmInfo('It should have blinked.  Since it didn''t and there were no obvious errors I will bail and let you work on it.');
106
106
        return;
107
107
      end
167
167
        end
168
168
      end
169
169
      numTries = numTries+1;
170
 
      if numTries > 1 & ~TheLEDBlinked
 
170
      if numTries > 1 && ~TheLEDBlinked
171
171
        ConfirmInfo('I don''t know why this didn''t work.  I hope you do because I am bailing!');
172
172
        return;
173
173
      end
231
231
% fprintf(['\n** NOT RESPONDING? If your %s is not responding, try quitting and\n'...
232
232
%     '** restarting MATLAB. Denis found that this reliably restored normal\n'...
233
233
%     '** communication for his device.\n'],devices(daq(1)).product);
234
 
if strcmp(devices(daq(1)).product,'USB-1208FS') | strcmp(devices(daq(1)).product,'PMD-1208FS') | strcmp(devices(daq(1)).product,'USB-1408FS')  
 
234
if strcmp(devices(daq(1)).product,'USB-1208FS') || strcmp(devices(daq(1)).product,'PMD-1208FS') || strcmp(devices(daq(1)).product,'USB-1408FS')  
235
235
  fprintf(['\n'...
236
236
      '** WIRING THE PINS OF THE USB-1208FS (and presumably -1408FS)\n'...
237
237
      '**    For the analog i/o test, please connect both channels of analog\n'...
302
302
    TestClearMex(daq);
303
303
end
304
304
 
305
 
% Denis originally did not test the memory read and write functions because he
306
 
% was afraid of messing up his firmware.  However, since this was one of the
307
 
% first sets of functions from which I got interpretable test results, I added
308
 
% some safeguards to DaqMemWrite and added tests of the functions here. -- mpr
309
 
fprintf('\nTesting my ability to read and write your daq device''s EEPROM...');
310
 
 
311
 
[TheOriginalData,TheErrors] = DaqMemRead(daq(1),512,59);
312
 
MemoryReadError = 0;
313
 
for k=1:length(TheErrors)
314
 
  if TheErrors(k).n
315
 
    MemoryReadError = 1;
316
 
    TheErrors(k)
317
 
  end
318
 
end
319
 
 
320
 
if MemoryReadError
321
 
  fprintf(['\nYou should have just been told of at least one error that occurred when I\n' ...
322
 
           'tried to read the EEPROM of your daq device.  Since it failed this test, I\n' ...
323
 
           'am aborting.  Sorry things didn''t work out...\n\n']);
324
 
  return;
325
 
end
326
 
 
327
 
MemWriteTestData = 1:59;
328
 
 
329
 
fprintf('\nMemory was apparently read successfully...');
330
 
err=DaqMemWrite(daq(1),512,MemWriteTestData);
331
 
if err.n
332
 
  fprintf(['\nUh oh... an error occurred when I tried to write to the EEPROM of your daq\n' ...
333
 
           'device.  Since that test failed, I am aborting.  I hope that I have not screwed\n' ...
334
 
           'up the memory of your device...  In any case, I am bailing out now.  Good\n' ...
335
 
           'luck fixing things!  What I was told was:\n\n']);
336
 
  err
337
 
  return;
338
 
end
339
 
 
340
 
fprintf('\nMemory was apparently written successfully...');
341
 
 
342
 
[TheWrittenData,TheErrors] = DaqMemRead(daq(1),512,59);
343
 
MemoryReadError = 0;
344
 
for k=1:length(TheErrors)
345
 
  if TheErrors(k).n
346
 
    MemoryReadError = 1;
347
 
    TheErrors(k)
348
 
  end
349
 
end
350
 
 
351
 
if MemoryReadError
352
 
  fprintf(['\nUh oh... I spoke too soon.  As you should just have been told, there was at\n' ...
353
 
           'least one error when I tried to read from your daq device a second time.  Odd that\n' ...
354
 
           'the device passed such a test once and then failed...  but that''s how things look\n' ...
355
 
           'to me.\n']);
356
 
  return;
357
 
end
358
 
 
359
 
if ~all(TheWrittenData(2:end) == MemWriteTestData)  
360
 
  fprintf(['\nUh oh...  I spoke too soon.  The data that I just read from the EEPROM of your\n' ...
361
 
           'daq device does not match the data that I think I just wrote to it.  I do not know\n' ...
362
 
           'why that might be.  Did you unplug it (sorry for such a lame question...).\n\n']);
363
 
  return;
364
 
end
365
 
 
366
 
fprintf('\nI just read what I wrote, and it looks like I wrote what I thought I wrote!');
367
 
 
368
 
err=DaqMemWrite(daq(1),512,TheOriginalData(2:end));
369
 
if err.n
370
 
  fprintf(['\nHmmmm...  I just tried to write your original data back to the EEPROM of your daq\n' ...
371
 
           'device.  That operation apparently failed.  I hope that I did not do any serious\n' ...
372
 
           'damage here...  It is unlikely that I did, but it is also unlikely that this function\n' ...
373
 
           'would fail here when it worked before.  Sorry things didn''t go more smoothly.  This\n' ...
374
 
           'is all I can tell you about the problem:\n\n']);
375
 
  err
376
 
  fprintf(['If you want to take matters into your own hands, the data I originally read from your\n' ...
377
 
           'daq''s EEPROM was:\n\n']);
378
 
  TheOriginalData(2:end)
379
 
  return;
380
 
end
381
 
 
382
 
fprintf(['\nEEPROM of your daq device has been restored to what it was before this test began.\n' ...
383
 
         'So far so good!\n\nMoving on to test mode changes...']);
384
 
       
 
305
% Disable EEPROM read/write tests by default. Having this on by default is
 
306
% just bat-shit crazy!!!
 
307
if 0
 
308
  % Denis originally did not test the memory read and write functions because he
 
309
  % was afraid of messing up his firmware.  However, since this was one of the
 
310
  % first sets of functions from which I got interpretable test results, I added
 
311
  % some safeguards to DaqMemWrite and added tests of the functions here. -- mpr
 
312
  fprintf('\nTesting my ability to read and write your daq device''s EEPROM...');
 
313
 
 
314
  [TheOriginalData,TheErrors] = DaqMemRead(daq(1),512,59);
 
315
  MemoryReadError = 0;
 
316
  for k=1:length(TheErrors)
 
317
    if TheErrors(k).n
 
318
      MemoryReadError = 1;
 
319
      TheErrors(k)
 
320
    end
 
321
  end
 
322
 
 
323
  if MemoryReadError
 
324
    fprintf(['\nYou should have just been told of at least one error that occurred when I\n' ...
 
325
             'tried to read the EEPROM of your daq device.  Since it failed this test, I\n' ...
 
326
             'am aborting.  Sorry things didn''t work out...\n\n']);
 
327
    return;
 
328
  end
 
329
 
 
330
  MemWriteTestData = 1:59;
 
331
 
 
332
  fprintf('\nMemory was apparently read successfully...');
 
333
  err=DaqMemWrite(daq(1),512,MemWriteTestData);
 
334
  if err.n
 
335
    fprintf(['\nUh oh... an error occurred when I tried to write to the EEPROM of your daq\n' ...
 
336
             'device.  Since that test failed, I am aborting.  I hope that I have not screwed\n' ...
 
337
             'up the memory of your device...  In any case, I am bailing out now.  Good\n' ...
 
338
             'luck fixing things!  What I was told was:\n\n']);
 
339
    err
 
340
    return;
 
341
  end
 
342
 
 
343
  fprintf('\nMemory was apparently written successfully...');
 
344
 
 
345
  [TheWrittenData,TheErrors] = DaqMemRead(daq(1),512,59);
 
346
  MemoryReadError = 0;
 
347
  for k=1:length(TheErrors)
 
348
    if TheErrors(k).n
 
349
      MemoryReadError = 1;
 
350
      TheErrors(k)
 
351
    end
 
352
  end
 
353
 
 
354
  if MemoryReadError
 
355
    fprintf(['\nUh oh... I spoke too soon.  As you should just have been told, there was at\n' ...
 
356
             'least one error when I tried to read from your daq device a second time.  Odd that\n' ...
 
357
             'the device passed such a test once and then failed...  but that''s how things look\n' ...
 
358
             'to me.\n']);
 
359
    return;
 
360
  end
 
361
 
 
362
  if ~all(TheWrittenData(2:end) == MemWriteTestData)  
 
363
    fprintf(['\nUh oh...  I spoke too soon.  The data that I just read from the EEPROM of your\n' ...
 
364
             'daq device does not match the data that I think I just wrote to it.  I do not know\n' ...
 
365
             'why that might be.  Did you unplug it (sorry for such a lame question...).\n\n']);
 
366
    return;
 
367
  end
 
368
 
 
369
  fprintf('\nI just read what I wrote, and it looks like I wrote what I thought I wrote!');
 
370
 
 
371
  err=DaqMemWrite(daq(1),512,TheOriginalData(2:end));
 
372
  if err.n
 
373
    fprintf(['\nHmmmm...  I just tried to write your original data back to the EEPROM of your daq\n' ...
 
374
             'device.  That operation apparently failed.  I hope that I did not do any serious\n' ...
 
375
             'damage here...  It is unlikely that I did, but it is also unlikely that this function\n' ...
 
376
             'would fail here when it worked before.  Sorry things didn''t go more smoothly.  This\n' ...
 
377
             'is all I can tell you about the problem:\n\n']);
 
378
    err
 
379
    fprintf(['If you want to take matters into your own hands, the data I originally read from your\n' ...
 
380
             'daq''s EEPROM was:\n\n']);
 
381
    TheOriginalData(2:end)
 
382
    return;
 
383
  end
 
384
 
 
385
  fprintf(['\nEEPROM of your daq device has been restored to what it was before this test began.\n' ...
 
386
           'So far so good!\n\nMoving on to test mode changes...']);
 
387
else
 
388
  fprintf('\n\nMoving on to test mode changes...');
 
389
end
 
390
 
385
391
TheStatus = DaqGetStatus(daq);
386
392
if isempty(TheStatus)
387
393
  fprintf(['\nFailed to receive status report...  Look inside DaqGetStatus and run\n' ...
538
544
  data=DaqDIn(daq(1));
539
545
  if ~isempty(data)
540
546
    fprintf('DaqDIn: %3d %3d.\n',data);
541
 
    if length(data) ~= 2 | ~all(data == [a b])
 
547
    if length(data) ~= 2 || ~all(data == [a b])
542
548
      disp('Mismatch between what I read and what I wrote.  I will stop to let you investigate.');
543
549
      return;
544
550
    else