mirror of
https://github.com/holub/mame
synced 2025-04-25 09:50:04 +03:00
pty: seems ok (linux only)
This commit is contained in:
parent
f8cb153519
commit
898fc7b373
@ -194,6 +194,8 @@ files {
|
||||
MAME_DIR .. "src/emu/ui/imgcntrl.h",
|
||||
MAME_DIR .. "src/emu/ui/info.c",
|
||||
MAME_DIR .. "src/emu/ui/info.h",
|
||||
MAME_DIR .. "src/emu/ui/info_pty.c",
|
||||
MAME_DIR .. "src/emu/ui/info_pty.h",
|
||||
MAME_DIR .. "src/emu/ui/inputmap.c",
|
||||
MAME_DIR .. "src/emu/ui/inputmap.h",
|
||||
MAME_DIR .. "src/emu/ui/selgame.c",
|
||||
|
@ -4,20 +4,18 @@
|
||||
#include <stdio.h>
|
||||
#include "pty.h"
|
||||
|
||||
#define FU_TEST
|
||||
|
||||
static const int TIMER_POLL = 1;
|
||||
|
||||
pseudo_terminal_device::pseudo_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
|
||||
device_t(mconfig, PSEUDO_TERMINAL, "Pseudo terminal", tag, owner, clock, "pseudo_terminal", __FILE__),
|
||||
device_serial_interface(mconfig, *this),
|
||||
device_rs232_port_interface(mconfig, *this),
|
||||
device_serial_interface(mconfig, *this),
|
||||
device_rs232_port_interface(mconfig, *this),
|
||||
device_pty_interface(mconfig, *this),
|
||||
m_rs232_txbaud(*this, "RS232_TXBAUD"),
|
||||
m_rs232_rxbaud(*this, "RS232_RXBAUD"),
|
||||
m_rs232_startbits(*this, "RS232_STARTBITS"),
|
||||
m_rs232_databits(*this, "RS232_DATABITS"),
|
||||
m_rs232_parity(*this, "RS232_PARITY"),
|
||||
m_rs232_txbaud(*this, "RS232_TXBAUD"),
|
||||
m_rs232_rxbaud(*this, "RS232_RXBAUD"),
|
||||
m_rs232_startbits(*this, "RS232_STARTBITS"),
|
||||
m_rs232_databits(*this, "RS232_DATABITS"),
|
||||
m_rs232_parity(*this, "RS232_PARITY"),
|
||||
m_rs232_stopbits(*this, "RS232_STOPBITS"),
|
||||
m_input_count(0),
|
||||
m_input_index(0)
|
||||
@ -26,97 +24,94 @@ pseudo_terminal_device::pseudo_terminal_device(const machine_config &mconfig, co
|
||||
|
||||
WRITE_LINE_MEMBER(pseudo_terminal_device::update_serial)
|
||||
{
|
||||
int startbits = convert_startbits(m_rs232_startbits->read());
|
||||
int databits = convert_databits(m_rs232_databits->read());
|
||||
parity_t parity = convert_parity(m_rs232_parity->read());
|
||||
stop_bits_t stopbits = convert_stopbits(m_rs232_stopbits->read());
|
||||
int startbits = convert_startbits(m_rs232_startbits->read());
|
||||
int databits = convert_databits(m_rs232_databits->read());
|
||||
parity_t parity = convert_parity(m_rs232_parity->read());
|
||||
stop_bits_t stopbits = convert_stopbits(m_rs232_stopbits->read());
|
||||
|
||||
set_data_frame(startbits, databits, parity, stopbits);
|
||||
set_data_frame(startbits, databits, parity, stopbits);
|
||||
|
||||
int txbaud = convert_baud(m_rs232_txbaud->read());
|
||||
set_tra_rate(txbaud);
|
||||
int txbaud = convert_baud(m_rs232_txbaud->read());
|
||||
set_tra_rate(txbaud);
|
||||
|
||||
int rxbaud = convert_baud(m_rs232_rxbaud->read());
|
||||
set_rcv_rate(rxbaud);
|
||||
int rxbaud = convert_baud(m_rs232_rxbaud->read());
|
||||
set_rcv_rate(rxbaud);
|
||||
|
||||
output_rxd(1);
|
||||
output_rxd(1);
|
||||
|
||||
// TODO: make this configurable
|
||||
output_dcd(0);
|
||||
output_dsr(0);
|
||||
output_cts(0);
|
||||
// TODO: make this configurable
|
||||
output_dcd(0);
|
||||
output_dsr(0);
|
||||
output_cts(0);
|
||||
}
|
||||
|
||||
static INPUT_PORTS_START(pseudo_terminal)
|
||||
MCFG_RS232_BAUD("RS232_TXBAUD", RS232_BAUD_9600, "TX Baud", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_BAUD("RS232_RXBAUD", RS232_BAUD_9600, "RX Baud", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_STARTBITS("RS232_STARTBITS", RS232_STARTBITS_1, "Start Bits", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_DATABITS("RS232_DATABITS", RS232_DATABITS_8, "Data Bits", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_PARITY("RS232_PARITY", RS232_PARITY_NONE, "Parity", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_STOPBITS("RS232_STOPBITS", RS232_STOPBITS_1, "Stop Bits", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_BAUD("RS232_TXBAUD", RS232_BAUD_9600, "TX Baud", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_BAUD("RS232_RXBAUD", RS232_BAUD_9600, "RX Baud", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_STARTBITS("RS232_STARTBITS", RS232_STARTBITS_1, "Start Bits", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_DATABITS("RS232_DATABITS", RS232_DATABITS_8, "Data Bits", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_PARITY("RS232_PARITY", RS232_PARITY_NONE, "Parity", pseudo_terminal_device, update_serial)
|
||||
MCFG_RS232_STOPBITS("RS232_STOPBITS", RS232_STOPBITS_1, "Stop Bits", pseudo_terminal_device, update_serial)
|
||||
INPUT_PORTS_END
|
||||
|
||||
ioport_constructor pseudo_terminal_device::device_input_ports() const
|
||||
{
|
||||
return INPUT_PORTS_NAME(pseudo_terminal);
|
||||
return INPUT_PORTS_NAME(pseudo_terminal);
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::device_start()
|
||||
{
|
||||
m_timer_poll = timer_alloc(TIMER_POLL);
|
||||
m_timer_poll = timer_alloc(TIMER_POLL);
|
||||
|
||||
if (open()) {
|
||||
#ifdef FU_TEST
|
||||
printf("slave PTY = %s\n" , slave_name());
|
||||
#endif
|
||||
} else {
|
||||
#ifdef FU_TEST
|
||||
puts("Opening PTY failed");
|
||||
#endif
|
||||
}
|
||||
open();
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::device_stop()
|
||||
{
|
||||
close();
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::device_reset()
|
||||
{
|
||||
update_serial(0);
|
||||
update_serial(0);
|
||||
queue();
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
|
||||
{
|
||||
switch (id)
|
||||
{
|
||||
case TIMER_POLL:
|
||||
queue();
|
||||
break;
|
||||
switch (id)
|
||||
{
|
||||
case TIMER_POLL:
|
||||
queue();
|
||||
break;
|
||||
|
||||
default:
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
default:
|
||||
device_serial_interface::device_timer(timer, id, param, ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::tra_callback()
|
||||
{
|
||||
output_rxd(transmit_register_get_data_bit());
|
||||
output_rxd(transmit_register_get_data_bit());
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::tra_complete()
|
||||
{
|
||||
queue();
|
||||
queue();
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::rcv_complete()
|
||||
{
|
||||
receive_register_extract();
|
||||
receive_register_extract();
|
||||
write(get_received_char());
|
||||
}
|
||||
|
||||
void pseudo_terminal_device::queue(void)
|
||||
{
|
||||
if (is_transmit_register_empty())
|
||||
{
|
||||
if (m_input_index == m_input_count)
|
||||
{
|
||||
if (is_transmit_register_empty())
|
||||
{
|
||||
if (m_input_index == m_input_count)
|
||||
{
|
||||
m_input_index = 0;
|
||||
int tmp = read(m_input_buffer , sizeof(m_input_buffer));
|
||||
if (tmp > 0) {
|
||||
@ -124,25 +119,20 @@ void pseudo_terminal_device::queue(void)
|
||||
} else {
|
||||
m_input_count = 0;
|
||||
}
|
||||
#ifdef FU_TEST
|
||||
if (m_input_count) {
|
||||
printf("read %u\n" , m_input_count);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
if (m_input_count != 0)
|
||||
{
|
||||
transmit_register_setup(m_input_buffer[ m_input_index++ ]);
|
||||
if (m_input_count != 0)
|
||||
{
|
||||
transmit_register_setup(m_input_buffer[ m_input_index++ ]);
|
||||
|
||||
m_timer_poll->adjust(attotime::never);
|
||||
}
|
||||
else
|
||||
{
|
||||
int txbaud = convert_baud(m_rs232_txbaud->read());
|
||||
m_timer_poll->adjust(attotime::from_hz(txbaud));
|
||||
}
|
||||
}
|
||||
m_timer_poll->adjust(attotime::never);
|
||||
}
|
||||
else
|
||||
{
|
||||
int txbaud = convert_baud(m_rs232_txbaud->read());
|
||||
m_timer_poll->adjust(attotime::from_hz(txbaud));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const device_type PSEUDO_TERMINAL = &device_creator<pseudo_terminal_device>;
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
protected:
|
||||
virtual ioport_constructor device_input_ports() const;
|
||||
virtual void device_start();
|
||||
virtual void device_stop();
|
||||
virtual void device_reset();
|
||||
virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
|
||||
|
||||
|
@ -48,6 +48,11 @@ void device_pty_interface::close(void)
|
||||
}
|
||||
}
|
||||
|
||||
bool device_pty_interface::is_open(void) const
|
||||
{
|
||||
return m_opened;
|
||||
}
|
||||
|
||||
ssize_t device_pty_interface::read(UINT8 *rx_chars , size_t count)
|
||||
{
|
||||
UINT32 actual_bytes;
|
||||
|
@ -27,6 +27,8 @@ public:
|
||||
bool open(void);
|
||||
void close(void);
|
||||
|
||||
bool is_open(void) const;
|
||||
|
||||
ssize_t read(UINT8 *rx_chars , size_t count);
|
||||
void write(UINT8 tx_char);
|
||||
|
||||
|
44
src/emu/ui/info_pty.c
Normal file
44
src/emu/ui/info_pty.c
Normal file
@ -0,0 +1,44 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:F.Ulivi
|
||||
/***************************************************************************
|
||||
|
||||
ui/info_pty.c
|
||||
|
||||
Information screen on pseudo terminals
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "emu.h"
|
||||
#include "ui/menu.h"
|
||||
#include "ui/info_pty.h"
|
||||
|
||||
ui_menu_pty_info::ui_menu_pty_info(running_machine &machine, render_container *container) :
|
||||
ui_menu(machine, container)
|
||||
{
|
||||
}
|
||||
|
||||
ui_menu_pty_info::~ui_menu_pty_info()
|
||||
{
|
||||
}
|
||||
|
||||
void ui_menu_pty_info::populate()
|
||||
{
|
||||
item_append("Pseudo terminals", NULL, MENU_FLAG_DISABLE, NULL);
|
||||
item_append("", NULL, MENU_FLAG_DISABLE, NULL);
|
||||
|
||||
pty_interface_iterator iter(machine().root_device());
|
||||
for (device_pty_interface *pty = iter.first(); pty != NULL; pty = iter.next()) {
|
||||
const char *port_name = pty->device().owner()->tag() + 1;
|
||||
if (pty->is_open()) {
|
||||
item_append(port_name , pty->slave_name() , MENU_FLAG_DISABLE , NULL);
|
||||
} else {
|
||||
item_append(port_name , "[failed]" , MENU_FLAG_DISABLE , NULL);
|
||||
}
|
||||
item_append("", NULL, MENU_FLAG_DISABLE, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void ui_menu_pty_info::handle()
|
||||
{
|
||||
process(0);
|
||||
}
|
24
src/emu/ui/info_pty.h
Normal file
24
src/emu/ui/info_pty.h
Normal file
@ -0,0 +1,24 @@
|
||||
// license:BSD-3-Clause
|
||||
// copyright-holders:F.Ulivi
|
||||
/***************************************************************************
|
||||
|
||||
ui/info_pty.h
|
||||
|
||||
Information screen on pseudo terminals
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef __UI_INFO_PTY_H__
|
||||
#define __UI_INFO_PTY_H__
|
||||
|
||||
class ui_menu_pty_info : public ui_menu {
|
||||
public:
|
||||
ui_menu_pty_info(running_machine &machine, render_container *container);
|
||||
virtual ~ui_menu_pty_info();
|
||||
virtual void populate();
|
||||
virtual void handle();
|
||||
};
|
||||
|
||||
#endif // __UI_INFO_PTY_H__
|
@ -22,6 +22,7 @@
|
||||
#include "ui/barcode.h"
|
||||
#include "ui/cheatopt.h"
|
||||
#include "ui/info.h"
|
||||
#include "ui/info_pty.h"
|
||||
#include "ui/inputmap.h"
|
||||
#include "ui/mainmenu.h"
|
||||
#include "ui/miscmenu.h"
|
||||
@ -90,6 +91,10 @@ void ui_menu_main::populate()
|
||||
item_append("Tape Control", NULL, 0, (void *)TAPE_CONTROL);
|
||||
}
|
||||
|
||||
pty_interface_iterator ptyiter(machine().root_device());
|
||||
if (ptyiter.first() != NULL) {
|
||||
item_append("Pseudo terminals", NULL, 0, (void *)PTY_INFO);
|
||||
}
|
||||
if (machine().ioport().has_bioses())
|
||||
item_append("Bios Selection", NULL, 0, (void *)BIOS_SELECTION);
|
||||
|
||||
@ -191,6 +196,10 @@ void ui_menu_main::handle()
|
||||
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_tape_control(machine(), container, NULL)));
|
||||
break;
|
||||
|
||||
case PTY_INFO:
|
||||
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_pty_info(machine(), container)));
|
||||
break;
|
||||
|
||||
case SLOT_DEVICES:
|
||||
ui_menu::stack_push(auto_alloc_clear(machine(), ui_menu_slot_devices(machine(), container)));
|
||||
break;
|
||||
|
@ -44,7 +44,8 @@ private:
|
||||
CHEAT,
|
||||
SELECT_GAME,
|
||||
BIOS_SELECTION,
|
||||
BARCODE_READ
|
||||
BARCODE_READ,
|
||||
PTY_INFO
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user