|
I want to develop and aplication to te information from 1 weigthing machine that is connected to my serial port. but the problem there is no DLL or any library that i can use from the machine vendor.
thay only let me know tha address where i can get the data from and after i get the i have to delete the data from the machine..
how do i make my a serial port listener that whenever the machin have activity i have to get notified by the machine.
thanks..
Jalil
|
|
|
|
|
Without knowing any details about the scale and how it communicates, you're going to be doing LOTS of trial-and-error testing to figure out how the thing works and what you're going to have to do to get the information you need. There's no standard to follow here.
It could be as simple and opening the Serial port the scale is attached to (with the correct communication parameters of course!) and waiting for the scale to send you a weight. Beyond that, try it and see what happens.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You can use the System.IO.Ports namespace in your project. The SerialPort class is very simple to use. I guess your weighting machine has a special way to send data on the port. If you don't know, I suggest that you use an RS-232 analyzer to see what's being sent by the weighting machine.
fred.
There is no spoon.
|
|
|
|
|
Hello gurus,
I can successfully use the serial communication in .NET 2 but I'd like to know if it is possible to communicate with a USB driver in C#?
I could do this in C++ with the CreateFile function, but I wonder if we can do this with .NET 2...
The Win32 call I wish to do in .NET 2 is the following:
<br />
strChannel=_T("\\\\.\\HPx9G+\\PIPE0");<br />
m_hInput=::CreateFile(strChannel, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING, NULL);<br />
Is it possible at last in .NET 2?
Thanks for the help.
Best regards.
Fred.
There is no spoon.
|
|
|
|
|
|
Hi Christian,
This site is what I am looking for for a list of api to be used are this applicable in Windows Xp and Windows CE? It seems there is no explanation as to what each method of api does. Thanks.
I have look and not found exactly what I wanted.
denpsia
-- modified at 1:50 Friday 9th December, 2005
|
|
|
|
|
This site covers all APIs, read the API docs to see what's in CE and what's in XP ( until Vista comes out, I assume it's all in XP anyhow )
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Christian,
Thanks for reply. I am looking for functions/methods in reseting pc, controlling audio on/off, setting volume, setting screen brightness, things like that. Seems I did not find other functionalities in the site you mentioned.
denpsia
-- modified at 2:14 Friday 9th December, 2005
|
|
|
|
|
Actually it seems to be a .NET stub to the Win32 API, so if I do such a thing, my project will become a nightmare and it won't be a full .NET application. Maybe communications with drivers will be available in .NET 3
Thanks for your help.
Fred.
There is no spoon.
-- modified at 2:17 Friday 9th December, 2005
|
|
|
|
|
that's exactly what it is pinvoke is a way to call any standard c/c++ library from .net apps. As for it not being a full .net app, most (all?) of the winform classes are MS written wrappers that simply pinvoke the win32 api themselves.
|
|
|
|
|
im using .net 2.0 and the TableLayoutPanel, when i add/move controls to/in the grid it flickers alot, ive tried <code>SetStyle(ControlStyles.OptimizedDoubleBuffer, true);</code> but still flickers.
im using this method to add the controls
<code>
this.tableLayoutPanel1.Controls.Add(control, column, row);
</code>
and for moving
<code>
this.field.tableLayoutPanel1.SetRow(control, position);
</code>
any ideas?
Thanks
-- modified at 17:10 Thursday 8th December, 2005
|
|
|
|
|
When I try to compile my class I get this error:
Type of conditional expression can't be determined because there is no implicit conversion between '<null>' and 'int'
Which would make sense, but I am not trying to put a null in an int, I'm trying to stick null in an object...
parms[0].Value = _categoryID == -1 ? null : _categoryID;
where parms is of type SqlParameter[]
Now, if do:
<br />
parms[0].Value = null;<br />
or
<br />
if( _categoryID == -1 )<br />
{<br />
parms[0].Value = null;<br />
}<br />
else<br />
{<br />
parms[0].Value = _categoryID;<br />
}<br />
it compiles and works fine. Now obviously this isn't a game breaker because I can write out every if/else statement longhand. However, I should be able to use a ternary condition, right?
|
|
|
|
|
|
Basically, you can't do this. This is because you're evaluating an expression (bool?x:y) that is trying to return 2 different types, an object reference and int.
From the MSDN Gospel:
The second and third operands of the ?: operator control the type of the conditional expression. Let X and Y be the types of the second and third operands. Then,
If X and Y are the same type, then this is the type of the conditional expression.
Otherwise, if an implicit conversion exists from X to Y, but not from Y
to X, then Y is the type of the conditional expression.
Otherwise, if an implicit conversion exists from Y to X, but not from X
to Y, then X is the type of the conditional expression.
Otherwise, no expression type can be determined, and a compile-time error occurs.
What all this means, is that the compiler error occurs because there is no conversion possible between int and null . It looks like you'll have to do it using an if statement.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
This solved it, thank you very much =)
-- modified at 16:50 Monday 12th December, 2005
|
|
|
|
|
hi,
i want to save a picture in the ico-format and tried it like this:
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
Bitmap bmp = new Bitmap(16, 16);<br />
Graphics g = Graphics.FromImage(bmp);<br />
<br />
Font f = new Font("Arial", 5);<br />
LinearGradientBrush b = new LinearGradientBrush(ClientRectangle, Color.Red, Color.Red, LinearGradientMode.Horizontal);<br />
g.DrawString("ABC", f, b, 1, 1);<br />
pictureBox1.Image = bmp;<br />
<br />
bmp.Save("d:\\test.ico", ImageFormat.Icon);<br />
Icon = new Icon("d:\\test.ico");<br />
}
somehow it doesn't work, i just don't have a clue what the reason is.
i hope someone can help me.
|
|
|
|
|
Hi man try this:
System.IO.FileStream stream = System.IO.File.Create(@"c:\myIcon.ico");
Icon ico= System.Drawing.Icon.FromHandle(bmp.GetHicon());
ico.Save(stream);
hope that helped
GanDad
|
|
|
|
|
I have a grid control that takes an IList, ITypedList or IBindingList object as a DataSource. I'm currently using a System.Data.DataTable and the performance is pretty dismal. I've isolated the bottle neck as being the build of the DataTable. My question is, which of the various data collections is the lightest weight and most efficient? Thanks.
-- modified at 14:10 Thursday 8th December, 2005
|
|
|
|
|
An IList implementation is the lightest of the three. But, why is filling your DataTable taking so long? I ask because if it's an inefficient process, you'll run into the same lag when filling an IList object.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 17:18 Thursday 8th December, 2005
|
|
|
|
|
Hi everyone!
I got a little problem with an asyncronous WebRequest, or more precise, with its exception handler.
I'm calling a method that issues an asyncronous WebRequest and returnes its IAsyncResult to be able to wait for it lateron. Everything works fine so far, but if the host is unreachable an exception is thrown and an error message is added to my RequestState, which is returned along with the IAsyncResult. The problem is that in many cases that error message is added to the RequestState after my surrounding class received and waited for the WebRequests IAsyncResult.WaitHandle (which of cause is compleated and no error messages are found). So i'm trying for quite a while now to, 'sort of', syncronize that mechanism with a ManualResetEvent inside an asyncronously called delegate whose IAsyncResult is returned instead of the WebRequests IAsyncResult, but with no success.
I'm not very familiar with threaded applications, so i don't know exactly what to look for... so it would be great if someone could point me in the right direction.
Thanks in advance!
Below some pseudo-code with the general structure:
public void CallingMethod()<br />
{<br />
<br />
<br />
}<br />
<br />
public IAsyncResult Process()<br />
{<br />
IAsyncResult asyncResult = myWebRequest.BeginGetResponse(RespCallback, myRequestState);<br />
return asyncResult;<br />
}<br />
<br />
private void RespCallback(IAsyncResult asyncResult)<br />
{<br />
try<br />
{<br />
resp = req.EndGetResponse(asyncResult);<br />
}<br />
catch (Exception ex)<br />
{<br />
string errorMessage = string.Format("host unreachable...");<br />
((MyRequestState)asyncResult.AsyncState).AddStatusMessage(errorMessage);<br />
}<br />
}
Variables won't; constants aren't. (Osborne's Law)
|
|
|
|
|
Is is possible to have a C# app update text boxes in a webpage that I don't own?
For example if there was a webpage that had a couple of textarea input fields would it be possible to write a C# app that could put text into those textarea's?
Thanks.
- Aaron
|
|
|
|
|
Hi Aaron,
Do you actually need to do this? Perhaps if you are wanting to send data to a particular website you could simulate the POST with HttpWebRequest ...?
Regards,
Rob Philpott.
|
|
|
|
|
Yes, it is something I would like to do. Would it be possible to provide and example using the HttpWebRequest? I'm not very familiar with web programming.
Thanks.
- Aaron
|
|
|
|
|
Hi again,
The first thing I'd do in tackling this problem is to see what the form the POST takes when you fill in the details on the webpage normally by hand and hit submit.
I'd recommend using the Microsoft Soap Toolkit Trace Utility for this http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-4088-9753-86F052EC8450&displaylang=en[^]
Fire this up and create a new trace. Put in the URL of the page you want to submit to, and leave the local port on 8080 and the external port on 80. Then point your browser at http://localhost:8080
This tool will allow you to see exactly what gets sent and what is recieved from the website (provided its not SSL secured). From playing around with this you should be able to determine exactly what to POST to the website to make it look like its just plain Internet Explorer etc. I find this is a damn handy thing to have around when web programming. Bear in mind that this is a bit like the old screen-scraping approach and if the website changes will probably break.
In your code create an instance of the HttpWebRequest class by calling its static Create() method passing in the url of the website. Set the Method property to "POST" and then use GetRequestStream() to get a stream to which you can feed your simulated data. Call GetResponse() to fire the data up to the website.
If you have problems with this I'll knock up a sample for you tomorrow.
Regards,
Rob Philpott.
|
|
|
|