PICcoder.co.uk Forum  


::post new topic::
ReceiveLength = 0 some times...
Date: 2008/01/29 21:52 By: Svein Jarle Status: Visitor  
 
Hello.

I have read and tryd your codes. Work find exept that I have made some new code for fun but cant get it to work as I like.

const char PICPOST_STATUS[16] = {'0','1','2','3','4','5','6','7','8','9','1','2','3','4','5','6'};


case USB_SEND_POST_STATUS:
i=0;
while (i <=16)
{
dataPacket._byte[i+1]= PICPOST_STATUS[i];
++i;
}
counter=0x11;
break;

When I use this command in c#:

public String USB_SEND_POST_STATUS()
{
byte* send_buf = stackalloc byte[64];
byte* receive_buf = stackalloc byte[64];

string Temp = "";

DWORD RecvLength = (byte)17;
send_buf[0] = 0x50;
DWORD x = SendReceivePacket(send_buf, 1, receive_buf, &RecvLength);
if ((x >= 1) & ((char)receive_buf[0]== 'P'))
{
for (int i = 1; i <= x-1; i++)
{
Temp += ((char)receive_buf[i]).ToString();
}
}
return Temp;
}


The Problem is that I got only data every 2time I run this function.
When I look at the ReceiveLength and the ExpectedReceiveLength they look like this.

1 time:
ExpectedReceiveLength = 17
ReceiveLength = 17
Result: 0123456789123456

2time:
ExpectedReceiveLength = 17
ReceiveLength = 17
Result: 0123456789123456

3time:
ExpectedReceiveLength = 17
ReceiveLength = 0
Result:

4time:
Same as 2time

5time same as 3time

Why?? Why does I not get 17bit every time?? just in the start??
What have I done wrong??

Sorry for my bad english, hope you understand what my problem is.

Best regards Svein Jarle
reply | quote

Re:ReceiveLength = 0 some times...
Date: 2008/02/02 12:25 By: Svein Jarle Status: Visitor  
 
Hello,

I can’t get this to work. What do I do wrong??

Code:

  case LED:   mLED_4_Toggle();   dataPacket._byte[1]= '1';   dataPacket._byte[2]= '2';   dataPacket._byte[3]= '3';   counter=0x04; break;



Then I use the SendReceivePacket function and it returns this STRING
50495051. The next time I use SendReceivePacket I got the STRING 0000.

ExpectedReceiveLength = 4
ReceiveLength = 0

Why?? The LED4 is flashing every time, but I can’t get data from the CHIP more then every second time I hit my button in the form1.
Please help me?? What am I doing wrong???
reply | quote

::post new topic::