Per Malmberg
Everything is possible, including the impossible. It just takes a little longer…
Everything is possible, including the impossible. It just takes a little longer…
Another post in English, just to please the larger audience.
I just finished an interesting discussion with another developer, about starting an Open Source 1-Wire project to convert the existing Java 1-Wire classes provided by Dallas/Maxim to C#. We’ll see what this ends in, sounds promising.
Update: After having a look at the code that was provided (which is based on the alpha release of the “Pure C#”-code by Dallas), I’ve come to the conclusion that I’m going to stick to my own 1-Wire library for the time being. Although using the code-base from Dallas might give some benefits – it is the official C# library after all – I also see benefits of using my own implementation. The biggest advantage to use their code-base is obviously the device containers that comes with it; I’ll have to implement those I need in my library. On the other hand, there are very few devices for which I need support; it’s just temperature sensors (Family 0×10), switches (0×05) and a third party LCD driver.
Support for temperature sensors are already implemented and judging by the data sheet for DS2405, implementing support for that switch doesn’t look very hard. The same goes for the LCD driver. So, until someone convinces me otherwise, I will continue to develop my own library.
Oh, for those who wonders: I’ve not decided if I shall release my library as Open Source or not yet. I’m still thinking about it.
Comments are closed.
2008/11/23 - 20:54
Hi,
I’m new in 1-Wire and trying to implement communication to DS18S20 via DS9097U in pure C#.
I know about TMEX lib and mapped WinApi calls way, but want to implement communication using SerialPort class.
OneWireViewer works propertly on my hardware but my source has problem with presence detecting and returned temp=85C all the time.
Could you please check my source for Reset and tell me what I’m doing wrong?
Maybe the problem is with port settings, but I can’t find any samples or docs for this point.
Thanks
[Test]
public void DS1820_resetLine()
{
using (SerialPort port = new SerialPort(“COM3″))
{
try
{
port.Open();
port.Parity = Parity.None;
port.DataBits = 8;
port.StopBits = StopBits.One;
port.BaudRate = 9600;
port.DtrEnable = false; // for DS9097
port.RtsEnable = false; // for DS9097
WaitOp(300);
port.DtrEnable = true; // for DS9097
port.RtsEnable = true; // for DS9097
WaitOp(100);
port.BaseStream.Flush();
port.BaseStream.WriteByte(0xE3); //to command mode
port.BaseStream.WriteByte(0xC1); //reset
port.BaseStream.Flush();
WaitOp(1);
byte cmd = (byte)port.BaseStream.ReadByte(); // PROBLEM: never returns
Assert.That(cmd, Is.Not.EqualTo(0));
}
finally
{
port.Close();
}
}
}
public void WaitOp(int ms)
{
Thread.Sleep(ms);
}
2008/11/23 - 21:11
Hello,
Sorry, but I do not give this kind of support. However, feel free to look at the source for my open source project here: http://sourceforge.net/projects/owdotnet
It should have all you need.
2008/11/24 - 7:56
Hi,
ok, thanks, you are using WinAPI functions mapping in your project, but I want to do the same via SerialPort class from .Net 2.0. (seems it is not possible because of some port settings issue
)
Best Regards,
tz