×
INDI Library v1.8.5 Released (19 Apr 2020)

April 2020 release of INDI Library v1.8.5 introduces new drivers while providing fixes and improvements to existing devices and core framework.

Moonlite focuser doesn't move with 3.4.3 KStars MacOS

2 months 2 weeks ago
rickbassham
Junior Boarder
Junior Boarder
Posts: 31
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54850
Yeah, I'm trying to test now, but looking at Moonlite::sendCommand, it calls tcflush(PortFD, TCIOFLUSH) immediately before calling tty_write_string. tcflush is going to discard all unsent and unread data in the serial port at that moment, and since we are immediately calling tty_write back to back, I don't think the underlying serial port has actually sent the data yet. I think we need to add tcdrain in indicom.c. I'll give it a test as soon as I get it to compile on my Mac.

Gayle H Riggsbee Observatory
Charlotte Amateur Astronomers Club

CGX
AT72EDII w/Homemade Moonlite Compatible Arduino Focuser
AT8RC w/Moonlite CSL 2.5" w/Moonlite Stepper v3
ZWO ASI1600MC-Pro
ZWO ASI1600MM-Pro
ZWO ASI174MM-Mini
ZWO OAG
ZWO EFW
AT2FF

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
dallmon
Senior Boarder
Senior Boarder
Posts: 52
More
Topic Author
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54857
I just commented out the tcflush(PortFD, ...) to test it and it solved the problem. I don't know if that is the solution, but it is the problem.

Thanks,
Dave

Dave Allmon

12" LX600
SBIG STF-8300EN
Raspberry Pi 4 Indi server
Mac Pro client

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
knro
Administrator
Administrator
Posts: 8213
Karma: 51
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54859
So Mac flushes :SN because :FG is called soon after it? What if you replace TCIOFLUSH with TCIFLUSH ?

Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
rickbassham
Junior Boarder
Junior Boarder
Posts: 31
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54861
That will probably also work. I'm willing to bet there's just a minor difference in the serial implementation in the linux kernel vs the xnu kernel.

Gayle H Riggsbee Observatory
Charlotte Amateur Astronomers Club

CGX
AT72EDII w/Homemade Moonlite Compatible Arduino Focuser
AT8RC w/Moonlite CSL 2.5" w/Moonlite Stepper v3
ZWO ASI1600MC-Pro
ZWO ASI1600MM-Pro
ZWO ASI174MM-Mini
ZWO OAG
ZWO EFW
AT2FF

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
ChrisRowland
Platinum Boarder
Platinum Boarder
Posts: 517
Karma: 9
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54863
Calling tcflush just before writing data is just about standard in all drivers. However in the majority of cases sending a command is followed by reading a response.
But some moonlite commands don't return a response and in this case the driver doesn't do the read so the next tty command is the flush at the start of the next command.

At present the moonlite sendCommand has:

if (res == nullptr)
return true;

Perhaps this should be:
if (res == nullptr)
{
tcdrain(PortFD);
return true;
}

It's surprising this hasn't been more of a problem, the send takes milliseconds while the processor is working in microseconds.

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
rickbassham
Junior Boarder
Junior Boarder
Posts: 31
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54865
Yeah, a lot of serial code I've used in the past just always put a tcdrain after a write. With the amount of data any of our drivers send, the delay caused by adding tcdrain should be very short, single digit milliseconds in most cases. Adding it to the tty_write function in indicom.c may prevent these kinds of issues from cropping up in all other serial drivers as well.

Gayle H Riggsbee Observatory
Charlotte Amateur Astronomers Club

CGX
AT72EDII w/Homemade Moonlite Compatible Arduino Focuser
AT8RC w/Moonlite CSL 2.5" w/Moonlite Stepper v3
ZWO ASI1600MC-Pro
ZWO ASI1600MM-Pro
ZWO ASI174MM-Mini
ZWO OAG
ZWO EFW
AT2FF

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
dallmon
Senior Boarder
Senior Boarder
Posts: 52
More
Topic Author
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54870
tcflush(PortFD, TCIFLUSH);

also works.

Dave Allmon

12" LX600
SBIG STF-8300EN
Raspberry Pi 4 Indi server
Mac Pro client

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
knro
Administrator
Administrator
Posts: 8213
Karma: 51
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54871
How about the tcdrain when res == nullptr as Chris suggested above? If that works, I'll change it across all drivers.

Jasem Mutlaq
Support INDI & Ekos; Get StellarMate Astrophotography Gadget.
How to Submit Logs when you have problems?
Add your observatory info

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
dallmon
Senior Boarder
Senior Boarder
Posts: 52
More
Topic Author
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54872
That works as well. With the original tcflush:
tcflush(PortFD, TCIOFLUSH); 
Modifying the code to drain:
    if (res == nullptr)
    {
        tcdrain(PortFD);
        return true;
    }
fixes the problem.

Dave Allmon

12" LX600
SBIG STF-8300EN
Raspberry Pi 4 Indi server
Mac Pro client

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago 2 months 2 weeks ago by dallmon.
dallmon
Senior Boarder
Senior Boarder
Posts: 52
More
Topic Author
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54874
To be clear, this change was made to the indi_moonlite_focus module only. (moonlite.cpp)

Dave Allmon

12" LX600
SBIG STF-8300EN
Raspberry Pi 4 Indi server
Mac Pro client

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
ChrisRowland
Platinum Boarder
Platinum Boarder
Posts: 517
Karma: 9
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54879
The Moonlite DRO driver will also need this.

There may be other drivers of all sorts which don't always return a serial response to a command.

I would be a bit nervous about adding this in indicom.c for a couple of reasons:
QtCreator reports over 200 issues with indicom.c, half of which are errors.
There's no knowing how drivers use the tty commands in indicom.

It isn't usually a problem because if a driver expects a response the tty_read will start by waiting for the command to finish being sent, then for the hardware to process the command and send the reply.

Please Log in or Create an account to join the conversation.

2 months 2 weeks ago
rickbassham
Junior Boarder
Junior Boarder
Posts: 31
More
Moonlite focuser doesn't move with 3.4.3 KStars MacOS #54880
Fair enough. Definitely safer to only add it to the Moonlite drivers, or others that do multiple writes in quick succession.

Gayle H Riggsbee Observatory
Charlotte Amateur Astronomers Club

CGX
AT72EDII w/Homemade Moonlite Compatible Arduino Focuser
AT8RC w/Moonlite CSL 2.5" w/Moonlite Stepper v3
ZWO ASI1600MC-Pro
ZWO ASI1600MM-Pro
ZWO ASI174MM-Mini
ZWO OAG
ZWO EFW
AT2FF

Please Log in or Create an account to join the conversation.

Time to create page: 0.951 seconds