Pulse-Eight / libcec

USB CEC Adapter communication Library http://libcec.pulse-eight.com/
Other
704 stars 282 forks source link

Please flush stdout of cec-client after you got the remote data #613

Open Cosmotan01 opened 1 year ago

Cosmotan01 commented 1 year ago

Hi, i have write a program in Lazarus on Rpi4, i start cec-client with TProcess and for longer cec-client output almost 90% of my tv remote its working good .

Such cec-output like this works, and i can retrieve the pressed button : TRAFFIC: [ 57918] >> 01:44:25 DEBUG: [ 57918] SetCurrentButton 5 (25) D:0ms cur:1c70850 DEBUG: [ 57918] key pressed: 5 (25) current(ff) duration(0) DEBUG: [ 57918] Changed key 5 (25) D:0ms cur:ff DEBUG: [ 57918] key pressed: 5 (25, 0) DEBUG: [ 57918] CheckKeypressTimeout T:103999.584 DEBUG: [ 57918] Key 5: idle (duration:0) (25) timeout:-1280316024ms (rel:500,rep:0,prs:500,rel:0)

But this will not work (i thing because the stdout buffer wait for more data/strings): TRAFFIC: [ 29624] >> 01:42:03 DEBUG: [ 29624] >> TV (0) -> Recorder 1 (1): deck control (42)

Can you add a parameter to cec-client that will force a stdout flush after no new data is coming from the remote, maybe like --flush-stdout=50 (ms) so if cec-client receive the second example and no new data is coming withing 50 ms, its flush the output buffer and TProcess will get the data.

I have write a little test program that sends either the first sample or the second sample to stdout , and i have the same behavior like with cec-client, i added a Flush(stdout); and then the second sample was working to.

In Bash both samples works good, but in Lazarus the 2nd is a problem.

Cheers

P.S.: I can send you the source of my lazarus program if needed.