~ubuntu-branches/debian/jessie/linpsk/jessie

« back to all changes in this revision

Viewing changes to linpsk/checkcom.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Hamish Moffatt
  • Date: 2005-04-10 18:17:27 UTC
  • mfrom: (1.1.1 upstream) (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050410181727-3l9dnfg0sp7bhk13
Tags: 0.8.1-1
* New upstream release 0.8.1
  * Modified upstream configure.in to support FHS-compliant Qt
    installation! (ie /usr/include/qt3, not /usr/lib/qt3/include) :-(
  * Re-autotools with autoconf2.59 and automake-1.9
* linpsk is no longer a Debian-native package (dsc/tar.gz)
* Now maintained by the debian-hams group
* Switch to debhelper 4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
                          checkcom.cpp  -  description
3
 
                             -------------------
4
 
    begin                : Fri Apr 21 2000
5
 
    copyright            : (C) 2000 by Volker Schroer
6
 
    email                : DL1KSV@gmx.de
7
 
 ***************************************************************************/
8
 
 
9
 
/***************************************************************************
10
 
 *                                                                         *
11
 
 *   This program is free software; you can redistribute it and/or modify  *
12
 
 *   it under the terms of the GNU General Public License as published by  *
13
 
 *   the Free Software Foundation; either version 2 of the License, or     *
14
 
 *   (at your option) any later version.                                   *
15
 
 *    based on the work of  Moe Wheatly, AE4JY                             *  
16
 
 ***************************************************************************/
17
 
 
18
 
#include "checkcom.h"
19
 
 
20
 
int getVolume(int);
21
 
 
22
 
bool checkcom(const char* s)
23
 
{
24
 
 
25
 
int fd;
26
 
 
27
 
struct serial_struct serinfo;
28
 
 
29
 
 
30
 
fd=open(s,O_RDWR|O_NONBLOCK);
31
 
 
32
 
if (fd <0)
33
 
 
34
 
return false;
35
 
 
36
 
serinfo.reserved_char[0] = 0;
37
 
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
38
 
        {
39
 
        close(fd);
40
 
        return false;
41
 
        }
42
 
close(fd);
43
 
if ( serinfo.type == 5 || serinfo.type ==0 )
44
 
return false;
45
 
else
46
 
return true;
47
 
}
48
 
 
49
 
/*int getInputVolume()
50
 
{
51
 
return getVolume( MIXER_READ(SOUND_MIXER_MIC));
52
 
}*/
53
 
 
54
 
int getOutputVolume()
55
 
{
56
 
return getVolume(SOUND_MIXER_VOLUME);
57
 
}
58
 
 
59
 
int getVolume(int Device)
60
 
{
61
 
int fd;
62
 
int volume;
63
 
 
64
 
fd=open("/dev/mixer",O_RDWR);
65
 
 
66
 
if  (fd <0)
67
 
        return 0;
68
 
 
69
 
if (ioctl(fd,MIXER_READ(Device),&volume) == -1)
70
 
        volume=0;
71
 
volume=volume & 0x7f;
72
 
close(fd);
73
 
return volume;
74
 
}
75
 
 
76
 
void setVolume(int Device,int volume)
77
 
 
78
 
{
79
 
int fd;
80
 
int vol;
81
 
fd=open("/dev/mixer",O_RDWR);
82
 
 
83
 
if  (fd >0)
84
 
 
85
 
        {
86
 
//    vol = volume << 8;
87
 
//              vol     = vol | ( volume & 0x7f);
88
 
                vol = volume & 0x7f;
89
 
                ioctl(fd,MIXER_WRITE(Device),&volume);
90
 
                close(fd);
91
 
        }
92
 
}
93
 
 
94
 
void setOutputVolume(int volume)
95
 
{
96
 
setVolume(MIXER_WRITE(SOUND_MIXER_VOLUME),volume);
97
 
}
98
 
 
99
 
void setInputVolume(int volume)
100
 
{
101
 
setVolume(MIXER_WRITE(SOUND_MIXER_MIC),volume);
102
 
}
103
 
 
104
 
void setInputSource(int Device)
105
 
{
106
 
int fd_mixer;
107
 
int mixer_channel;
108
 
mixer_channel= (1 << Device);
109
 
 
110
 
fd_mixer=open("/dev/mixer",O_RDWR);     //Open Mixer
111
 
if ( fd_mixer >0 )
112
 
        ioctl(fd_mixer,MIXER_WRITE(SOUND_MIXER_RECSRC),&mixer_channel);
113
 
close(fd_mixer);        
114
 
 
115
 
}