Jedhi Posted October 7, 2003 Posted October 7, 2003 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; Quote
Administrators PlausiblyDamp Posted October 7, 2003 Administrators Posted October 7, 2003 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. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jedhi Posted October 7, 2003 Author Posted October 7, 2003 I have some problems with callback function. Would you look through the code and correct the errors and send me back the source ? Quote
Administrators PlausiblyDamp Posted October 7, 2003 Administrators Posted October 7, 2003 what callback function? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Jedhi Posted October 7, 2003 Author Posted October 7, 2003 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... } Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.