Results 1 to 4 of 4

Thread: Defining data format in c++

  1. #1
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Defining data format in c++

    I would like to transmit a stream of bits formatted to my liking, between two PCs, i already have a serial conection betwen them which will allow me to transmit data; an array with a string ("hello world") for example.

    My problem is i don't have any idea as to how to go about defining the format, so that both PCs can parse it and pick out relevant information.

    I think need to know how to create and send a binary frame, example:

    start_bit + character + stop_bit; where the character will inclued the parity bit

    I also need to know how to implement data identification, as i am sendng different types of information:

    example; at one point i may need to send, say, user_information;
    which may include user_name, user_password etc.

    and at another time i may want to send somthing else, like, say,
    system_info; which may include system_status, number_of_users, ect.

    basically, the recieving PC must be able to tell:

    1) what data is being sent: user or system info

    2) if its user info, where does user_name stop, and user_password begin, and where does the whole user_info stop.

    Does anyone know how i can implement this?

    I am using MS visual studio .NET 2003 and programmng in C++. Along wit the qt VS .NET 2003 integration.

    If you can give some suggstions or direct me to some resource that covers this kind of thing, i would be most greatful.

    Thanks very much for your attention

    You are invited to be as generous as possible with your sugestions.
    All suggestions welcomed.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Defining data format in c++

    I'd suggest to use some platform independent solution, like ASN.1 - all the parsing and stuff would be made automatically then.

  3. #3
    Join Date
    Jan 2007
    Posts
    38
    Thanks
    12
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Defining data format in c++

    Thanks wysota for that info on the ASN1 encoding form.
    I tried it and it works well, and i am using it in my project.

    I have read that:

    ASN expresses only syntax (data types), not semantics
    could you tell me in what context the word
    semantics
    is being used here?

    See i aside from data i need to transfer a small .WAV
    file, and from the quote above i am guessing that ASN cannot encode the file for me.

    I am trying to find some easy to use encoding form that will enable me to send the file.

    I am not confining myself to using an encoding, any suggestions for sending the file is welcomed. I am sending my data via COM port between the two computers.

    Thanks for your help so far, i really appreciate it.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Defining data format in c++

    Quote Originally Posted by locus View Post
    could you tell me in what context the word is being used here?
    "Grammar". It means the encoding carries no meaning with the data. It is only a container for data.

    file, and from the quote above i am guessing that ASN cannot encode the file for me.
    You're wrong then. It'll do just fine with binary data. It just means it won't treat it specially because it's a WAV file or it won't be able to convert it to MP3, etc. It'll just be a blob of data.

    I am not confining myself to using an encoding, any suggestions for sending the file is welcomed. I am sending my data via COM port between the two computers.
    You always use some form of encoding. It's just your decision which one to choose. If you just need to send a WAV file over a cable, you don't need to use ASN.1. But if you want to send some other things like numbers, characters, etc. in a platform independent way then ASN.1 might prove helpful.

Similar Threads

  1. QSqlQueryModel data update
    By psi in forum Qt Programming
    Replies: 4
    Last Post: 20th July 2012, 04:59
  2. how to use loadFromData in painter
    By sar_van81 in forum Qt Programming
    Replies: 18
    Last Post: 31st January 2007, 05:09
  3. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 13:53
  4. How to convert binary data to hexadecimal data
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 8th March 2006, 17:17
  5. Replies: 16
    Last Post: 7th March 2006, 16:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.