08-21-2011 04:41 AM - edited 08-21-2011 04:42 AM
Hello, everyone
I want to use the UDP protocol to send a message from computer #1 to computer #2 with this format
First byte: Message ID
Second byte: number of message bytes n
Third byte: the message
How I can send that message by that format , could anyone help me?.
I try to do that by this way, is that way is a right way?....
In the message to be send (string indicator box) dose 1 represent message ID (M Id), - sign represent # of bytes and is the first byte of message is the index 0 of array , second byte is index 1 , third byte is index 2 ,......etc
Best regard
Zhrani
Solved! Go to Solution.
08-22-2011 11:17 AM
Hello Al-Zahrani,
Are you having issues trying to do it this way (errors, incorrect message, etc.)? I am also attaching a link to our UDP Communication in LabVIEW. Hope this helps a little bit!
Mychal F
08-23-2011 06:39 AM
Hello Mychal,
thank you for your reply , yeah I have issue to send the message by that format.
actually I have two computers and one microcontroller (PIC) which connected together via ethernet switch.
in attachment you can find my VI's ,I tested these VI's in my two computers (until now without PIC circuit) ,
it was O.K
but until now I don't know if my technic is a right way to send a message by that format
(Message ID, # of bytes send and 2 or 3 or 4 Bytes the payload)
and at computer 2
any suggestion or answer is helpful for me...
Thanks
alzhrani
08-23-2011 05:29 PM
Al-Zahrani,
Can you please clarify the issue you are having? Are you receiving errors, warnings, time-outs, etc.? Thanks!
Mychal F
08-23-2011 06:45 PM
Mychal F
In the microcontroller board (which contain PIC microcontroller from microchip ) I can only use UDP protocol ,
the program in PIC microcontroller receive a message in bytes format, because of that I should send the message as that format.
in computer to computer there is no problems of communication (try to test my VI's in previous reply in two computers)
Thank you again 
Alzhrani
08-24-2011 11:29 AM
Alzhrani,
What microcontroller are you using?
Mychal F
08-27-2011 02:22 PM
Hello Mychal
Thankyou for reply
I used PIC16F877 with ENC624J600
to communicate with computer
Best regard
Alzhrani
08-29-2011 07:00 PM
Hi Al-Zahrani,
It is too bad you don't have the device, it would make the testing easier. However, I think we still are a little unclear on your question. It sounds like you are trying to form instructions for your micro controller, such as the ones found in the Instruction set manual for your device, in which caseI think that what you might be interested in is logical shifts.
To put it another way, are you trying to send all three bytes at the same time, as part of the same command?
If not, what exactly are you trying to do and where did you get the criteria for three bytes?
08-30-2011 03:07 PM
Hello Jess_D
Thankyou for reply
To put it another way, are you trying to send all three bytes at the same time, as part of the same command?
yeah , I wat to send all three bytes in one command
let's forget the microcontroller , if I want to send that three command to the second computer How I can do that ????
 
Thank you
Alzhrani
08-31-2011 11:10 AM - edited 08-31-2011 11:20 AM
Cool, that is what I thought your were trying to do.
You need to use logical shifts form the command. You will shift the first byte over 8 bits, the second byte over 4 bits and the payload over none. Then you can add them all into a single number and send this number over a single udp command. This give you a total message length of 3x4 = 12 bits.
To illustrate, lets pretend that we have the following scenario:
Message ID: 255 (1111 in binary)
Number of bytes: 0000 (0000 in binary)
Message: 255 (1111 in binary)
The below program shifts arranges them into one 12 bit message using shifts:
You can then send this number over udp. Is this what you were trying to do?
Could you tell me more about where you got this requirement? Was it from the manuals for the micro controller or a different source? I still don't understand why you need to send these commands in this fashion, which will help me answer your question much more effectively.