2008-04-14 15:12:55 +00:00
|
|
|
//============================================================================
|
|
|
|
//
|
|
|
|
// SSSS tt lll lll
|
|
|
|
// SS SS tt ll ll
|
|
|
|
// SS tttttt eeee ll ll aaaa
|
|
|
|
// SSSS tt ee ee ll ll aa
|
|
|
|
// SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator"
|
|
|
|
// SS SS tt ee ll ll aa aa
|
|
|
|
// SSSS ttt eeeee llll llll aaaaa
|
|
|
|
//
|
2015-01-01 03:49:32 +00:00
|
|
|
// Copyright (c) 1995-2015 by Bradford W. Mott, Stephen Anthony
|
2010-04-10 21:37:23 +00:00
|
|
|
// and the Stella Team
|
2008-04-14 15:12:55 +00:00
|
|
|
//
|
2010-01-10 03:23:32 +00:00
|
|
|
// See the file "License.txt" for information on usage and redistribution of
|
2008-04-14 15:12:55 +00:00
|
|
|
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
|
|
|
//
|
2009-05-13 13:55:40 +00:00
|
|
|
// $Id$
|
2008-04-14 15:12:55 +00:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/errno.h>
|
|
|
|
#include <sys/termios.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/filio.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include "SerialPortMACOSX.hxx"
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
SerialPortMACOSX::SerialPortMACOSX()
|
|
|
|
: SerialPort(),
|
|
|
|
myHandle(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
SerialPortMACOSX::~SerialPortMACOSX()
|
|
|
|
{
|
First pass at adding a cart-specific bankswitch/info tab to the
debugger. In the process, I had to spend several days extending
the UI/dialog class to actually contain multiple tabs. This was
harder than expected, and it still isn't quite finished. In many
ways, we're beginning to reach the limits of the current code; it
was never designed for a full-fledged, graphically rich UI.
For now the tab is empty, but eventually it will contain general
info about the ROM bankswitch type (size, virtual layout, etc),
but also cart-specific info, including the ability to change
banks, which can be vary greatly among the different schemes.
Eventually, it may even allow to see/modify very cart-specific
info (like display RAM in DPC, etc).
Better handle errors in opening the serial port (AtariVox support)
for Windows and OSX.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2678 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2013-03-31 00:10:05 +00:00
|
|
|
closePort();
|
2008-04-14 15:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool SerialPortMACOSX::openPort(const string& device)
|
|
|
|
{
|
|
|
|
myHandle = open(device.c_str(), O_RDWR | O_NOCTTY | O_NONBLOCK);
|
|
|
|
if(myHandle <= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
struct termios termios;
|
2008-04-14 18:50:35 +00:00
|
|
|
tcgetattr(myHandle, &termios);
|
2008-04-14 15:12:55 +00:00
|
|
|
memset(&termios, 0, sizeof(struct termios));
|
2008-04-14 18:50:35 +00:00
|
|
|
cfmakeraw(&termios);
|
|
|
|
cfsetspeed(&termios, 19200); // change to 19200 baud
|
|
|
|
termios.c_cflag = CREAD | CLOCAL; // turn on READ and ignore modem control lines
|
|
|
|
termios.c_cflag |= CS8; // 8 bit
|
|
|
|
termios.c_cflag |= CDTR_IFLOW; // inbound DTR
|
2008-04-14 15:12:55 +00:00
|
|
|
tcsetattr(myHandle, TCSANOW, &termios);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
void SerialPortMACOSX::closePort()
|
|
|
|
{
|
|
|
|
if(myHandle)
|
First pass at adding a cart-specific bankswitch/info tab to the
debugger. In the process, I had to spend several days extending
the UI/dialog class to actually contain multiple tabs. This was
harder than expected, and it still isn't quite finished. In many
ways, we're beginning to reach the limits of the current code; it
was never designed for a full-fledged, graphically rich UI.
For now the tab is empty, but eventually it will contain general
info about the ROM bankswitch type (size, virtual layout, etc),
but also cart-specific info, including the ability to change
banks, which can be vary greatly among the different schemes.
Eventually, it may even allow to see/modify very cart-specific
info (like display RAM in DPC, etc).
Better handle errors in opening the serial port (AtariVox support)
for Windows and OSX.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2678 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2013-03-31 00:10:05 +00:00
|
|
|
{
|
2008-04-14 15:12:55 +00:00
|
|
|
close(myHandle);
|
First pass at adding a cart-specific bankswitch/info tab to the
debugger. In the process, I had to spend several days extending
the UI/dialog class to actually contain multiple tabs. This was
harder than expected, and it still isn't quite finished. In many
ways, we're beginning to reach the limits of the current code; it
was never designed for a full-fledged, graphically rich UI.
For now the tab is empty, but eventually it will contain general
info about the ROM bankswitch type (size, virtual layout, etc),
but also cart-specific info, including the ability to change
banks, which can be vary greatly among the different schemes.
Eventually, it may even allow to see/modify very cart-specific
info (like display RAM in DPC, etc).
Better handle errors in opening the serial port (AtariVox support)
for Windows and OSX.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@2678 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
2013-03-31 00:10:05 +00:00
|
|
|
myHandle = 0;
|
|
|
|
}
|
2008-04-14 15:12:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
bool SerialPortMACOSX::writeByte(const uInt8* data)
|
|
|
|
{
|
|
|
|
if(myHandle)
|
|
|
|
{
|
|
|
|
// cerr << "SerialPortMACOSX::writeByte " << (int)(*data) << endl;
|
|
|
|
return write(myHandle, data, 1) == 1;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|