Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Serial Port Accessing / File handling in Local Network

Reply
Thread Tools

Serial Port Accessing / File handling in Local Network

 
 
pandi
Guest
Posts: n/a
 
      12-17-2009
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

 
Reply With Quote
 
 
 
 
Michael Doubez
Guest
Posts: n/a
 
      12-17-2009
On 17 déc, 13:47, pandi <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
 
pandi
Guest
Posts: n/a
 
      12-17-2009
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 <(E-Mail Removed)> wrote:
> On 17 déc, 13:47, pandi <(E-Mail Removed)> 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


 
Reply With Quote
 
Michael Doubez
Guest
Posts: n/a
 
      12-17-2009
On 17 déc, 15:40, pandi <(E-Mail Removed)> 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

 
Reply With Quote
 
pandi
Guest
Posts: n/a
 
      12-17-2009
Ok Thanks Michael...

On Dec 17, 8:52*pm, Michael Doubez <(E-Mail Removed)> wrote:
> On 17 déc, 15:40, pandi <(E-Mail Removed)> 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


 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      12-17-2009
On Dec 17, 2:40 pm, pandi <(E-Mail Removed)> 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
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      12-18-2009
On Dec 17, 9:11 pm, Paavo Helde <(E-Mail Removed)> wrote:
> Paavo Helde <(E-Mail Removed)> 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[i] 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
emulate a serial port in windows (create a virtual 'com' port) Pom Python 2 01-31-2007 07:49 PM
Access local port or Running local exe file =?Utf-8?B?WVNVVA==?= ASP .Net 0 01-14-2006 12:41 AM
Can I connect router Serial interface directly to a PC serial port? Faustino Dina Cisco 2 08-18-2004 02:30 AM
Re: Serial port and PS/2 port schematics OR Assistive Tech. suggestion naive.verizon@locality.net Computer Support 1 07-10-2003 11:46 AM
Re: Serial port and PS/2 port schematics °Mike° Computer Support 1 07-09-2003 10:30 PM



Advertisments