PICcoder.co.uk Forum  


Post a new message in "Article Discussion"
Name:
Subject:
This image contains a scrambled text, it is using a combination of colors, font size, background, angle in order to disallow computer to automate reading. You will have to reproduce it to post on my homepage Enter what you see: *
tips: hit Reload page before writing a text if you have difficulty reading characters in image
topic icon:
no
boardcode:
 Colour:  Size:   Close all tags
Message:

emoticons
B) ;) :) :P
:laugh: :ohmy: :sick: :angry:
:blink: :( :unsure: :kiss:
:woohoo: :lol: :silly: :pinch:
:side: :whistle: :evil: :S
:blush: :cheer: :huh: :dry:

Topic History of: ReceiveLength = 0 some times...
Max. showing the last posts - (Last post first)
Author Message
Svein Jarle 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???
Svein Jarle 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