Re: C MEX S-Function Builder




Hello Ashish,

Many thanks for your reply.I also do not understand what is going
wrong and about to go mad really. Anyway, i tried to use union once
more:

Just before initialization function,

typedef union { uint8_T uvalue[8];
real_T d;
} UnionNum;

static void mdlOutputs(SimStruct *S, int_T tid)

{
int_T i;
int_T width = ssGetOutputPortWidth(S,0);

InputPtrsType uPtrs = ssGetInputPortSignalPtrs(S,0);

uint8_T *y = (uint8_T *)ssGetOutputPortSignal(S,0);
UnionNum num;
num.d = uPtrs ;

This is incorrect, the assignment shoult be:

num.d = *uPtrs[0];

uPtrs is a pointer to a pointer to the input so you cannot assign it
directly to a double.

Also try adding this line for debugging:

ssPrintf("sizeof union = %d\n",sizeof(num));

If the value printed is greater than 8 that means your machine doesn't
support a uint8s and so uint8_T is actually something larger. In that
case you'll have to do some bitwise AND and shifting math to get your
result.


for(i=0; i<width; i++)
{
y[i] = num.uvalue[i];

}
}

This time it gives me this error message :

>> mex double2integer.c
Error double2integer.c: 79 operands of = have illegal types `double'
and `pointer to const pointer to const void'

Why does it have problem with 'double'? Do you see anything to
correct here? I appreciate your help again. Thank you.

Regards,
Cahit

HTH,
Ashish.

.



Relevant Pages

  • [PATCH 1/1] Char: ip2, macros cleanup
    ... remove i2os.h -- there was only macro to macro renaming or useless ... -// Given a pointer to board structure, read a byte or word from the fifo ... // Add the channel pointer to list of channels needing service (first ...
    (Linux-Kernel)
  • [PATCH] usb: kfree cleanup for drivers/usb/* - no need to check for NULL
    ... there's no need to check a pointer for NULL before calling kfreeon it. ... static void auerswald_int_free ... the urb is finished. ... /* if this urb had a transfer buffer already free it */ ...
    (Linux-Kernel)
  • Re: [KVM PATCH v8 3/3] KVM: add iosignalfd support
    ... Sorry, Michael. ... * (wildcard), or to a write of a specific value. ... highly suspect that the pointer is already aligned anyway. ...
    (Linux-Kernel)
  • Re: [KVM PATCH v8 3/3] KVM: add iosignalfd support
    ... * (wildcard), or to a write of a specific value. ... However, you can't cast an unaligned pointer, or it ... highly suspect that the pointer is already aligned anyway. ...
    (Linux-Kernel)
  • Reading data from File
    ... I have written a Level2-C-Sfunction for reading blocks of data from a *.dat file. ... static void mdlInitializeSampleTimes ... open the file and store the pointer ... ssPrintf(" \n EOF Not Reached \n"); ...
    (comp.soft-sys.matlab)

Loading