How Do You Construct a Basic Data Packet for Communication?

  • Thread starter Thread starter rama1001
  • Start date Start date
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
7 replies · 4K views
rama1001
Messages
130
Reaction score
1
Hi,
I am very new to communication and now i want transmit a packet to read data. The attached file containg the packet structure. and relavant data need to make a packet.
can anyone help by giving some example packet by given data.

Please it's urgent for me, hope for helping forum.
 

Attachments

Physics news on Phys.org
Hey there.

The simple answer is create structs for you're header (and footer) and use an array for the rest.

Use some kind of array class (or a managed buffer) and pack all your data into that array.

Then use a sockets library to send the data.

That's the basics but you need to have a system in place to handle networked traffic.

To start off use the TCP protocol. Don't use UDP just yet.

If you're just doing a demo program you could poll until you get the appropriate response (ie loop until you get response).

If you want to develop it into reusable code you will need to create a library that contains encapsulated code for servers, clients, and protocols.

Since I don't know the scope of what you want to accomplish maybe you can give me some hints on the matter.
 
i am just making a project and its imporant to get data from slave. Inorder to do that commands will transfer from host(PC) to slave, then it responds for different commands with answer. Basic, i need send packet like what i have gave you. cam you make any example packet from that. Please help me.
 
rama1001 said:
i am just making a project and its imporant to get data from slave. Inorder to do that commands will transfer from host(PC) to slave, then it responds for different commands with answer. Basic, i need send packet like what i have gave you. cam you make any example packet from that. Please help me.

Is this over a network like say a LAN/WAN or internet or is it over say some local bus that inside the boundary of the machine?
 
chiro said:
Is this over a network like say a LAN/WAN or internet or is it over say some local bus that inside the boundary of the machine?[/QUO

First of all, forgive me if i made any mistake. Perhaps. i am looking for basic packet construction from the given parameters. what should you need to know else. I need to send the packet from labview.
 
Use a function to figure out how much space you need, allocate the space, write the data to the allocated memory and then after you setup the socket connection use the send function to send it to the destination.

I can't help you if you do not get more specific about what you dealing with (machine, environment/platform, programming language, communication bus etc).

If you can't provide me with things to go on, I'm afraid I can't be as helpful as I could if you more specific about what problem you are having.
 
chiro said:
Use a function to figure out how much space you need, allocate the space, write the data to the allocated memory and then after you setup the socket connection use the send function to send it to the destination.

I can't help you if you do not get more specific about what you dealing with (machine, environment/platform, programming language, communication bus etc).

If you can't provide me with things to go on, I'm afraid I can't be as helpful as I could if you more specific about what problem you are having.

I need to communicate with powersupply digitally from PC. SO, commands willl takes mail lead get answer. I am using PMBus protocol on slave side to get values from Power supply everytime. you can also fine more commands in the link(http://pmbus.org/docs/PMBus_Specification_Part_II_Rev_1-1_20070205.pdf) and you can find more command in pdf last pages. Detailed information also available for packet structure. Just i am looking for example packet structure. just give me what you think about packet structure. I am new to this packet making and sending stuff.
 
Ok I will give you an example packet with the following values:

Address byte - 255 (0xFF)
Command byte - 136 (0x88)

Lets say you have one data byte 27 (0x1C)
Lets say no optional PEC data

According to your document you need to wait for acknowledgment signals so you will do the following:

1) Send 0xFF (in binary 11111111) (wait for acknowledgment)
2) Send 0x88 (in binary 10001000) (wait for acknowledgment)
3) Send 0x1C (in binary 00011100) (wait for stop signal)