OK, I was able to create the PtTty using PtCreateWidget (see code below).
A file descriptor is returned and printed, (and the TTY appears in my GUI)
but the returned path info is not a recognizable string.
What did I do wrong?
-GF
char tty_name [20];
int *tty_fd;
int
main_setup( PtWidget_t *link_instance, ApInfo_t *apinfo, PtCallbackInfo_t
*cbinfo )
{
PtArg_t args [2];
/* Attach to unused pseudo-tty device */
strcpy (tty_name, “/dev”);
PtSetArg (&args[0], Pt_ARG_TTY_PSEUDO, tty_name, strlen (tty_name));
tty_widget = PtCreateWidget (PtTty, NULL, 1, args);
if (tty_widget == NULL)
{
fprintf (stderr, “Error: Failed to create TTY widget. \n”);
return (Pt_CONTINUE);
}
/* Attach succeeded, so get file descriptor and path. */
PtSetArg (&args[0], Pt_ARG_TTY_MFD, &tty_fd, 1);
PtSetArg (&args[1], Pt_ARG_TTY_PATH, tty_name, 20);
PtGetResources (tty_widget, 2, args);
if (*tty_fd == -1)
{
fprintf (stderr, “Error: No TTY Device attached! \n”);
}
else
{
fprintf (stdout, “TTY Device file descriptor %d\n”, &tty_fd);
fprintf (stdout, “TTY Device path: %s\n”, tty_name);
}
return( Pt_CONTINUE );
}
output:
TTY Device file descriptor 1914268
TTY Device path: