2

Has anybody successfully used the pps_gen_parport kernel module to generate PPS on a PC's printer output port?

The module has been marked as broken almost since it appeared in the kernel at 2.6.38, on account of a potential lockup problem. However there are a couple of unapplied patches which (a) allow the polarity of the signal to be specified and (b) in principle fix the lockup problem.

https://lore.kernel.org/patchwork/patch/760701/

https://lkml.org/lkml/2011/2/18/310

https://lore.kernel.org/patchwork/patch/760699/

With the patches applied, I am able to build the module on x86_64 4.19.0 (Debian) using DKMS, and am able to run it without- in the short term at least- lockups.

With debugging messages, I can see that the code is running over the system call that should be writing to the parallel port (specifically, pulsing the strobe signal) but an attached logic analyzer shows nothing happening. I've tried running a slightly older version of the code on an old laptop with limited success.

This from https://github.com/torvalds/linux/blob/master/drivers/pps/generators/pps_gen_parport.c

    /* busy loop until the time is right for an assert edge */
    do {
        ktime_get_real_ts64(&ts2);
    } while (expire_time.tv_sec == ts2.tv_sec && ts2.tv_nsec < lim);

// Debugging output here is successful

    /* set the signal */
    port = dev->pardev->port;
    port->ops->write_control(port, SIGNAL); // Appears to have no effect

// Debugging output here is successful

    /* busy loop until the time is right for a clear edge */
    lim = NSEC_PER_SEC - dev->port_write_time;
    do {
        ktime_get_real_ts64(&ts2);
    } while (expire_time.tv_sec == ts2.tv_sec && ts2.tv_nsec < lim);

I've blacklisted the lp module so that pps_gen_parport can have exclusive access to the device, hence

# modprobe pps_gen_parport
# lsmod | grep par
pps_gen_parport        16384  0
parport_pc             32768  1
parport                57344  3 parport_pc,ppdev,pps_gen_parport

# dmesg -e
[ +11.585790] pps_gen_parport: parallel port PPS signal generator
[  +0.000133] pps_gen_parport: attached to parport0
[  +0.000049] pps_gen_parport: port write takes 1429ns
[Apr28 17:58] pps_gen_parport: we are late this time 1619629128.999968656
[Apr28 17:59] pps_gen_parport: we are late this time 1619629141.999983670

The object of the exercise is to compare PPS output from the computer with PPS signals from other equipment, so that I can see what latency to assume when the computer is reporting timed input events.

It might just be that I've made some silly mistake with what modules should be in memory etc.

I've uploaded the code to https://github.com/MarkMLl/pps_gen_parport for discussion purposes.

Is anybody sufficiently familiar with this area that they can make any suggestions?

0

You must log in to answer this question.

Browse other questions tagged .