|
.... U have created the instance of the serial port as "objR232Driver" and set all the necessary parameters.But you were trying to use some other object named "rs232SerialPort". Where you created the obj for the later serial port?
You can make use of the below lines of code:
System.IO.Ports.SerialPort rs232SerialPort = new System.IO.Ports.SerialPort("COM" + CStr(intPort),9600,ioParity.None,DataBits.8);
and Set the read time out to either 2 or 3 secs.
The code is:
rs232SerialPort.ReadTimeOut = 2000; (For 2 secs)
Then use ur read port function:
intToRead = rs232SerialPort.BytesToRead();
rs232SerialPort.Read(bData, 0, intToRead);
Instead of Read function you can also make use of readbyte function that shall be used later for finding out any Start_Communication_Byte or like that...
The snippet ll be:
System.IO.Ports.SerialPort rs232SerialPort = new System.IO.Ports.SerialPort("COM" + CStr(intPort),9600,ioParity.None,DataBits.8);
rs232SerialPort.ReadTimeOut = 2000; (For 2 secs)
intToRead = rs232SerialPort.BytesToRead();
byte[]bData= new byte[intToRead ];
for (int nIndex = 0; nIndex < intToRead ; nIndex ++)
{
bData[nIndex ] = (byte)(rs232SerialPort.ReadByte());
}
The above ll surely help you to get the data in the Serial port buffer.
Thanks & Rgds,
Sri..
|
|
|
|
|
Have you tried trapping exceptions from this snippet of code? That should help determine what the problem is.
Phil
|
|
|
|
|
Hello all,
I try to have user thread to perform update on the window form list
view item back color. However, I can see the new item was added each
time. However, the back color just not changed until I move the window
around. May I noe what code I had missing out?
Thank you very much!
delegate void OnGUIDelegate(int msgID, object param1, object
param2);
public void OnGUI(int msgID, object param1, object param2)
{
// Make sure we're on the right thread
if(listView1.InvokeRequired == false)
{
switch(msgID)
{
case GUIMessage.MSG_ERR:
if(param1 is string)
{
string strDate = DateTime.Now.ToLongTimeString();
string[] s = {strDate, (string)param1};
ListViewItem listViewItem = new ListViewItem(s);
listViewItem.StateImageIndex = 2;
listViewItem.BackColor = Color.FromArgb(255, 224, 192);
listView1.Items.Add(listViewItem);
isSave = false;
}
break;
case GUIMessage.MSG_INFO:
if(param1 is string)
{
string strDate = DateTime.Now.ToLongTimeString();
string[] s = {strDate, (string)param1};
ListViewItem listViewItem = new ListViewItem(s);
listViewItem.StateImageIndex = 0;
listViewItem.BackColor = Color.FromArgb(192, 255, 192);
listView1.Items.Add(listViewItem);
isSave = false;
}
break;
case GUIMessage.MSG_WARNING:
if(param1 is string)
{
string strDate = DateTime.Now.ToLongTimeString();
string[] s = {strDate, (string)param1};
ListViewItem listViewItem = new ListViewItem(s);
listViewItem.StateImageIndex = 1;
listViewItem.BackColor = Color.FromArgb(255, 255, 192);
listView1.Items.Add(listViewItem);
isSave = false;
}
break;
} // switch
}
else
{
// Update GUI asynchronously
OnGUIDelegate onGUI =
new OnGUIDelegate(OnGUI);
this.BeginInvoke(onGUI,
new object[] { msgID, param1, param2});
}
}
|
|
|
|
|
Hello everyone,
Can someone tell me how I can increase the Height of the rows in my ListView?
Thank you very much for your help.
Khoramdin
|
|
|
|
|
|
suppose a network path to a text is like this \\MY_REMOTE_PC(or the ip address)\sharedFolder\Myfile.Txt
how can i access this file from a hostPC using C#. what areas to dig-in to get an acquaintance. Any help would be greatly appreciated. I am pretty new to domain of C# but have started loving it.
please do reply.
With regards
Pankaj
|
|
|
|
|
wildpankaj wrote: how can i access this file from a hostPC using C#.
Like this:
using System;
using System.IO;
StreamReader sr = File.OpenText ("\\\\MY_REMOTE_PC\\sharedFolder\\Myfile.Txt");
while ((string input = re.ReadLine()) != null)
Console.WriteLine (input);
sr.Close();
/ravi
|
|
|
|
|
He Pankaj,
you can use the open file dialog as always. If you are able to access any computer from that machine, then this procedure will work
OpenFileDialog ofn = new OpenFileDialog();
ofn.Filter = "XML Files (*.xml)|*.xml";
ofn.Title = "Type File";
This opens a file dialog, where you get to choose the file of your choice. This file dialogue is for xml files. LikeWise you can set which files you want to choose. be careful of the extension though.
continue it with
if (ofn.ShowDialog() == DialogResult.Cancel)
goto Quit;
"Quit" defines a label, used in case, the user chooses cancel buttion of the open file dialog.
i hope this helps.
Keshav Kamat
India
|
|
|
|
|
Once You open the file, u can use the stream reader to read the contents of the file as Ravi has suggested.
Keshav Kamat
India.
|
|
|
|
|
I am attempting to execute a Surround SCM CLI Command using system.diagnostics.process. The cruisecontrol command to be exact. If I execute the command in command window it works perfectly. If I place and run the command from a batch file it works perfectly. When I execute it using the system.diagnostics.process it does not run, at least not completely. At the end of the command I use “> filename.txt” to dump the results to a text file. Again, it runs great in a command window and from a batch file but not in the C# app. Any ideas?????
<br />
<br />
System.Diagnostics.Process process = new System.Diagnostics.Process();<br />
process.StartInfo.FileName = @"c:\mypath\seapine\surround scm\sscm.exe";<br />
process.StartInfo.Arguments = " cc -d" + timecode + " -r -bMyBranch –pMy/Path -x- -z127.0.0.1:1234 -yUN:PW > FileName.txt";<br />
process.StartInfo.UseShellExecute = true;<br />
process.StartInfo.RedirectStandardOutput = true;<br />
process.StartInfo.RedirectStandardError = true;<br />
process.StartInfo.CreateNoWindow = true;<br />
process.Start();<br />
process.WaitForExit();<br />
<br />
|
|
|
|
|
The ">" doesn't work because you redirected the standard output stream away in your Process object.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
I reset the redirection properties to false, and I am still getting the same results.
|
|
|
|
|
Try setting CreateNoWindow to False, after that, play with the UseShellExecute.
It'll work, but you have to get these settings correct to get it work correctly.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
By setting the CreateNoWindow to false, and UseShellExecute to true it ran twice. I changed the arguments property value and it quit working. I changed it back and it still won't work again.
I finally created a method that would create a batch file dynamically and I execute that using the diagnostics process and it works everytime.
Strange....
Thanks!
|
|
|
|
|
JMichael2468 wrote: it runs great in a command window and from a batch file but not in the C# app.
What do you mean by "not"?
Perhaps the command is executing but you don't know where the file is being created? If so, have you tried specifying a fully qualified filename?
/ravi
|
|
|
|
|
I reset the redirection properties to false, and I also added the working directory folder, and I also used a fully qualified filename but I am still not getting the results in a text file. I ran a search in all folders on the hd and no results. I pieced together the values from the process properties and ran them in a command window, the command executes and the file is created no problems. It just won't run from C#. Atleast the results aren't being redirected to the file.
<br />
System.Diagnostics.Process process = new System.Diagnostics.Process();<br />
process.StartInfo.WorkingDirectory = "c:\\program files\\seapine\\surround scm";<br />
process.StartInfo.FileName = "SSCM.EXE;<br />
process.StartInfo.Arguments = "cc -d" + timecode + " -r -bMyBranch -pMy/Path -x- -zmyIPAndPort -yUser:Password > MyResults.txt";<br />
process.StartInfo.UseShellExecute = true;<br />
process.StartInfo.RedirectStandardOutput = false;<br />
process.StartInfo.RedirectStandardError = false;<br />
process.StartInfo.CreateNoWindow = false;<br />
process.Start();<br />
process.WaitForExit();<br />
|
|
|
|
|
Hi all,
I have created a form with a datagridview.
I created a new Class called duplicate Picture that has 4 fields.
2 type String both hold filepaths.
2 type Bitmap that "should" hold the picture at the path set above.
My constructor sets the Bitmap to be the paths as specified.
I look through a file structure and find duplicate images, add them to a List of the class described above, then using CurrencyManager show a list of the path on the DataGridview as well as the image.
I kept getting the little White Square with a red cross in it for the Bitmaps.
So I changed the Properties for the Bitmaps to return a Image class instead, and converted the Bitmap to a Thumbnail, but that just caused more problems.
Am I missing something fundamental here?
Original Class I created -
<br />
sing System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
using System.Drawing;<br />
<br />
namespace DuplicateFile<br />
{<br />
class DuplicateFile<br />
{<br />
private string _shortName;<br />
private string _originalFilePath;<br />
private String _duplicateFilePath;<br />
private Bitmap _originalPicture;<br />
private Bitmap _duplicatePicture;<br />
<br />
public DuplicateFile(string newShortName, string newOriginalFilePath, string newDuplicateFilePath)<br />
{<br />
shortName = newShortName;<br />
originalFilePath = newOriginalFilePath;<br />
duplicateFilePath = newDuplicateFilePath;<br />
}<br />
<br />
<br />
<br />
public string shortName<br />
{<br />
get<br />
{<br />
return this._shortName;<br />
}<br />
set<br />
{<br />
this._shortName = value;<br />
<br />
}<br />
}<br />
<br />
public string originalFilePath<br />
{<br />
get<br />
{<br />
return this._originalFilePath;<br />
<br />
}<br />
set<br />
{<br />
this._originalFilePath = value;<br />
Bitmap originalPicture = new Bitmap(originalFilePath);<br />
}<br />
}<br />
<br />
public string duplicateFilePath<br />
{<br />
get<br />
{<br />
return this._duplicateFilePath;<br />
}<br />
set<br />
{<br />
this._duplicateFilePath = value;<br />
Bitmap duplicatePicture = new Bitmap(duplicateFilePath);<br />
}<br />
}<br />
<br />
public Bitmap duplicatePicture<br />
{<br />
get<br />
{<br />
return _duplicatePicture;<br />
}<br />
<br />
}<br />
<br />
public Bitmap originalPicture<br />
{<br />
get<br />
{<br />
return _originalPicture;<br />
}<br />
<br />
}<br />
}<br />
}<br />
<br />
|
|
|
|
|
Hello,
my app connect to a sql server 2000 db and a I store my data in a decimal data type like this(12.32) ,but when I retrive it in my app it appears (12.32000000)I'd like to solve the problem of the zero with out effecting
the value.
Dad
|
|
|
|
|
The value is not directly linked to how it appears. The appearence is only the string representation of the value. You can specify how you want the value displayed when you convert it to a string.
---
single minded; short sighted; long gone;
|
|
|
|
|
How can I draw a finest dot or color a particular pixel on the screen.............. Actually I want to do makeup on a picture and for doing soo I want to draw finest dots...... Can anybuddy help??????????
|
|
|
|
|
Bitmaps have a method called SetPixel but it is incredibly slow. Any real image manipulation will require unsafe code to be fast and even then it is slow.
File Not Found
|
|
|
|
|
I have used that set pixel but its sooo slow..... Can u give any example of the unlock bitmap so that I can draw on the particular pixel.... I must do the mapping frm the form to the bitmap that is again a problem...........
|
|
|
|
|
Look at my article on unsafe Grayscale conversion. If you modify my code you should be able to write a simple pixel offset arithmetic to edit only one pixel very quickly.
File Not Found
|
|
|
|
|
My image processing project nearing completion is built using VS2003, and intentionally uses a huge amount of memory (100's of data arrays loaded) which does not get fully released until I restart my app process: I can live that for now. I've read the various articles here on memory management, and the main issue appears to be the way the Large Object Pool is (mis)managed by NET 1.1. NET 2.0 apparantly fixes some of this, and XP64 or Vista fixes the rest(?).
So, several questions I can't locate simple answers to.
Can I update VS2003 to build with build with NET 2.0, or do I have to upgrade to VS2005 or later to get NET 2.0? What about NET 3.0? I'd REALLY not like to have to do this at this point.
As I run the app, I can watch the memory usage increase, but what I find odd is the Page File usage also increases. This is on a Core 2 Extreme (quad core) with 4GB of ram. Is this just an effect of the NET 1.1 memory management or what?
I also note that XPsp2 renders the top 750MB of my 4GB ram unusable to (according to MS) allow for "memory mapped I/O devices that MIGHT be installed". Well, I don't have any cards that need this, so is there any way that some of this 750MB of ram can be identified to XP as actually usable?
Thanks for any suggestions...
Stewart DIBBS
|
|
|
|
|
The 750 megs of unused space is for Memory Mapped IO and makes up a nice week in your Architecture class from the Computer Science degree. It is inherent in all memory mapped systems. (The limit may be different based on the processor and/or bus)
If your code will compile in 2005 (and it should) you can download the express edition or just the sdk and build it using the csc command line utility.
Page File usage is related to virtual memory usage. Memory mismanagement as well as significant use can cause the pf usage to go up.
File Not Found
|
|
|
|