[mythtv-users] Serial control of a TV
David Brodbeck
gull at gull.us
Sat Mar 14 23:38:18 UTC 2009
Yan Seiner wrote:
> George Nassas wrote:
>> On 14-Mar-09, at 2:11 AM, Greg Newton wrote:
>>
>>> I'd stick with the line-ends theory too - the manual for my LC46PD7X
>>> says "Eight ASCII codes + CR" - maybe try
>>>
>>> echo -e "POWR0 \r"
>>
>>
>> Not sure what the -e is doing but echo sends a newline (\n) after its
>> output. The TV might be taking that newline as the start of its next
>> command and, deciding it doesn't like it, ignoring everything until
>> the next \r.
>>
>> The shell printf command doesn't send any extra characters so a printf
>> "POWER0 \r" might do it for you and also leave the TV in a good state
>> for the next command. echo -n works too if you're without printf.
>
> -e enables parsing of special characters like '\r'.
If you're trying to send just a carriage return, you actually want to
use both -e and -n. Otherwise echo will still insert a newline on the end:
gull at dyna-soar:~$ echo -e "test.\r" | od -c
0000000 t e s t . \r \n
0000007
gull at dyna-soar:~$ echo -e -n "test.\r" | od -c
0000000 t e s t . \r
0000006
It sort of depends on what the TV expects. "\r \n" is a standard DOS
end-of-line sequence, but to me "CR" would suggest just a carriage
return, "\r". UNIX uses "\n", a line feed, as its end of line character.
More information about the mythtv-users
mailing list