Serial Port Accessing / File handling in Local Network

Discussion in 'C++' started by pandi, Dec 17, 2009.

  1. pandi

    pandi Guest

    Hi

    I am developing a mini application which just get the input from
    serial port and after this copies some file to my LAN machine(share
    folder)...I am using Visual C++....


    Friends can you give the way to access serial port? and then network
    file accessing like open a file and write/read, close?

    One more thing i want to know is regarding system command using...

    I can able to use system command like
    system("CMD arg1..argn") => This works fine

    However what i need is arg1 is stored to a variable var1 and then
    others in var2,,,var3
    Now how to i use this variable in system command..

    Thanks
    pandi, Dec 17, 2009
    #1
    1. Advertising

  2. On 17 déc, 13:47, pandi <> wrote:
    > I am developing a mini application which just get the input from
    > serial port and after this copies some file to my LAN machine(share
    > folder)...I am using Visual C++....
    >
    > Friends can you give the way to access serial port? and then network
    > file accessing like open a file and write/read, close?


    I could but it would be rude because your are OT here.
    Please ask your question on
    comp.os.ms-windows.programmer.win32

    Another solution it to look for a solution on Google or MSDN.

    > One more thing i want to know is regarding system command using...
    >
    > I can able to use system command like
    > system("CMD arg1..argn") => This works fine
    >
    > However what i need is arg1 is stored to a variable var1 and then
    > others in var2,,,var3
    > Now how to i use this variable in system command..


    You build you system command

    string cmd = "CMD ";
    string var1,var2,var3;
    cmd += var1 + ' ' + var2 + ' ' + var3;

    And then execute it:
    ::system( cmd.c_str() );

    --
    Michael
    Michael Doubez, Dec 17, 2009
    #2
    1. Advertising

  3. pandi

    pandi Guest

    Hi

    Many Thanks for Your help..

    Now am able to use system command as per your suggestion.

    One general doubts is FILE handling, Actually i want to open a file in
    desktop and give path like "C:\Documents and Settings\Administrator
    \Desktop\test.txt" but it did not open..since we have space character
    in this path. How to open of this type file.

    Thanks again...

    On Dec 17, 4:55 am, Michael Doubez <> wrote:
    > On 17 déc, 13:47, pandi <> wrote:
    >
    > > I am developing a mini application which just get the input from
    > > serial port and after this copies some file to my LAN machine(share
    > > folder)...I am using Visual C++....

    >
    > > Friends can you give the way to access serial port? and then network
    > > file accessing like open a file and write/read, close?

    >
    > I could but it would be rude because your are OT here.
    > Please ask your question on
    > comp.os.ms-windows.programmer.win32
    >
    > Another solution it to look for a solution on Google or MSDN.
    >
    > > One more thing i want to know is regarding system command using...

    >
    > > I can able to use system command like
    > > system("CMD arg1..argn") => This works fine

    >
    > > However what i need is arg1 is stored to a variable var1 and then
    > > others in var2,,,var3
    > > Now how to i use this variable in system command..

    >
    > You build you system command
    >
    > string cmd = "CMD ";
    > string var1,var2,var3;
    > cmd += var1 + ' ' + var2 + ' ' + var3;
    >
    > And then execute it:
    > ::system( cmd.c_str() );
    >
    > --
    > Michael
    pandi, Dec 17, 2009
    #3
  4. On 17 déc, 15:40, pandi <> wrote:
    [snip]
    > Now am able to use system command as per your suggestion.
    >
    > One general doubts is FILE handling, Actually i want to open a file in
    > desktop and give path like "C:\Documents and Settings\Administrator
    > \Desktop\test.txt" but it did not open..since we have space character
    > in this path. How to open of this type file.


    You could add "" around the path parameters (that's how it is done in
    scripts), or I guess there must be some possible encoding with
    backslashes. This is a question best asked on comp.os.ms-
    windows.programmer.win32.

    [snip: don't top post]

    --
    Michael
    Michael Doubez, Dec 17, 2009
    #4
  5. pandi

    pandi Guest

    Ok Thanks Michael...

    On Dec 17, 8:52 pm, Michael Doubez <> wrote:
    > On 17 déc, 15:40, pandi <> wrote:
    > [snip]
    >
    > > Now am able to use system command as per your suggestion.

    >
    > > One general doubts is FILE handling, Actually i want to open a file in
    > > desktop and give path like "C:\Documents and Settings\Administrator
    > > \Desktop\test.txt" but it did not open..since we have space character
    > > in this path. How to open of this type file.

    >
    > You could add "" around the path parameters (that's how it is done in
    > scripts), or I guess there must be some possible encoding with
    > backslashes. This is a question best asked on comp.os.ms-
    > windows.programmer.win32.
    >
    > [snip: don't top post]
    >
    > --
    > Michael
    pandi, Dec 17, 2009
    #5
  6. pandi

    James Kanze Guest

    On Dec 17, 2:40 pm, pandi <> wrote:

    [...]
    > One general doubts is FILE handling, Actually i want to open a file in
    > desktop and give path like "C:\Documents and Settings\Administrator
    > \Desktop\test.txt" but it did not open..since we have space character
    > in this path. How to open of this type file.


    Technically, the limitations on filenames are defined by the
    implementation, but practically, all of the implementations I know
    will
    accept anything the OS will, including white space in the case of
    Windows or Unix. What might be causing you problems is the fact that
    '\' is an escape character in string literals. Just replace it with
    '/'
    (which works fine in both Windows and Unix), and there will be no
    problems.

    Outside of literals, of course: when displaying filenames, you want to
    display what the user expects, which is '\' under Windows; and when
    parsing them, you want to behave exactly as the system does, which
    means
    recognizing both '\' and '/' as directory separators under Windows.

    --
    James Kanze
    James Kanze, Dec 17, 2009
    #6
  7. pandi

    James Kanze Guest

    On Dec 17, 9:11 pm, Paavo Helde <> wrote:
    > Paavo Helde <> wrote
    > innews:Xns9CE4E8BB05AApaavo256@216.196.109.131:


    > > Off-topic: '/' does not work with system() on Windows (used by OP),
    > > which calls cmd.exe shell, which does not support forward slashes in
    > > pathnames.


    > > The '/' character is accepted only by lower level function
    > > interfaces, like fopen() etc.


    > A correction: also cmd.exe and other utilities can accept forward
    > slashes in pathnames if one manages to convince them that this is a
    > single filename argument which has to be directly passed to a system
    > function. For that one can try enclosing the filename in double
    > quotes. Different commands/programs accept different things, though.


    I was going to say that I use it rather regularly in cmd.exe, with no
    problems. (Filename expansion doesn't take it into account, but
    everything else does.) It's true that the Windows documentation says
    to
    use a '\', with a note that the file I/O functions in the Windows API
    convert '/' to '\' (except when they don't). In practice, the real
    problem with '/' is that it is conventionally used to signal an option
    (like '-' under Unix); you should definitely avoid filenames that
    start
    with a '/' (but "c:/..." doesn't generally seem to cause problems).

    Of course, you can always write it: "file://c:/...":). (In URL's,
    '/'
    is the only allowed path separator.)

    In practice, I'll stand by my original statement: a well written
    program
    should accept both '/' and '\' in input (and will pass the '/' on to
    the
    system, if that's all it's doing with the filename), and use '\' in
    output (because it is the "standard"). The one exception is in argv:
    if
    argv starts with a '/', it's an option, not a filename (and for
    various historical reasons, a well written program will accept either
    '/' or '-' as an option---most of Microsoft's code does).
    (Internally,
    you might prefer maintaining the name in an std::vector< std::string
    >,

    and ignoring the issue:).)

    --
    James Kanze
    James Kanze, Dec 18, 2009
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?WVNVVA==?=

    Access local port or Running local exe file

    =?Utf-8?B?WVNVVA==?=, Jan 14, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    515
    =?Utf-8?B?WVNVVA==?=
    Jan 14, 2006
  2. George T.

    Accessing Windows Serial Port

    George T., Feb 6, 2006, in forum: Python
    Replies:
    5
    Views:
    965
    Grant Edwards
    Feb 7, 2006
  3. Pom
    Replies:
    2
    Views:
    1,658
    Bas-i
    Jan 31, 2007
  4. Replies:
    2
    Views:
    2,528
    Praetorian
    Dec 25, 2007
  5. msalerno
    Replies:
    3
    Views:
    410
    Ilmari Karonen
    Jul 14, 2005
Loading...

Share This Page