Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I was just wondering what you do in C# when you do not have any pointers. How would you for example do this in C# ?

 

byte *pData, byte length

byte ix = 0

static byte buffer[100];

 

for (int i=0;i<length;i++)

buffer[ix++] = pData;

  • Administrators
Posted

You could just use arrays.

 

private void CopyArray(byte[] pData)
{
byte ix = 0;
byte[] buffer = new byte[100];

for (int i=0;ibuffer[ix++] = pData[i];
}

 

any reason why you need pointers? If so you can mark the code as being unsafe and pointers can be used.

Posting Guidelines FAQ Post Formatting

 

Intellectuals solve problems; geniuses prevent them.

-- Albert Einstein

Posted

In short term when clicked on the button buttonClick is activated. You send a broadcast to all the nodes by passing the parameters to the function SendData, afterwards it return. And call ActivateAlllNodeswhere it call itself until max number of nodes has been received. I do not know it is easier to look through having all the project.

 

private void buttonClick(object sender, System.EventArgs e)

{

 

if (api.SendData(BROADCAST,command,2, ActivateAlllNodes)))

{

m_txtStatus.Text.Insert(1,"OKAY");

}

else

{

m_txtStatus.Text.Insert(1,"FAILING");

}

}

 

public virtual void ActivateAlllNodes(byte[] command)

{

byte nodeID = 0;

while (nodeID++ < MAX_NODES)

{

if (nodeIDisaccepted)

break;

}

if (nodeID > MAX_NODES)

{

m_txtStatus.Text.Insert(1,"FINISH");

}

else

{

api.SendData(nodeID, command, 2,ActivateAlllNodes);

}

}

 

public delegate void CompletedFunc(byte b);

 

public byte SendData(byte nodeID, byte[] pdata, byte dataLength, CompletedFunc cmplfunc)

{

byte byCompletedFunc = ( cmplfunc == NULL? 0: 0x03); and some other stuff here...

}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...