jSerialComm/src/main/c/OSX/OSXHelperFunctions.c

73 lines
1.5 KiB
C

/*
* OSXHelperFunctions.c
*
* Created on: Jul 1, 2015
* Last Updated on: Mar 25, 2016
* Author: Will Hedgecock
*
* Copyright (C) 2012-2018 Fazecast, Inc.
*
* This file is part of jSerialComm.
*
* jSerialComm is free software: you can redistribute it and/or modify
* it under the terms of either the Apache Software License, version 2, or
* the GNU Lesser General Public License as published by the Free Software
* Foundation, version 3 or above.
*
* jSerialComm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of both the GNU Lesser General Public
* License and the Apache Software License along with jSerialComm. If not,
* see <http://www.gnu.org/licenses/> and <http://www.apache.org/licenses/>.
*/
#ifdef __APPLE__
#include <sys/types.h>
#include <fcntl.h>
#include "OSXHelperFunctions.h"
speed_t getBaudRateCode(speed_t baudRate)
{
switch (baudRate)
{
case 50:
return B50;
case 75:
return B75;
case 110:
return B110;
case 134:
return B134;
case 150:
return B150;
case 200:
return B200;
case 300:
return B300;
case 600:
return B600;
case 1200:
return B1200;
case 1800:
return B1800;
case 2400:
return B2400;
case 4800:
return B4800;
case 9600:
return B9600;
case 19200:
return B19200;
case 38400:
return B38400;
default:
return 0;
}
return 0;
}
#endif