|
<br />
using System;<br />
using System.Collections.Generic;<br />
using System.Linq;<br />
using System.Text;<br />
using System.IO.Ports;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args)<br />
{<br />
for (int i = 0; i < args.Length; i++)<br />
{<br />
System.Console.Write("Arg[{0}] = [{1}] ", i, args[i]);<br />
};<br />
Console.WriteLine();<br />
Console.WriteLine();<br />
Console.WriteLine("Written by Joseph Goldburg Phone 0412 750 765 joe.g@optusnet.com.au");<br />
Console.WriteLine();<br />
<br />
if (args.Length < 3) <br />
{<br />
Console.WriteLine("*** Error in command line arguments ***\n");<br />
Console.WriteLine("3 arguments required COMx inputfile logfile [Pause]\n\n");<br />
<br />
Console.WriteLine("Press any key to continue...");<br />
Console.ReadKey(true);<br />
<br />
System.Environment.Exit(1); <br />
}<br />
<br />
<br />
<br />
string comport = args[0].ToUpper();<br />
string inputfile = args[1].Replace("\\", "\\\\");<br />
string logfile = args[2].Replace("\\", "\\\\");<br />
<br />
<br />
<br />
System.IO.StreamReader sr = new System.IO.StreamReader(inputfile);<br />
System.IO.TextWriter tw = new System.IO.StreamWriter(logfile);<br />
string line;<br />
tw.WriteLine("Job Started {0} ", DateTime.Now);<br />
Console.WriteLine("Job Started {0} ", DateTime.Now);<br />
<br />
<br />
SerialPort port = new SerialPort(comport, 115200, Parity.None, 8, StopBits.One);<br />
try<br />
{
<br />
port.Open();<br />
tw.WriteLine("Compport {0} open ",comport);<br />
Console.WriteLine("Compport {0} open ", comport);<br />
<br />
string ATstring = "AT";<br />
string ATZstring = "ATZ";<br />
<br />
int starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
port.WriteLine(ATZstring); tw.WriteLine(ATstring); Console.WriteLine(ATstring);
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
<br />
<br />
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
port.WriteLine(ATZstring); tw.WriteLine(ATZstring); Console.WriteLine(ATZstring);
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
<br />
while ((line = sr.ReadLine()) != null)
{<br />
if (line.IndexOf("^Z") > -1 || line.IndexOf("^z") > -1)
{<br />
line = line.Replace("^Z", "\x001A");
line = line.Replace("^z", "\x001A");
port.Write(line);
tw.WriteLine(line);<br />
Console.WriteLine("Control z reached : SMS is : --> {0}",line);<br />
<br />
<br />
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
}<br />
else<br />
{<br />
port.WriteLine(line);
tw.WriteLine(line);
Console.WriteLine(line);
<br />
starttime = DateTime.Now.Second;<br />
while (starttime == DateTime.Now.Second) { }<br />
}<br />
<br />
}<br />
port.Close();<br />
}<br />
catch<br />
{<br />
Console.WriteLine("Could not open serial comport {0}", args[0]);<br />
}<br />
<br />
if (args.Length > 3)<br />
{<br />
Console.WriteLine("Press any key to continue...");<br />
Console.ReadKey(true);<br />
}<br />
<br />
<br />
tw.Close();
sr.Close();
}<br />
}<br />
}<br />
|
|
|
|
|
Hi...
This seems to be a little old post..
anyway thanks for your code.. i will try it out sometimes....
Have a Happy Coding.....
|
|
|
|
|
I have implemented class using IComaprer where in compareto method has been used.
I have 2 objects and say i have date field in both set as march 20 2009 in both objects.
Let there be name field in both in first case it is Amit and second it is Ajay
Now i sort these 2 on date. first time i get Amit as first record and Ajay as second record. I say refresh and call sort again than i get Ajay first and Amit second. Cant i get same sequence everytime as date value on which sort is being done is same in both objects
|
|
|
|
|
Before returning from the CompareTo, check if the result is 0. If it is, do a secondary compare on the name field and return that result.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Hey guys, I'd posted this question as a message in a thread that's been nudged down to page two, so not sure if anybody would read it. So I'll just re-ask here.
I have a sub-dialog in which I have a datagridview that i can search through, select a row, and click load. When clicking load, the data from that selected row is saved as a public static string in a class, so i can use it in my main dialog. The problem I am having is that I can't figure out how to automatically populate the fields of the main dialog on the click of the load button in the sub-dialog.
Any help greatly appreciated.
Martin
|
|
|
|
|
try searching for the information google is your friend[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Martin!!!!
This is very rude, behaviour.
You have to remember Time differences, also people here are busy doing their own work, they are not just sitting here waiting for you to post a question.
If you want instant answers you have to Pay.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
|
you just want date and time of system?
look at the DateTime class... more specifically the static Now property
example...
TextBox1.Text = DateTime.Now.ToString("dd/MM/yyyy HH:mm:ss");
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
System.DateTime.Now.Tostring();
|
|
|
|
|
are you sure that will work?
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Although you've been given the answer, you really should know this sort of basic stuff, and you should invest in a C# book and work through it before attempting anything more complex than basic exercises and self teaching.
Christian Graus
Driven to the arms of OSX by Vista.
"I am new to programming world. I have been learning c# for about past four weeks. I am quite acquainted with the fundamentals of c#. Now I have to work on a project which converts given flat files to XML using the XML serialization method" - SK64 ( but the forums have stuff like this posted every day )
|
|
|
|
|
|
Hi all,
it may be a simple one but i dont know how to do it
In my C#.net 3.5 windows application, i have to create a separate file(like Code File)
here i will give some text and this text i want to read from coding.
is it possible?
please give some idea or please share some sample code if u have.
Thanks In Advance
--Naren
|
|
|
|
|
i want to add a textfile(.txt) to setup of my project
|
|
|
|
|
You have to create the file in the Program Data folder. Vista won't allow you to create it in the Program Files folder.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
how can i get path of my application folder?
|
|
|
|
|
Application.StartupPath;
this is a string representing the full path where the application executable was started
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
That's not available in WPF.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: That's not available in WPF.
I didnt see anything about WPF....
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
If he wants to move the app to WPF, he will have issues if he uses that particular method. It's all about maintainability.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Does this still work in WPF:
System.Reflection.Assembly.GetExecutingAssembly.Location
(not the best way to do it but a way )
|
|
|
|
|
That's not always reliable. Try this[^] way instead.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
it is just a c#.net windows application
|
|
|
|
|
Repeat after me - "future-proofing" and "maintainability". You could just use interop and cal GetModuleFileName, because that's what .Net is doing anyway...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|