|
|
Hi,
i'm beginner in MODBUS, so please help me.
i have a temperature regulator with MODBUS communication.
For example:
If i want to read holding register e.g.: 0042 „Value of temperature“ from mentioned device, in my application for MODBUS-RTU communication which i was writte in
Microsoft Visual Studio 2005- VC#,
i made request -byte array:
{0x01, 0x03, 0x00, 0x29, 0x00, 0x01, 0x83, 0x01}
1- slave adress (configured in device)- 0x01
2.- function code(Read Holding Registers)- 0x03
3.- start adress Hi- 0x00
4.- start adress Lo- 0x29
5.- no. of registers Hi- 0x00
6.- no of registers Lo- 0x01
7.- error code- 0x83
8.- exception code- 0x01
and sent that array to device. Label Rx blinks ,on the front panel of device, so device received my request, but i don't get any response, Tx doesn't blink!!!
For example:
If holding register 0042 „Value of temperature“=555, response message from device should be:
{slave adress=0x01, function code= 0x03, byte count= 0x02, register value Hi= 0x02,
register value Lo= 0x2B,... } !!!????
But i get nothing!!!!
All other parameters like port name, baud rate, parity, data bits, stop bits,ReadTimeout, WriteTimeout and RS485/RS232 converter are O.K.
Plese, could You help me with some advice to get response from device and tell me what i do wrong.
Is my request -byte array O.K.??? (especialy last two bytes 0x83, 0x01- CRC)
Thank You very much.
Best regards!
|
|
|
|
|
Without seeing any code or knowing what transmission media that you're using, it's difficult to say with any certainty where the problem is.
Try using this[^] to check your CRC bytes. Here[^] has some links to tools that may help you.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
what tool is available for coding rules ?
|
|
|
|
|
|
|
|
|
Hello everyone,
I am using the following code to retrieve the string content of XML, my question is why there is many trailing zeros in variable content? How to solve it?
static void Main(string[] args)
{
MemoryStream MemoryStream1 = new MemoryStream();
StreamWriter StreamWriter1 = new StreamWriter(MemoryStream1);
XmlTextWriter XMLWriter1 = new XmlTextWriter(StreamWriter1);
XMLWriter1.WriteStartDocument();
XMLWriter1.WriteStartElement("Entity");
XMLWriter1.WriteAttributeString("node", "Hello Node");
XMLWriter1.WriteEndElement();
XMLWriter1.WriteEndDocument();
XMLWriter1.Flush();
string content = Encoding.UTF8.GetString(MemoryStream1.GetBuffer());
return;
}
thanks in advance,
George
|
|
|
|
|
|
Thanks leppie,
It works!
regards,
George
|
|
|
|
|
Hi! All
I m working on a project who has images, icons defined in Resources Properties. All these loads at run time. but when i remove some images from Resources then it prompts error messages. I want to handle it if the image exist then it appears if it does not exist then does not.
Let me tell how to Handle this
these are accessed as
this.BackGroundImage = MyProject.Properties.Resources.Logo;
it is ok
when i remove "logo" from Resources.
then a compile time error: logo is identified.
* So far i handle this. as i make an empty image with same name i removed.
but that is the not a solution.
Any suggestion regarding this. will be anticipated.
Thanks in advance.
|
|
|
|
|
Instead of linking the file at compile time, you can embed it in the .resx file. There will be a Persistence property for the image when you open the Resources.resx file in IDE.
Also, If you want to remove the image, you can remove it from resources also, why you want to keep it if its not used?
*jaans
|
|
|
|
|
Hi.
im currently stuck in a small problem which i cant seem to overcome
i have built a small easy tracking service which runs with timers and takes the current address from internet explorer bar and writes it on a notepad
im using a refference for .COM internet controls 6 -> shDocVw.ShellWindows
now, when i compile the program-it works perfectly fine (i even tried to build it on a webform it runs smoothly with no problems at all)
But when im trying to run the service after installing it with installutil
i get the error "COM object with CLSID {9BA05972-F6A8-11CF-A442-00A0C90A8F39} is either not
valid or not registered"
and it get closed by itself
any magical solutions???
thanks alot!
|
|
|
|
|
When u make a function call, all the value type of the calling function are pushed in stack. As soon as function returns control, the value types & memory used by variables inside function got released.
string and object are refrence type.
class A
{
string abc = "";
...
...
...
}
class B
{
A obj = new A();
obj.abc = "Value";
}
class C
{
A obj = new A();
}
Now sequence in which these class got called is A->B->C.
What happen to value i stored in abc during class B, does It got restore to default by C class obj creation.
What is the scope of variables declare at class level, as soon as control comes out from a class does they restore to default?
Thanks & regards.
|
|
|
|
|
Jon Skeet has an excellent article here[^]. It's worth reading.
|
|
|
|
|
N a v a n e e t h wrote: Jon Skeet has an excellent article here[^]. It's worth reading.
I did read that one. But i couldn't grasp whole.
will u please tell me, with refrence to my original post,
what value does abc hold if i use it after executing C class.
|
|
|
|
|
humdumof wrote: What happen to value i stored in abc during class B, does It got restore to default by C class obj creation.
No, the instance of A that is created in the B class is separate from the instance of A created in the C class.
humdumof wrote: What is the scope of variables declare at class level, as soon as control comes out from a class does they restore to default?
At the class level, you have to distinguish between class members (static variables) and instance members (member variables). A static variable in a class exists only once and exists in the class rather than in an instance of the class. A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Guffa wrote: A member variable exists in an instance of the class, so it's separate for each instance. A member variable retains it's value as long as the instance exists.
class test
{
string abc = "";
}
class Test2
{
test t1 = new test();
t1.abc = "some value";
test t2 = new test();
t2.abc = "next value";
}
Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
Means t1 is seprate & t2 is seprate copy?
Is it correct?
What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
modified on Wednesday, June 11, 2008 5:55 AM
|
|
|
|
|
humdumof wrote: Does it means as long as t1 exist(not garbage collected), t1.abc =="some value" ?
..if you don't change the value
humdumof wrote:
Means t1 is seprate & t2 is seprate copy?
Is it correct?
t1 and t2 are different instance of Type test, yes.
|
|
|
|
|
humdumof wrote: Means t1 is seprate & t2 is seprate copy?
Is it correct?
Yes.
humdumof wrote: What i thought, suppose there exist A, B, C classes.
set the class A feild within B, then i was trying to access that value(which i set in B) in C by another obj created inside C.
We cant set like this, can we?
No, you can't. They are separate instances, and they are not aware of each other.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Thanks a lot for your replies.
|
|
|
|
|
How to reverse the string by the following manner ?
If string is "This is the test".
1] Reverse string should be "tset eht si siht"
2] other one: "siht si eht tset" (for this, using substring function)
|
|
|
|
|
Homework ?
We won't help you; You have to do it yourself. We can help you when you are struck somewhere.
|
|
|
|
|
How abt a loop which iterates the length times of the given string and stores the values from the last char index to first in another string
Try it once if u struck post code
If You win You need not Explain............
But If You Loose You Should not be there to Explain......
|
|
|
|