001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.transport.serial;
021
022import org.apache.mina.core.session.IoSessionConfig;
023
024/**
025 * An {@link IoSessionConfig} for serial transport type.
026 * All those parameters are extracted from rxtx.org API for more details :
027 * http://www.rxtx.org
028 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
029 */
030public interface SerialSessionConfig extends IoSessionConfig {
031
032    /**
033     * Gets the input buffer size. Note that this method is advisory and the underlying OS
034     * may choose not to report correct values for the buffer size.
035     * @return input buffer size in bytes
036     */
037    int getInputBufferSize();
038
039    /**
040     * Sets the input buffer size. Note that this is advisory and memory availability may
041     * determine the ultimate buffer size used by the driver.
042     * @param bufferSize the buffer size in bytes
043     */
044    void setInputBufferSize(int bufferSize);
045
046    /**
047     * Gets the output buffer size. Note that this method is advisory and the underlying OS
048     * may choose not to report correct values for the buffer size.
049     * @return input buffer size in bytes
050     */
051    int getOutputBufferSize();
052
053    /**
054     * Sets the output buffer size. Note that this is advisory and memory availability may
055     * determine the ultimate buffer size used by the driver.
056     * @param bufferSize the buffer size in bytes
057     */
058    void setOutputBufferSize(int bufferSize);
059
060    /**
061     * Is the low latency mode is enabled.
062     * @return low latency on
063     */
064    boolean isLowLatency();
065
066    /**
067     * Set the low latency mode, be careful it's not supported by all the OS/hardware.
068     * @param lowLatency The low latency mode
069     */
070    void setLowLatency(boolean lowLatency);
071
072    /**
073     * The current receive threshold (-1 if not enabled). Give the value of the current buffer
074     * needed for generate a new frame.
075     * @return the receive threshold in bytes or -1 if disabled
076     */
077    int getReceiveThreshold();
078
079    /**
080     * Set the receive threshold in byte (set it to -1 for disable). The serial port will try to
081     * provide frame of the given minimal byte count. Be careful some devices doesn't support it.
082     * @param bytes minimal amount of byte before producing a new frame, or -1 if disabled
083     */
084    void setReceiveThreshold(int bytes);
085
086}