Re: pl2303_read_int_callback - usb_submit_urb failed with result -19

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think i am.

int readDword(int addr) {

    uint16_t reg[1];// will store read registers values

    int num = modbus_read_registers(ctx, addr, 1, reg);     //16386 = X2

    usleep(5);

    if (num != 1) {
        fprintf(stderr, "Failed(%i) to read: %s\n", num,
modbus_strerror(errno));
        modbus_close(ctx);
        modbus_free(ctx);
        sleep(5);
        int wait = 1;
        while(initModbus()) {
            cerr << "Waiting for PLC.. SLEEP[" << wait*20 << "]" << endl;
            sleep(wait*20);
            wait++;
        }
    }

    return reg[0];
}

according to modbus documentation, "The modbus_close() function shall
close the connection established with the backend set in the context."

Even if not. Shouldn't the minor number's go upto 512 (as Johan
pointed out) before giving up?

The system is an Olimex A20-micro,
Linux version 3.4.90+ (gcc version 4.7.1 (Debian 4.7.1-7) )

Thanks,
Malith

On Wed, Jul 13, 2016 at 10:17 AM, Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
> On Wed, Jul 13, 2016 at 08:58:48AM +0530, Malith Yapa wrote:
>> The reason for the random disconnects is apparently EMI related.
>>
>> Mar  1 07:09:09 localhost kernel: [265922.921985] hub 5-0:1.0: port 1
>> disabled by hub (EMI?), re-enabling...
>>
>> This is very much a possibility because the box is in a high current
>> industrial control panel. That is not an issue because the device
>> automatically reconnects.
>> But after a few day's operation it stops reconnecting and i finally
>> managed to capture the syslog.
>>
>> Mar  1 07:09:09 localhost kernel: [265922.934119] usb 5-1: USB
>> disconnect, device number 83
>> Mar  1 07:09:10 localhost kernel: [265923.245580] usb 5-1: new
>> full-speed USB device number 84 using sw-ohci
>> Mar  1 07:09:10 localhost kernel: [265923.451746] pl2303 5-1:1.0:
>> pl2303 converter detected
>> Mar  1 07:09:10 localhost kernel: [265923.486633] pl2303 5-1:1.0: No
>> more free serial devices
>> Mar  1 07:09:10 localhost kernel: [265923.496483] pl2303: probe of
>> 5-1:1.0 failed with error -5
>> Mar  1 07:09:10 localhost mtp-probe: checking bus 5, device 84:
>> "/sys/devices/platform/sw-ohci.2/usb5/5-1"
>> Mar  1 07:09:10 localhost mtp-probe: bus: 5, device: 84 was not an MTP device
>>
>> The driver issues "No more free serial devices".
>>
>> The two reasons i can see for this are either if the malloc fails (but
>> there's no "out of memory" error) or if minor numbers have exceeded
>> the limit. But the minor is only 84!
>>
>> Any pointers for a solution?
>
> Are you sure you are properly closing up the device node when the
> disconnect happens?  That looks to be the problem here.
>
> thanks,
>
> greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux