Kualla481 / boblight

Automatically exported from code.google.com/p/boblight
GNU General Public License v3.0
0 stars 0 forks source link

Boblightd compiled for Enigma2 (mipsel), dreambox. WriteBytes Output wrong! #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I have compiled the boblightd for my dreambox.
See the attachement.

I i run boblightd i see only:
/dev/ttyUSB0 write: 41 64 61 00 31 64 ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 
ff ff 

And my lights go on, and have the color White.

If i run boblight-constant FFCC00 (also in attachement), i see only white (ff 
ff ff ff ff ).

If i run the same on Ubuntu i see, for black
/dev/ttyUSB0 write: 41 64 61 00 31 64 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

and for FFCC00
/dev/ttyUSB0 write: 41 64 61 00 31 64 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff cc 
00 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff cc 00 ff 
cc 00 ff cc 00 ff cc 00 ff cc 00 
That's good.

What version of the product are you using? On what operating system?
Boblightd 2.0 on Engima2 Box, on image OpenPli2.1

Who can help me, to figure out this problem.
I think it's a problem with the ftdi_sio ?

Original issue reported on code.google.com by vosenw...@gmail.com on 14 Feb 2012 at 7:32

Attachments:

GoogleCodeExporter commented 8 years ago
 can you pls post libboblight.so too, so I can test it is on my box.

Just a hint: try for testing purposes /dev/ttyS0 instead of ttyUSB0, then you 
know if it's because ftdi.so

I am also at ihad board (denim), if you want to discuss further...

cheers
d

Original comment by ooztue...@gmail.com on 14 Feb 2012 at 10:09

GoogleCodeExporter commented 8 years ago
Hi,

I have test your tip, same problem.
I have attached the file.

Test it please.

I find this code in devicers232.cpp:

int64_t now = GetTimeUs();

This code gives me 0, if i try  int32_t now = GetTimeUs();
It gives me time's, bath the times are wrong.

Original comment by vosenw...@gmail.com on 14 Feb 2012 at 10:47

Attachments:

GoogleCodeExporter commented 8 years ago
My guess is CLOCK_MONOTONIC is not functioning.

Original comment by bob.loo...@gmail.com on 15 Feb 2012 at 2:04

GoogleCodeExporter commented 8 years ago

Original comment by bob.loo...@gmail.com on 15 Feb 2012 at 2:04

GoogleCodeExporter commented 8 years ago
OK, Can i change CLOCK_MONOTONIC to something else, so it's working ?

Original comment by vosenw...@gmail.com on 15 Feb 2012 at 8:47

GoogleCodeExporter commented 8 years ago
Try CLOCK_REALTIME

Original comment by bob.loo...@gmail.com on 15 Feb 2012 at 4:35

GoogleCodeExporter commented 8 years ago
Try CLOCK_REALTIME

I have done that, bath no result.
It's like that int64_t is not working.

Original comment by vosenw...@gmail.com on 15 Feb 2012 at 4:42

GoogleCodeExporter commented 8 years ago
Are the values in the struct timespec correct?

Original comment by bob.loo...@gmail.com on 15 Feb 2012 at 6:07

GoogleCodeExporter commented 8 years ago
What do you mean?

This is my code of timeutils.h

#ifndef TIMEUTILS
#define TIMEUTILS

#include "inclstdint.h"

#include <time.h>

inline int64_t GetTimeUs()
{
  struct timespec time;
  clock_gettime(CLOCK_MONOTONIC, &time);

  return ((int64_t)time.tv_sec * 1000000LL) + (int64_t)(time.tv_nsec + 500) / 1000LL;
}

template <class T> 
inline T GetTimeSec()
{
  return (T)GetTimeUs() / (T)1000000.0;
}

void USleep(int64_t usecs, volatile bool* stop = NULL);

#endif //TIMEUTILS

If i do a ErrorLog in devicers232.cpp.

bool CDeviceRS232::WriteOutput()
{
  //get the channel values from the clienshandler
  int64_t now = GetTimeUs();
  m_clients.FillChannels(m_channels, now, this);

  //put the values in 1 byte unsigned in the buffer
  for (int i = 0; i < m_channels.size(); i++)
  {
    int64_t output = Round64((double)m_channels[i].GetValue(now) * m_max);
    output = Clamp(output, 0, m_max);

    //Send errorlog for debug
    LogError("Now =$i",now); //////// - This gives me 0 on my  box, on ubuntu gives me the time.
    LogError("output Clamp =$f",output); ////// - a random number 6nrs or sometime 7nrs. and on ubuntu         gives me 0 when there is no connection with the client and a number when there is a connection on with a client.

    for (int j = 0; j < m_bytes; j++)
      m_buff[m_prefix.size() + i * m_bytes + j] = (output >> ((m_bytes - j - 1) * 8)) & 0xFF;

     //mbuff gives me altime 0.00000 or FFFFFF
  }

Original comment by vosenw...@gmail.com on 15 Feb 2012 at 6:33

GoogleCodeExporter commented 8 years ago
now and output are int64_t, this is how you print them to the log:

LogError("Now =%" PRIi64, now);
LogError("output Clamp =%" PRIi64, output);

Original comment by bob.loo...@gmail.com on 15 Feb 2012 at 7:34

GoogleCodeExporter commented 8 years ago
Hi, Thanks for your tip.

I think i no where the problem come from.

int64_t output = (double)m_channels[i].GetValue(now) * m_max;
output = Clamp(output, 0, m_max);

With Clamp i get 255 and without Clamp i get 9223372034707292159, That's Wrong.
So the leds are 255 that's FFFFFF.

on Ubuntu i get without clamp 0.

I i manual change the output to 55 i changed my color.
Do you no where i can find a solution for this problem.
I think the problem come from device.cpp GetValue.

Greetz Martijn

Original comment by vosenw...@gmail.com on 16 Feb 2012 at 12:43

GoogleCodeExporter commented 8 years ago
I suggest you start tracing back to where it goes wrong, it could be something 
in the CChannel::GetValue function.

Original comment by bob.loo...@gmail.com on 16 Feb 2012 at 10:14

GoogleCodeExporter commented 8 years ago
Al the output from m_speed gives me negative numbers.
On linux its good.

Original comment by joseonli...@gmail.com on 16 Feb 2012 at 10:16

GoogleCodeExporter commented 8 years ago
Hi Bob, 
I am trying to solve this issue too. 
GDB is running on 2 machines with boblightd  (X86  / MIPS) :

MIPS OUTPUT (wrong):
(After the 2nd check once m_lastupdate was correctly set, it come to check the 
speed, but it never goes there, on x86 it does)
Breakpoint 1, CChannel::GetValue (this=0x4516e8, time=100323097023) at 
device/device.cpp:60
60        if (m_lastupdate == -1)
(gdb)
57      float CChannel::GetValue(int64_t time)
(gdb)
60        if (m_lastupdate == -1)
(gdb)
66        if (m_speed == 100.0) //speed of 100.0 means max
(gdb) p m_speed
$2 = -4.45014772e-308
(gdb) n
72          float diff = m_wantedvalue - m_currentvalue; //difference between 
where we want to be, and where we are
(gdb) p m_speed
$3 = -4.45014772e-308
(gdb) printf "%f ",m_speed
-0.000000 (gdb)

m_speed is show at least negative (I hope GDB is working and showing correct 
output)

X86 OUTPUT (correct):

Breakpoint 2, CChannel::GetValue (this=0x807b9c0, time=96943026820) at 
device/device.cpp:58
58  {
(gdb) 
60    if (m_lastupdate == -1)
(gdb) 
66    if (m_speed == 100.0) //speed of 100.0 means max
(gdb) 
68      m_currentvalue = m_wantedvalue;
(gdb) p m_speed 
$9 = 100
(gdb) printf "%f ",m_speed 
100.000000 (gdb) 

on X86 it show correctly all. 

This happens with almost all float values like for m_currentvalue, 
m_wantedvalue etc. 

So I am not really a C++ expert, so this problem might be easy to resolve (I 
hope :)

Original comment by ooztue...@gmail.com on 16 Feb 2012 at 10:22

GoogleCodeExporter commented 8 years ago
Nope, no easy fix, and without a machine to reproduce it on I can't be of much 
help.

Original comment by bob.loo...@gmail.com on 16 Feb 2012 at 11:45

GoogleCodeExporter commented 8 years ago
my assumption is, that there are problems with float on the mipsel machine.

if I add:
---
float CChannel::GetValue(int64_t time)
{
printf("%4.2f %4.2f %4.2f\n",m_speed  ,m_lastupdate  , m_currentvalue  );
---

I get -> nan 324234234 nan

Original comment by ooztue...@gmail.com on 17 Feb 2012 at 9:54

GoogleCodeExporter commented 8 years ago
Now the question is where are those values coming from.

Original comment by bob.loo...@gmail.com on 17 Feb 2012 at 6:56

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
I just got boblightd working with my arm router TL-WR1043ND and openwrt, and I 
don't have any problems.

I noticed openwrt uses "-msoft-float" as a compilation option - and it says 
about it:

> If your target CPU does not have a Floating Point Unit (FPU) or a kernel FPU 
emulator, but you still wish to support floating point functions, then 
everything will need to be compiled with soft floating point support 
(-msoft-float)

So maybe you guys should try to compile boblight with "-msoft-float" and all 
this float problems "float" away? ;-)

Original comment by markus.d...@gmail.com on 8 Jul 2012 at 10:49

GoogleCodeExporter commented 8 years ago
That sounds reasonable, but afaik it requires a software float implementation 
from glibc or another library.

Original comment by bob.loo...@gmail.com on 8 Jul 2012 at 12:29

GoogleCodeExporter commented 8 years ago
All fixed!

Original comment by boblight...@gmail.com on 29 Mar 2013 at 7:41

GoogleCodeExporter commented 8 years ago
github.com/speedy1985

Original comment by boblight...@gmail.com on 29 Mar 2013 at 7:42