×

INDI Library v2.0.6 is Released (02 Feb 2024)

Bi-monthly release with minor bug fixes and improvements

Update port or baud rate

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

One more thing - tried different things to save the configuration for the port, in my case rfcomm1. Attchached the .cpp and .h file - but that did not work.

I hardly dare to ask again Paul - but in case weather conditions are again unfavorable, could you have a look? :-)
5 years 1 month ago #34949
Attachments:

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

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Must be a conflict between the built-in save-routine and your declarations. (Did you use the "save" button in the options panel?

So if you want to save your extra items, try this:

in the .h file change:
virtual bool saveConfigItems(FILE *fp);
to
virtual bool saveConfigItems(FILE * fp) override;

in the c++ code add just before line 320:

INDI::Focuser::saveConfigItems(fp);

Rgrds,

Paul
The following user(s) said Thank You: Helge
5 years 1 month ago #34961

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

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Paul, it works, I am really pleased - thank you once again!!

Attached just a picture of the TIC825 with the HC-05 module.
Last edit: 5 years 1 month ago by Helge.
5 years 1 month ago #34979
Attachments:

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

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

That looks very good. (got my tic yesterday and now trying to make a driver that talks directly to the tic over the usb port. Still have to decide if I go for that or put an arduino nano in between and make a moonlite compatible protocol) If I do direct USB the board is soo small it can be fixed to the motor (so no risc of blowing the 8825 driver when connecting/disconnecting the motor when the board is powered)

Paul
5 years 1 month ago #34982

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

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi, in principle, the focuser works as it is supposed to, but upon connection, I am having difficulties to get the stepper going (in the Ticgui I am getting an error message, which says that the stepper has been de-energized because of a “safe start violation error“. Once clicking on the resume button, it is all working.

I started to compare the code example on the Pololu website, to compare it to my driver. Thanks to the incredible support of Paul, I am now leveraging on the INDI API. Practically, there is a function called „handshake“, which I assumes opens up the serial port. Unfortunately, I do not find anything in the documentation what is exactly happening code-wise, for instance is something like this implemented, or any options set, or is there e.g. a tcflush command applied?
fd = open(device, O_RDWR | O_NOCTTY);

Many thanks in advance for any support!

Helge
5 years 3 weeks ago #35846

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

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Hi,

the handshake function will not be usefull here. It is used to decide if you are talking to the correct device. (send command, get response and check, return true if ok)

What you need to do is energize the motor. (www.pololu.com/docs/0J71/8#cmd-energize)
This is a quick command and only requiers one byte to send (command code)

Had the same problems in my implementation, and solved it by doing this. (But since I talk directly to the USB i use the API commands, not the serial commands)

After that you will need to think about the position of focuser and steppermotor. If you don't take power of the motor stepper position will be were you left it. When power/off power/on it will probably be 0 (also seen negative values) so I am still thinking about a sort of calibration routine. (probably with a limit switch and homing mode to calibrate at absolute 0) ....

Now I am struggling to make an ASCOM driver :-( How much I like Indi, can't live without Win for fast usb connection. And my main area is solar astrophotography were I need the fastest USB camera rate I can get. (And Linux, or the drivers could not coop with that. )

This is my current Connect, you will need to translate Tic commands to their serial equivalent

bool TicFocusUsb::Connect()
{
DEBUGF(INDI::Logger::DBG_SESSION, "TiFocus searching for :%s:", desired_serial_number);
std::vector<tic::device> list = tic::list_connected_devices();
// Iterate through the list and select one device.
for (const tic::device & device : list)
{
DEBUGF(INDI::Logger::DBG_SESSION, "TicFocus has got:%s:", device.get_serial_number().c_str());
if (strcmp(desired_serial_number, "Any") &&
(strcmp(desired_serial_number, device.get_serial_number().c_str())))

// Found a device with the wrong serial number, so continue on to
// the next device in the list.
continue;
ticDev = tic::handle(device);
tic::variables vars = ticDev.get_variables();

currentPosition = vars.get_current_position();

if (currentPosition < 0) ticDev.halt_and_set_position(0);
curStepMode =vars.get_step_mode();
ticDev.set_max_speed(500000000);


ticDev.energize();
SetTimer(POLLMS);
ticDev.go_home(0);
return true;
}
DEBUG(INDI::Logger::DBG_SESSION, "No device found");
return IPS_IDLE;
}


Regards,

Paul
5 years 3 weeks ago #35852

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

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Paul,

I actually tried already whether it can be addressed by sending the „energize“ command. I wonder if it might have been wrong to send this command within the „handshake“ function, in-between the {} brackets?

Still wonder where in the code the port is actually opened, if this is not taking place during the handshake, how does the driver know the value for PortFD, where are the options set, as it happens within the Pololu code example - or is it technically not required. Probably I am ignoring something very basic.

Unfortunately I have no experience with ASCOM, so I cannot help. Amazing to here about the difference in speed, depending on OS. Hope you soon find a solution!

Best, Helge
5 years 3 weeks ago #35862

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

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Hi,

"Still wonder where in the code the port is actually opened"

Well hidden in the code. Look at indifocuser.cpp in the libs/indibase folder. That contains the base focuser class which you extends (? if that is the correct word for it) That inludes things from the connectionplugins folder including handling serial io.

I was wrong in my previous answer. Handshake should be the place to send the energize command in your case. (Since my version does not use serial or network, I had to re-impement the Connect method where I placed the code)

Regards,

Paul

PS: look at a few sources of other drivers, always a good source to see how these implemented some functions.
(and got a basic ASCOM driver working yesterday)
5 years 3 weeks ago #35887

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

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Paul,

Congrats on the ASCOM driver - would be curious to learn more about your project at some stage!

Thanks for pointing me to the github libraries. I found here in line 242 and following what I was looking for, especially line 255 which seems to be the one opening the port.

github.com/indilib/indi/blob/master/libi...nplugins/ttybase.cpp

But how does it work? When „handshake“ is called, what is the „chain of events“ that the above lines of code are executed? I am missing the kind of conceptual link. I have already been reading some tutorials about c++ programming and have some basic ideas about the concept of classes, but this is beyond my skills, but would be very keen to understand the logic!

I also looked at some other drivers, like onstep, smartfocus, nstep and can see that they all use the handshake - in that sense they are similar.

Best, Helge
5 years 3 weeks ago #35913

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

ttybase.cpp is not used in the current code. It is a proposal to move to a better more customizable solution than the current indicom implementation.

Last week, I started adding a few Skeleton drivers that you can modify and base your drivers on. Right now there are focuser and mount drivers, but I should add more with time. It is a great starting template for developing new drivers.

For serial drivers, the process is simple as you do not need to handle the serial connection yourself. After the user presses "Connect", the INDI::Focuser class establishes the connection and then call Handshake(). So at this point, you need to make sure you can communicate with the focuser. By now, you have a valid PortFD file descriptor that you can use with indicom's tty_XXX functions. However, I added a function called sendCommand that is better be used instead of direct tty_read or tty_write functions. Now I use this function in all the serial drivers since it makes things so much easier.
The following user(s) said Thank You: Helge
5 years 3 weeks ago #35943

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

  • Posts: 220
  • Thank you received: 27

Replied by PDB on topic Update port or baud rate

Hello Jasem,

will give these new skeletons a try (when I have time ....). That is probably an easier way to start a new driver than starting from some existing thing and forgetting to clean out not neededcode.

Paul
5 years 3 weeks ago #35944

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

  • Posts: 281
  • Thank you received: 29

Replied by Helge on topic Update port or baud rate

Hi Jasem,

Many thanks for the explanation and for providing the mentioned Skeleton drivers!

In my reference code for the Pololu stepper controller, there are a couple of configurations defined, for instance:

www.pololu.com/docs/0J71/12.5

// Turn off any options that might interfere with our ability to send and
// receive raw binary bytes.
options.c_iflag &= ~(INLCR | IGNCR | ICRNL | IXON | IXOFF);
options.c_oflag &= ~(ONLCR | OCRNL);
options.c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN);

// Set up timeouts: Calls to read() will return as soon as there is
// at least one byte available or when 100 ms has passed.
options.c_cc[VTIME] = 1;
options.c_cc[VMIN] = 0;

Are similar settings also initiated in the course of establishing the connection (upon pressing the connect button), or do I have to take of that in the driver myself?

Best, Helge
5 years 3 weeks ago #35983

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

Time to create page: 0.667 seconds