The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
What does this code mean... azazalis Shell Programming and Scripting 2 08-13-2006 05:02 AM
SSH key code versus server key code Texan Security 1 04-12-2006 11:57 AM
32-bit code with gcc amol.chavan High Level Programming 1 06-22-2004 10:58 AM
Return code from PL/SQL Code Shaz UNIX for Advanced & Expert Users 7 06-03-2003 10:56 AM
code help bb00y High Level Programming 3 10-12-2002 08:45 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-10-2007
amitpansuria amitpansuria is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 91
how i prepare a c++ code(c code) for implementing my own protocol format

helo my protocol format is given below

{ destno,mode,no.of packet,pktsize,,pktno,textsize,CRC}
description:- { is starting flag
destno - 4bytes
mode - 1 byte
no.of pkt - 4byes
pktsize - 6 bytes
pktno 3 bytes
text size 6 bytes
CRC is 2 bytes
i want to write c++ code(or c code) to prepare this packet and after this
i want to transfer this packet over serial port.
after that how i write a code to receive this packet from serial port and how i extract this packet after receiving the packet.
Regards,
Amit
  #2 (permalink)  
Old 09-06-2007
porter porter is offline Forum Advisor  
Registered User
  
 

Join Date: Jan 2007
Posts: 2,965
You need six bytes for a packet size? Wow.

Do you have code to generate and check CRCs?

sending side

Code:
len=call_generate_crc(buf,len);
write(fd,buf,len);
at receiving side

Code:
while (1)
{
    if (read(fd,buf,1) !=1) exit(1);
    if (buf[0]==start_of_packet) break;
}
..... /*read rest of packet */

check_crc(buf,len);
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:19 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0