more G-Labs products

Author Topic: RPi serial interface issues  (Read 1634 times)

October 20, 2014, 08:37:37 PM
Read 1634 times

J

  • *
  • Information
  • Newbie
  • Posts: 3
Hi guys,

I'm new here, but been reading a lot of your posts. For me (a noob at C# whatsoever) it helped me out a great deal. I've playing around with HG for a few of months now. I love it, but I'm running into a couple of issues now of which I hope you can help me with.

I'm trying to talk to a OpenTherm-gateway which allows me to read a load of data and set my temperature setpoint of my central heating. It uses a fairly simple serial protocol. I did this before in a VB-program on a windows machine and it worked. Now I installed HG on a windows server, wrote a program for it in HG C# and voile, it worked too.
Now, to save some kWh´s, I´ve bought me a Raspberry PI and loaded the HG-image. So far so good.

I would have thought that if I export the program I made on the server and transfer and import it to the RPI, it should work. Well, I was wrong there. I'm using a PL2303 USB-Serial converter, which i've found working on the server.

The protocol is a simple send REQ -> recv ACK -> send MESSAGE -> recv MESSAGE. All in byte form. I thought It might be the USB-Serial converter, but I've wrote a Python script on the RPI and it works OK. Then I tried writing some info to a file and then just reading it with HG, but as I've read, that's not supported. So I'll have to do the whole serial thing through HG.
So back to the C# program I wrote for HG. I found out that if I start my program on HG, it does send the REQs every 2 seconds. The gateway is replying, but it doesn't show on HG.
As soon as I go to the RPI terminal and hit "cat /dev/ttyUSB0" (and abort it), suddenly all the data I was requesting pops up in HG.
Then it sort of works! But then... after a minute or so, it looks like HG stops responding.

If you guys have any ideas or suggestions, please let me know.

Thanks,
Johan

October 20, 2014, 11:32:30 PM
Reply #1

bkenobi

  • *****
  • Information
  • Global Moderator
  • Posts: 1525
I haven't tried to read from a file, but I know you can write to a file.  Take a look at the Activity Monitor code I posted in my Advanced Smart Lights thread of App Contributions.  Perhaps a small modification can work to read data from a file.

October 20, 2014, 11:55:46 PM
Reply #2

J

  • *
  • Information
  • Newbie
  • Posts: 3
Thanks bkenobi,

I've found your program, and it indeed seems that the system.io.file class offers plenty of functionality. I thought my google-skill were sufficient, not...

I'll try your suggestion tomorrow,

Johan

October 21, 2014, 12:18:16 AM
Reply #3

J

  • *
  • Information
  • Newbie
  • Posts: 3
Well, I couldn't wait till tomorrow.

Thanks a lot bkenobi. I just tested it using the following code, and succes!
Code: [Select]
string test;
test = System.IO.File.ReadAllText("/root/Desktop/ReadFromGW.txt");
Program.Notify("file contents: ",test);


Johan