[Nut-upsdev] Liebert ESP II driver

Robert Jobbagy jobbagy.robert at gmail.com
Mon Aug 2 09:26:51 UTC 2010


I fixed my shutdown function:

void upsdrv_shutdown(void)
{
    int ret;
    FILE* logger = fopen( "/tmp/liebert-esp2_debug.log", "w" );

    fprintf(logger,"SHUTDOWN 1");

    ret = ser_send_buf(upsfd, cmd_UPSShutdown0, SHUTDOWN_CMD_LEN);
    if(ret < 0){
    fprintf(logger,"Something wrong 1");
    }else if(ret < 6){
    fprintf(logger,"Answer is too short 1");
    }

    fprintf(logger, "SHUTDOWN 2");

    ret = ser_send_buf(upsfd, cmd_UPSShutdown1, SHUTDOWN_CMD_LEN);
    if(ret < 0){
    fprintf(logger,"Something wrong 2");
    }else if(ret < 6){
    fprintf(logger,"Answer is too short 2");
    }

    fprintf(logger,"SHUTDOWN 3");

    ret = ser_send_buf(upsfd, cmd_UPSShutdown2, SHUTDOWN_CMD_LEN);
    if(ret < 0){
    fprintf(logger,"Something wrong 3");
    }else if(ret < 8){
    fprintf(logger,"Answer is too short 3");
    }

    fflush(logger);
    fclose(logger);

}

I ran a test and doesnt exist the /tmp/liebert-esp2_debug.log file so I
think shutdown function not called but I don't know why ....

any idea ?


2010/8/2 Robert Jobbagy <jobbagy.robert at gmail.com>

> Sorry I misundestand you Arjen, I try printf and no upsdebug and log
> functions.
> I understand now that driver don't can write to stderr in this function.
>
> 2010/8/2 Robert Jobbagy <jobbagy.robert at gmail.com>
>
> I use nut rev2462.
>> gcc version 4.1.2 20080704   answer for Arjen
>>
>> I modified my shutdown function :
>>
>>
>> void upsdrv_shutdown(void)
>> {
>>     int ret;
>>
>>     upsdebug_with_errno(2, "SHUTDOWN 1");
>>     upslog_with_errno(2, "SHUTDOWN 1");                                <--
>> I didnt look these msg in my log , I ran liebert-esp2 driver in debug 2
>> mode.
>>     upslogx(2, "SHUTDOWN 1");
>>
>>
>>
>>     ret = ser_send_buf(upsfd, cmd_UPSShutdown0, SHUTDOWN_CMD_LEN);
>>     if (ret < 0) {
>>         upsdebug_with_errno(2, "SHUTDOWN send");
>>
>>     }
>>     else if (ret < 6) {
>>         upsdebug_hex(2, "send: truncated", cmd_UPSShutdown0, ret);
>>     }
>>
>>     upsdebug_hex(2, "SHUTDOWN send", cmd_UPSShutdown0, SHUTDOWN_CMD_LEN);
>>
>>     upsdebug_with_errno(2, "SHUTDOWN 2");
>>
>>     ret = ser_send_buf(upsfd, cmd_UPSShutdown1, SHUTDOWN_CMD_LEN);
>>
>>     if (ret < 0) {
>>         upsdebug_with_errno(2, "SHUTDOWN send");
>>     }
>>     else if (ret < 6) {
>>         upsdebug_hex(2, "send: truncated", cmd_UPSShutdown1, ret);
>>     }
>>
>>     upsdebug_hex(2, "SHUTDOWN send", cmd_UPSShutdown1, SHUTDOWN_CMD_LEN);
>>
>>     upsdebug_with_errno(2, "SHUTDOWN 3");
>>
>>     ret = ser_send_buf(upsfd, cmd_UPSShutdown2, SHUTDOWN_CMD_LEN);
>>     if (ret < 0) {
>>         upsdebug_with_errno(2, "SHUTDOWN send");
>>     }
>>     else if (ret < 8) {
>>         upsdebug_hex(2, "send: truncated", cmd_UPSShutdown2, ret);
>>     }
>>
>>     upsdebug_hex(2, "SHUTDOWN send", cmd_UPSShutdown2, SHUTDOWN_CMD_LEN);
>>
>> }
>>
>>
>> Someone any idea or advice ? what can I do that I figure out what's wrong?
>>
>>
>> Thanks your help and your time.
>>
>> 2010/7/31 Robert Jobbagy <jobbagy.robert at gmail.com>
>>
>>
>>>
>>> 2010/7/30 Robert Jobbagy <jobbagy.robert at gmail.com>
>>>
>>> sorry , returns it's my fault,it was copy-paste from other function.
>>>
>>>
>>> I fixed the returns but never happend, the ups didnt shutdown .
>>> I think shutdown function cant performed, I dont know why
>>>
>>>>
>>>> but I checked the  upsdebug_hex function and I saw it use fprintf with
>>>> stderr and I think it will be to work.
>>>>
>>>> 2010/7/30 Arjen de Korte <nut+devel at de-korte.org<nut%2Bdevel at de-korte.org>
>>>> >
>>>>
>>>>> Citeren Robert Jobbagy <jobbagy.robert at gmail.com>:
>>>>>
>>>>>  This is my shutdown function:
>>>>>>
>>>>>> void upsdrv_shutdown(void)
>>>>>> {
>>>>>>    int ret;
>>>>>>
>>>>>>    fprintf(stderr,"SHUTDOWN 1");
>>>>>>
>>>>>
>>>>> This doesn't work. The driver backgrounds before it reaches this point,
>>>>> so you can't use fprintf at this point anymore.
>>>>>
>>>>>
>>>>>     ret = ser_send_buf(upsfd, cmd_UPSShutdown0, SHUTDOWN_CMD_LEN);
>>>>>>    if (ret < 0) {
>>>>>>        upsdebug_with_errno(2, "send");
>>>>>>        return -1;
>>>>>>    }
>>>>>>    else if (ret < 6) {
>>>>>>        upsdebug_hex(2, "send: truncated", cmd_UPSShutdown0, ret);
>>>>>>        return -1;
>>>>>>    }
>>>>>>
>>>>>
>>>>> A void function can't return a value. Does the above actually compile
>>>>> without errors? If it does, change the compiler flags so that it doesn't.
>>>>> Also make sure that you're running your freshly compiled driver.
>>>>>
>>>>> [...]
>>>>>
>>>>>
>>>>>  These commands works other way , but in this function didnt work
>>>>>>
>>>>>> And I cant found the "SHUTDOWN 1,2,3" test texts in debug.log, so I
>>>>>> think
>>>>>> dont sent these commands to UPS.
>>>>>>
>>>>>
>>>>> See above.
>>>>>
>>>>>
>>>>> Best regards, Arjen
>>>>> --
>>>>> Please keep list traffic on the list
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Nut-upsdev mailing list
>>>>> Nut-upsdev at lists.alioth.debian.org
>>>>> http://lists.alioth.debian.org/mailman/listinfo/nut-upsdev
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best Regards,
>>>>
>>>> Robert
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>>
>>> Robert
>>>
>>
>>
>>
>> --
>> Best Regards,
>>
>> Robert
>>
>
>
>
> --
> Best Regards,
>
> Robert
>



-- 
Best Regards,

Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsdev/attachments/20100802/d088379c/attachment-0001.htm>


More information about the Nut-upsdev mailing list