0

I have a TLC generated mexfunction with 2 inputs and 0 output. input 1 is unsigned char and input 2 is unsigned int.

When I try to get input values with:

unsigned char *u1 = ssGetInputPortSignal(S,0);     (uint8)    
unsigned int  *u2 = ssGetInputPortSignal(S,1);     (uint16)

mexPrintf("value1 %d\n",*u1);
mexPrintf("value2 %d\n",*u2);

why u2 depends on u1?

for example: in simulink the input port #1 = 2;*u1= 2;

but in simulink the input port #2 = 1000;*u2= *u2 +(*u1*65636);

I see this in mexprint..

I get u2 with a factor depends on the first input port

I set InputPortRequiredContiguous and InputPortDirectFeedThrough to 1.

Praetorian
  • 106,671
  • 19
  • 240
  • 328
  • There's a preview box provided so you can properly format your question before posting it. You say input 2 is `unsigned int`, but seem to also indicate that it is `uint16`. Which is it? If it is `uint16`, then your problem probably is that `unsigned int` is 32-bit and you're reading the memory location where `u1` is stored. Use `unsigned short *u2 = ssGetInputPortSignal(S,1);`. Or better yet, use the fixed width types that mex defines - `uint16_T *u2 = ssGetInputPortSignal(S,1);` – Praetorian Jun 10 '15 at 17:51
  • Thanks for reply ! originally i have a typedef for u1 and u2 so it looks this way: typedef unsigned char FaultC typdef unsigned int addData FaultC *u1 = (FaultC*) ssGetInputPortSignal(S,0); addData *u2 = (addData*) ssGetInputPortSignal(S,1); (types are registered) – David Németh-Nagy Jun 10 '15 at 17:53
  • sorry for the bad format, quite new here. – David Németh-Nagy Jun 10 '15 at 17:56
  • 1
    You should add details to your question by clicking the *edit* button below it. Change your `typedef`s to `typedef uint8_T FaultC; typedef uint16_T addData;`, hopefully that'll fix your problem. – Praetorian Jun 10 '15 at 18:00
  • thanks all, will try! i thought unsigned int is 16bit, but now its clear that this is minimum 16bit and thats not equal:)) – David Németh-Nagy Jun 10 '15 at 18:09

0 Answers0