Getcode function does not return output

Hi Chris,

I am trying to extract data using getcode, however it does not return any output. I was wondering if you have suggestion on how to fix this.
Thanks,
Eghbal

Hi Eghbal,

I’m not sure what you’re referring to. Do you mean the MWorks MATLAB function getCodecs? If so, then I’ll need some more details about how you’re trying to use it.

Cheers,
Chris

Yes, I meant ‘getCodecs’ , here is how I am calling the function:

d=dir([cd,‘/*’,‘.mwk’]);
codec = getCodecs(d(1).name);

it never returns an output, and I need to stop the function. I have attached the data file that causes the crash.

Thanks,
Eghbal

Hi Eghbal,

Thanks for the additional info.

Your data file seems to be corrupted. The event stream ends abruptly after a “Called stop on state system” message, whereas a normal experiment shutdown should contain many additional events after that point. Did this experiment terminate abnormally (e.g. with a MWServer crash)?

getCodecs is getting stuck because MWorks isn’t handling the corrupted data well. I can improve this somewhat, so that you’ll at least be able to retrieve events up to the point of corruption. I’ll try to get that fix in to the nightly build soon.

Cheers,
Chris

Hi Chris,

Thanks for your email.
The experiment did not terminate due to MWServer crash, after a number of trial experiment stopped manually.
Do you recommend any sequence for stopping the task( closing the stream, stopping MWClient, Stopping MWServer, etc).

Thanks,
Eghbal

Hi Eghbal,

Do you recommend any sequence for stopping the task( closing the stream, stopping MWClient, Stopping MWServer, etc).

I’d recommend the following sequence:

  1. Close data file (via MWClient)
  2. Close experiment (via MWClient)
  3. Close MWClient
  4. Close MWServer

However, regardless of the shutdown sequence, the data file shouldn’t get corrupted. Let me play around a little and see if there’s some ordering of these steps that leaves the data file in an invalid state. If there is, then I need to figure out how to prevent that from happening.

Thanks,
Chris

Hi Eghbal,

The currently nightly build has some changes relevant to this issue:

  1. You should now be able to read the pre-corruption portion of your event file.
  2. It should be much harder to end up with an invalid event file due to abnormal/unexpected server shutdown.

I believe the root of the issue is that, due to file I/O buffering, the end of the data file sometimes contained an incomplete event. If the file was closed normally, the missing data would be flushed to disk, and all would be well. However, if the server process shut down before that could happen, then the file would be unreadable.

In the currently nightly, MWServer now tries to ensure that the on-disk event data is always readable, even if the file is still open. Hopefully, this will eliminate (or at least greatly reduce) future occurrences of this problem.

Cheers,
Chris

Great, Thanks a lot.
Eghbal