302
302
TestClearMex(daq);
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...');
311
[TheOriginalData,TheErrors] = DaqMemRead(daq(1),512,59);
313
for k=1:length(TheErrors)
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']);
327
MemWriteTestData = 1:59;
329
fprintf('\nMemory was apparently read successfully...');
330
err=DaqMemWrite(daq(1),512,MemWriteTestData);
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']);
340
fprintf('\nMemory was apparently written successfully...');
342
[TheWrittenData,TheErrors] = DaqMemRead(daq(1),512,59);
344
for k=1:length(TheErrors)
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' ...
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']);
366
fprintf('\nI just read what I wrote, and it looks like I wrote what I thought I wrote!');
368
err=DaqMemWrite(daq(1),512,TheOriginalData(2:end));
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']);
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)
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...']);
305
% Disable EEPROM read/write tests by default. Having this on by default is
306
% just bat-shit crazy!!!
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...');
314
[TheOriginalData,TheErrors] = DaqMemRead(daq(1),512,59);
316
for k=1:length(TheErrors)
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']);
330
MemWriteTestData = 1:59;
332
fprintf('\nMemory was apparently read successfully...');
333
err=DaqMemWrite(daq(1),512,MemWriteTestData);
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']);
343
fprintf('\nMemory was apparently written successfully...');
345
[TheWrittenData,TheErrors] = DaqMemRead(daq(1),512,59);
347
for k=1:length(TheErrors)
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' ...
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']);
369
fprintf('\nI just read what I wrote, and it looks like I wrote what I thought I wrote!');
371
err=DaqMemWrite(daq(1),512,TheOriginalData(2:end));
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']);
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)
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...']);
388
fprintf('\n\nMoving on to test mode changes...');
385
391
TheStatus = DaqGetStatus(daq);
386
392
if isempty(TheStatus)
387
393
fprintf(['\nFailed to receive status report... Look inside DaqGetStatus and run\n' ...