[Ovmsdev] access to writer?

sharkcow sharkcow at gmx.de
Sat Sep 14 22:52:44 HKT 2024


Thanks for the swift replies!

So the deal is I do want to react to a shell command, means I do have a
reference to the current writer. But since my code works asynchronously
it's not easily possible to pass the writer to the other functions. I'll
think about it some more :)

I just wanted to return useful information also on the server web shell
and Android app since I realized some people don't/can't use the
built-in web shell (where I can output everything via log commands).

sharkcow


> Probably the best you can do is do a log.  If you the do log monitor yes
> and enable the channel it will appear.
>
> I think you need to take a step back and say what your original problem is.
>
> Remember multiple 'writers' can be active / temporarily created depending
>
>
> //.
>
> On Fri, 13 Sept 2024, 20:40 Michael Balzer via OvmsDev, <
> ovmsdev at lists.openvehicles.com> wrote:
>
>> The short answer is: you can't.
>>
>> There is no "current" writer. If a function may need to output text to a
>> writer, you need to pass the writer pointer to that function.
>>
>> In case of functions that may be called within a user command execution
>> and shall then provide output, add the writer to the signature, and only
>> use it when it's not null. If the output is important, send it to the
>> log if the writer is null.
>>
>> If you need to reduce the output for certain output channels, you'll
>> also want to pass the "verbosity" parameter along with the writer pointer.
>>
>> Regards,
>> Michael
>>
>>
>> Am 13.09.24 um 08:55 schrieb sharkcow via OvmsDev:
>> > Hi all,
>> >
>> > I have a dumb question: how do I get access to the current "writer"
>> > object in a "regular" function in my vehicle code (not defined by
>> > RegisterCommand)?
>> >
>> > Thanks!
>> >
>> > sharkcow
>> > _______________________________________________
>> > OvmsDev mailing list
>> > OvmsDev at lists.openvehicles.com
>> > http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>
>> --
>> Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
>> Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
>>
>> _______________________________________________
>> OvmsDev mailing list
>> OvmsDev at lists.openvehicles.com
>> http://lists.openvehicles.com/mailman/listinfo/ovmsdev
>>




More information about the OvmsDev mailing list