Remove coonflict

pull/117/head
F5OEO 2018-11-06 14:31:56 +00:00
commit aa54828e62
100 zmienionych plików z 13465 dodań i 4887 usunięć

BIN
BBC.jpg 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 17 KiB

674
LICENCE 100644
Wyświetl plik

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

109
README.md
Wyświetl plik

@ -1,109 +0,0 @@
**rpitx** is a radio transmitter for Raspberry Pi (B, B+, PI2, PI3B,PI3B+,PIZero,PiZerow) that transmits RF directly to GPIO. It can handle frequencies from 5 KHz up to 1500 MHz.
Before you transmit, know your laws. **rpitx** has not been tested for compliance with regulations governing transmission of radio signals. You are responsible for using your **rpitx** legally.
Rpitx is now based on a general Radio Frequency library : https://github.com/F5OEO/librpitx
_Created by Evariste Courjaud F5OEO. Code is GPL_
# Installation
Assuming a Raspbian Lite installation (stretch) : https://www.raspberrypi.org/downloads/raspbian/
```sh
git clone https://github.com/F5OEO/rpitx
cd rpitx
# make sure to have access to the internet to download packages
# or download and install them manually (libsndfile1-dev and imagemagick)
./install.sh
```
# Hardware
Plug a wire on GPIO 4, means Pin 7 of the GPIO header ([header P1](http://elinux.org/RPi_Low-level_peripherals#General_Purpose_Input.2FOutput_.28GPIO.29)). This acts as the antenna. The optimal length of the wire depends the frequency you want to transmit on, but it works with a few centimeters for local testing.
# Short manual
## General
**rpitx** is the main software to transmit. It allows to transmit from:
- **IQ** files *.iq (can be generated by external software like [GNU Radio](http://gnuradio.org/)).
- **Frequency/Time** files *.ft (generally used to easily implement digital modes)
Usage:
```
rpitx [-i File Input][-m ModeInput] [-f frequency output] [-s Samplerate] [-l] [-p ppm] [-h]
-m {IQ(FileInput is a Stereo Wav contains I on left Channel, Q on right channel)}
{IQFLOAT(FileInput is a Raw float interlaced I,Q)}
{RF(FileInput is a (double)Frequency,Time in nanoseconds}
{RFA(FileInput is a (double)Frequency,(int)Time in nanoseconds,(float)Amplitude}
{VFO (constant frequency)}
-i path to File Input
-f float frequency to output on GPIO_18 pin 12 in khz : (130 kHz to 750 MHz),
-l loop mode for file input
-p float frequency correction in parts per million (ppm), positive or negative, for calibration, default 0.
-d int DMABurstSize (default 1000) but for very short message, could be decrease
-c 1 Transmit on GPIO 4 (Pin 7) instead of GPIO 18
-h help (this help).
```
## Modulation samples
Some modulations are included in this repository and can be easily extended. These scripts create files which can be used by rpitx.
Some output in IQ (like SSB) other in FT (like SSTV).
### Single Side Band modulation (SSB)
**pissb** converts an audio file (Wav 48KHZ mono only!) to [SSB](https://www.sigidwiki.com/wiki/Single_Sideband_Voice) (Upper Side Band right now) and outputs it
to an IQ file.
Assuming your audio file is in your current working directory:
```sh
./pissb audio48mono.wav ssbIQ.wav
```
You could then transmit it on 50MHz (please set a correct frequency to be legal)
```sh
sudo ./rpitx -m IQ -i ssbIQ.wav -f 50000 -l
```
A sample script `testssb.sh` is included.
### Broadcat Frequency Modulation (FM)
**pifm** converts an audio file (Wav) to broadcast FM using Christophe Jacquet (F8FTK) PiFmRds project fork : https://github.com/F5OEO/PiFmRds
See Readme from this project for instructions.
### Slow Scan Television (SSTV)
**pisstv** converts an RGB picture to a [SSTV](https://www.sigidwiki.com/wiki/SSTV) .ft file.
The SSTV module will transmit using the Martin M1 encoding mode.
If you have a JPEG picture 320x256 you can convert it to an RGB picture with:
```sh
imagemagick convert -depth 8 picture.jpg picture.rgb
```
You can then transmit on 144.5Mhz (please set a correct frequency to be legal) :
```sh
./pisstv picture.rgb 144.5e6
```
A sample script `snapsstv.sh` grabs a picture from a PiCamera and then transmits it on 144.5 MHz.
### Fast Simple QSO (FSQ)
**pifsq** allows to send a text with the new [FSQ](https://www.sigidwiki.com/wiki/FSQ) modulation
It is still under development.
A sample script `testfsq.sh` allows to send a text with FSQ
### Weak Signal Propagation Reporter (WSPR)
**wsprrpi** allows to send wspr beacon https://en.wikipedia.org/wiki/WSPR_(amateur_radio_software)
It uses a fork from James (https://github.com/JamesP6000/WsprryPi) project and adpated to librpitx for frequency ehancement and cleaner spectrum (to be confirmed)
See https://github.com/F5OEO/WsprryPi for instructions
### Variable Frequency Offset (VFO)
A **VFO** mode is provided to allows precise frequency resolution.
For example to set a carrier on 100MHz (please set a correct frequency to be legal)
```sh
sudo ./rpitx -m VFO -f 100000
```
# Notes
All rights of the original authors reserved.
Special thanks to Sylvain Azarian F4GKR for improving SSB modulation
Inspired by
* http://pe1nnz.nl.eu.org/2013/05/direct-ssb-generation-on-pll.html
* http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
* https://github.com/richardghirst/PiBits/pull/18
* http://www.bellard.org/dvbt/

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 206 KiB

BIN
doc/Tunerpitx.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 776 KiB

BIN
doc/bpf-warning.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 35 KiB

BIN
doc/chirprpitx.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 670 KiB

BIN
doc/easymenu.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 26 KiB

BIN
doc/fmrds.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 754 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 472 KiB

BIN
doc/freedvrpitx.JPG 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 340 KiB

BIN
doc/operarpitx.JPG 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 196 KiB

BIN
doc/pocsagrpitx.JPG 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 278 KiB

BIN
doc/replay.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 257 KiB

BIN
doc/rfmyface.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 298 KiB

BIN
doc/rlsdrmenu.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 19 KiB

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 381 KiB

BIN
doc/ssbrpitx.png 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 374 KiB

BIN
doc/sstvrpitx.JPG 100644

Plik binarny nie jest wyświetlany.

Po

Szerokość:  |  Wysokość:  |  Rozmiar: 283 KiB

38
easytest.sh 100755
Wyświetl plik

@ -0,0 +1,38 @@
#!/bin/bash
status="0"
while [ "$status" -eq 0 ]
do
menuchoice=$(whiptail --title "Rpitx on 434Mhz" --menu "Choose your test, ctrl^c to end a test" 20 82 12 \
"0 Tune" "Carrier" \
"1 Chirp" "Moving carrier" \
"2 Spectrum" "Spectrum painting" \
"3 RfMyFace" "Snap with Raspicam and RF paint" \
"4 FmRds" "Broadcast modulation with RDS" \
"5 NFM" "Narrow band FM" \
"6 SSB" "Upper Side Bande modulation" \
"7 AM" "Amplitude Modulation (Poor quality)" \
"8 FreeDV" "Digital voice mode 800XA" \
"9 SSTV" "Patern picture" \
"10 Pocsag" "Pager message" \
"11 Opera" "Like morse but need Opera decoder" \
3>&2 2>&1 1>&3)
case "$menuchoice" in
0\ *) "./testvfo.sh" >/dev/null 2>/dev/null ;;
1\ *) "./testchirp.sh" >/dev/null 2>/dev/null ;;
2\ *) "./testspectrum.sh" >/dev/null 2>/dev/null ;;
3\ *) "./snap2spectrum.sh" >/dev/null 2>/dev/null ;;
4\ *) "./testfmrds.sh" >/dev/null 2>/dev/null ;;
5\ *) "./testnfm.sh" >/dev/null 2>/dev/null ;;
6\ *) "./testssb.sh" >/dev/null 2>/dev/null ;;
7\ *) "./testam.sh" >/dev/null 2>/dev/null ;;
8\ *) "./testfreedv.sh" >/dev/null 2>/dev/null ;;
9\ *) "./testsstv.sh" >/dev/null 2>/dev/null ;;
10\ *) "./testpocsag.sh" >/dev/null 2>/dev/null ;;
11\ *) "./testopera.sh" >/dev/null 2>/dev/null ;;
*) status=1;;
esac
done
exit

3
fm2ssb.sh 100755
Wyświetl plik

@ -0,0 +1,3 @@
echo fm2ssb.sh freq gain
rtl_fm -f $1 -s 250k -r 48k -g $2 - | csdr convert_i16_f | csdr fir_interpolate_cc 2| csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | buffer | sudo ./sendiq -i /dev/stdin -s 96000 -f 434.0e6 -t float
# | sox -traw -r48k -es -b16 - -c1 -r 48k -traw -

Wyświetl plik

@ -1,11 +1,36 @@
echo Install rpitx - some package need internet connection -
echo Install rpitx - some package need internet connexion -
sudo apt-get update
sudo apt-get install -y libsndfile1-dev
sudo apt-get install -y imagemagick
sudo mknod /dev/rpidatv-mb c 100 0
sudo apt-get install -y libsndfile1-dev git
sudo apt-get install -y imagemagick libfftw3-dev
#For rtl-sdr use
sudo apt-get install -y rtl-sdr buffer
# We use CSDR as a dsp for analogs modes thanks to HA7ILM
git clone https://github.com/simonyiszk/csdr
cd csdr
make && sudo make install
cd ../
cd src
make -j4
git clone https://github.com/F5OEO/librpitx
cd librpitx/src
make
cd ../../
make
sudo make install
cd ..
echo Installation done
read -p "In order to run properly, rpitx need to modify /boot/config.txt. Are you sure (y/n) " CONT
if [ "$CONT" = "y" ]; then
echo "Set GPU to 250Mhz in order to be stable"
LINE='gpu_freq=250'
FILE='/boot/config.txt'
grep -qF "$LINE" "$FILE" || echo "$LINE" | sudo tee --append "$FILE"
echo "Installation completed !"
else
echo "Warning : Rpitx should be instable and stop from transmitting !";
fi

44
rtlmenu.sh 100755
Wyświetl plik

@ -0,0 +1,44 @@
#!/bin/bash
status="0"
INPUT_RTLSDR=434.0
INPUT_GAIN=0
do_freq_setup()
{
FREQ=$(whiptail --inputbox "Choose input Frequency (in MHZ) Default is 100MHZ" 8 78 $INPUT_RTLSDR --title "RTL-SDR Receive Frequency" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
INPUT_RTLSDR=$FREQ
fi
GAIN=$(whiptail --inputbox "Choose input Gain (0(AGC) or 1-45)" 8 78 $INPUT_GAIN --title "RTL-SDR Receive Frequency" 3>&1 1>&2 2>&3)
if [ $? -eq 0 ]; then
INPUT_GAIN=$GAIN
fi
}
do_freq_setup
while [ "$status" -eq 0 ]
do
menuchoice=$(whiptail --title "Rpitx with RTLSDR" --menu "Choose your test, ctrl^c to end a test" 20 82 12 \
"0 Record" "Record spectrum on $INPUT_RTLSDR" \
"1 Play" "Replay spectrum" \
"2 Transponder" "Transmit $INPUT_RTLSDR to 434MHZ" \
"3 Fm->SSB" "Transcode FM $INPUT_RTLSDR to 434MHZ" \
"4 Set frequency" "Modify frequency (actual $INPUT_RTLSDR Mhz)" \
3>&2 2>&1 1>&3)
case "$menuchoice" in
0\ *) rtl_sdr -s 250000 -g "$INPUT_GAIN" -f "$INPUT_RTLSDR"M record.iq >/dev/null 2>/dev/null ;;
1\ *) sudo ./sendiq -s 250000 -f "$INPUT_RTLSDR"e6 -t u8 -i record.iq >/dev/null 2>/dev/null ;;
2\ *) source $"$PWD/transponder.sh" "$INPUT_RTLSDR"M $INPUT_GAIN ;;
3\ *) source $"$PWD/fm2ssb.sh" "$INPUT_RTLSDR"M $INPUT_GAIN >/dev/null 2>/dev/null ;;
4\ *) do_freq_setup ;;
*) status=1;;
esac
done
exit

Plik binarny nie jest wyświetlany.

12
snap2spectrum.sh 100755
Wyświetl plik

@ -0,0 +1,12 @@
raspistill -w 320 -h 256 -o picture.jpg -t 1
#convert picture.jpg -flip -colors 16 -colorspace gray -dither -colorspace YUV picture.yuv
#convert picture.jpg -flip -colors 16 -colorspace gray -colorspace YUV picture.yuv
#convert BBC-Test-Card-F320x256.jpg -flip -quantize YUV -dither FloydSteinberg -colors 4 -interlace partition picture.yuv
convert picture.jpg -flip -quantize YUV -dither FloydSteinberg -colors 4 -interlace partition picture.yuv
sudo ./spectrumpaint picture.Y 434.0e6 100000
#convert -depth 8 picture.jpg picture.rgb
#sudo ./pisstv picture.rgb 144.5e6

Wyświetl plik

@ -1,6 +1,6 @@
raspistill -w 320 -h 256 -o picture.jpg -t 1
convert -depth 8 picture.jpg picture.rgb
sudo ./pisstv picture.rgb picture.ft
sudo ./rpitx -m RF -i picture.ft -f 50105
sudo ./pisstv picture.rgb 434e6

Wyświetl plik

@ -1,54 +1,92 @@
all: ../rpitx ../pissb ../pisstv ../pifsq ../pifm ../piam ../pidcf77
all: ../pisstv ../piopera ../pifsq ../pichirp ../sendiq ../tune ../freedv ../dvbrf ../pocsag ../spectrumpaint ../pifmrds ../rpitx
#CFLAGS = -Wall -g -O2 -D DIGITHIN
CFLAGS = -Wall -g -O2 -Wno-unused-variable
LDFLAGS = -lm -lrt -lpthread
LDFLAGS = librpitx/src/librpitx.a -lm -lrt -lpthread
CCP= g++
CC= gcc
../rpitx: RpiGpio.c RpiTx.c mailbox.c RpiDma.c raspberry_pi_revision.c
$(CC) $(CFLAGS) -o ../rpitx RpiTx.c RpiGpio.c mailbox.c RpiDma.c raspberry_pi_revision.c $(LDFLAGS)
CFLAGS_Pissb = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Pissb = -lm -lrt -lpthread -lsndfile
LDFLAGS_Pissb = librpitx/src/librpitx.a -lm -lrt -lpthread -lsndfile -lliquid
../pissb: ../ssbgen/test_ssb.c ../ssbgen/ssb_gen.c
$(CC) $(CFLAGS_Pissb) -o ../pissb ../ssbgen/ssb_gen.c ../ssbgen/test_ssb.c $(LDFLAGS_Pissb)
../pissb: ssbgen/test_ssb.c ssbgen/ssb_gen.c ssbgen/liquid_ssb.c
$(CC) $(CFLAGS_Pissb) -o ../pissb ssbgen/liquid_ssb.c $(LDFLAGS_Pissb)
CFLAGS_Pisstv = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Pisstv = -lm -lrt -lpthread
../pisstv : ../sstv/pisstv.c
$(CC) $(CFLAGS_Pisstv) -o ../pisstv ../sstv/pisstv.c $(LDFLAGS_Pisstv)
../pisstv : sstv/pisstv.cpp
$(CCP) $(CFLAGS) -o ../pisstv sstv/pisstv.cpp $(LDFLAGS)
../piopera : opera/opera.cpp
$(CCP) $(CFLAGS) -o ../piopera opera/opera.cpp $(LDFLAGS)
../pifsq : fsq/pifsq.cpp
$(CCP) $(CFLAGS) -o ../pifsq fsq/pifsq.cpp $(LDFLAGS)
../pichirp : chirp/chirp.cpp
$(CCP) $(CFLAGS) -o ../pichirp chirp/chirp.cpp $(LDFLAGS)
../sendiq : sendiq.cpp librpitx/src/librpitx.a
$(CCP) $(CFLAGS) -o ../sendiq sendiq.cpp $(LDFLAGS)
../tune : tune.cpp
$(CCP) $(CFLAGS) -o ../tune tune.cpp $(LDFLAGS)
../freedv : freedv/freedv.cpp
$(CCP) $(CFLAGS) -o ../freedv freedv/freedv.cpp $(LDFLAGS)
../dvbrf : dvb/dvbrf.cpp dvb/dvbsenco8.s dvb/fec100.c dvb/dvbs2arm_1v30.s librpitx/src/librpitx.a
$(CC) $(CFLAGS) -c -o dvb/dvbsenco8.o dvb/dvbsenco8.s
$(CC) $(CFLAGS) -c -o dvb/dvbs2arm_1v30.o dvb/dvbs2arm_1v30.s
$(CC) $(CFLAGS) -c -o dvb/fec100.o dvb/fec100.c
$(CCP) $(CFLAGS) -o ../dvbrf dvb/dvbrf.cpp dvb/dvbsenco8.o dvb/fec100.o dvb/dvbs2arm_1v30.o $(LDFLAGS)
../pocsag: pocsag/pocsag.cpp librpitx/src/librpitx.a
$(CCP) $(CFLAGS) -o ../pocsag pocsag/pocsag.cpp $(LDFLAGS)
../spectrumpaint: spectrumpaint/spectrum.cpp librpitx/src/librpitx.a
$(CCP) $(CFLAGS) -o ../spectrumpaint spectrumpaint/spectrum.cpp $(LDFLAGS)
../pifmrds: pifmrds/rds.c pifmrds/waveforms.c pifmrds/pi_fm_rds.cpp pifmrds/fm_mpx.c pifmrds/control_pipe.c librpitx/src/librpitx.a
$(CC) $(CFLAGS) -c -o pifmrds/rds.o pifmrds/rds.c
$(CC) $(CFLAGS) -c -o pifmrds/control_pipe.o pifmrds/control_pipe.c
$(CC) $(CFLAGS) -c -o pifmrds/waveforms.o pifmrds/waveforms.c
$(CC) $(CFLAGS) -c -o pifmrds/rds_wav.o pifmrds/rds_wav.c
$(CC) $(CFLAGS) -c -o pifmrds/fm_mpx.o pifmrds/fm_mpx.c
$(CC) -o pifmrds/rds_wav pifmrds/rds_wav.o pifmrds/rds.o pifmrds/waveforms.o pifmrds/fm_mpx.o -lm -lsndfile
$(CCP) $(CFLAGS) -Wno-write-strings -o ../pifmrds pifmrds/rds.o pifmrds/waveforms.o pifmrds/pi_fm_rds.cpp pifmrds/fm_mpx.o pifmrds/control_pipe.o librpitx/src/librpitx.a -lm -lsndfile -lrt -lpthread
../rpitx: rpitxv1/rpitx.cpp librpitx/src/librpitx.a
$(CCP) $(CFLAGS) -Wno-write-strings -o ../rpitx rpitxv1/rpitx.cpp $(LDFLAGS)
CFLAGS_Pifsq = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Pifsq = -lm -lrt -lpthread
../pifsq : ../fsq/pifsq.c
$(CC) $(CFLAGS_Pisfq) -o ../pifsq ../fsq/pifsq.c $(LDFLAGS_Pisfq)
CFLAGS_Pifm = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Pifm = -lm -lrt -lpthread -lsndfile
LDFLAGS_Pifm = librpitx/src/librpitx.a -lm -lrt -lpthread -lsndfile
../pifm : ../fm/pifm.c
$(CC) $(CFLAGS_Pifm) -o ../pifm ../fm/pifm.c $(LDFLAGS_Pifm)
CFLAGS_Piam = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Piam = -lm -lrt -lpthread -lsndfile
LDFLAGS_Piam = librpitx/src/librpitx.a -lm -lrt -lpthread -lsndfile
../piam : ../am/piam.c
$(CC) $(CFLAGS_Piam) -o ../piam ../am/piam.c $(LDFLAGS_Piam)
CFLAGS_Pidcf77 = -Wall -g -O2 -Wno-unused-variable
LDFLAGS_Pidcf77 = -lm -lrt -lpthread
LDFLAGS_Pidcf77 = librpitx/src/librpitx.a -lm -lrt -lpthread
../pidcf77 : ../dcf77/pidcf77.c
$(CC) $(CFLAGS_Piam) -o ../pidcf77 ../dcf77/pidcf77.c $(LDFLAGS_Piam)
clean:
rm -f ../rpitx ../pissb ../pisstv ../pifsq ../pifm ../piam ../pidcf77 RpiTx.o mailbox.o RpiGpio.o RpiDma.o
rm -f ../dvbrf ../sendiq ../pissb ../pisstv ../pifsq ../pifm ../piam ../pidcf77 ../pichirp ../tune ../freedv ../piopera ../spectrumpaint ../pocsag ../pifmrds ../rpitx
install: all
install -m 0755 ../pisstv /usr/bin
install -m 0755 ../pifm /usr/bin
install -m 0755 ../piam /usr/bin
install -m 0755 ../pissb /usr/bin
install -m 0755 ../piopera /usr/bin
install -m 0755 ../pifsq /usr/bin
install -m 0755 ../pichirp /usr/bin
install -m 0755 ../sendiq /usr/bin
install -m 0755 ../tune /usr/bin
install -m 0755 ../freedv /usr/bin
install -m 0755 ../dvbrf /usr/bin
install -m 0755 ../rpitx /usr/bin
install -m 0755 ../pidcf77 /usr/bin
cp dt-blob.bin /boot/
$(info !!! You should reboot if it is the first installation !!!)

Wyświetl plik

@ -1,119 +0,0 @@
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "RpiDma.h"
#include "RpiGpio.h"
static int compareInts(const void* first, const void* second)
{
const int firstInt = *((int*)first);
const int secondInt = *((int*)second);
if (firstInt < secondInt) {
return -1;
}
if (firstInt == secondInt) {
return 0;
}
return 1;
}
char InitDma(void *FunctionTerminate, int* skipSignals)
{
DMA_CHANNEL=4;
char *line = NULL;
size_t size;
FILE * flinux = popen("uname -r", "r");
if (flinux != NULL && getline(&line, &size, flinux) == -1)
{
fprintf(stderr, "Could no get Linux version\n");
}
else
{
if(line[0]=='3')
{
printf("Wheezy\n");
DMA_CHANNEL=DMA_CHANNEL_WHEEZY;
}
if(line[0]=='4')
{
printf("Jessie\n");
DMA_CHANNEL=DMA_CHANNEL_JESSIE;
}
}
pclose(flinux);
//printf("Init DMA\n");
int sentinel[] = {0};
if (skipSignals == NULL) {
skipSignals = sentinel;
}
int sentinelIndex;
for (sentinelIndex = 0; ; ++sentinelIndex) {
if (skipSignals[sentinelIndex] == 0) {
break;
}
}
qsort(skipSignals, sentinelIndex, sizeof(int), compareInts);
// Catch all signals possible - it is vital we kill the DMA engine
// on process exit!
int i;
for (i = 0; i < 64; i++) {
// Some signals are fine, so don't catch them
if (i == *skipSignals) {
++skipSignals;
} else {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = FunctionTerminate;//terminate;
sigaction(i, &sa, NULL);
}
}
//NUM_SAMPLES = NUM_SAMPLES_MAX;
/* Use the mailbox interface to the VC to ask for physical memory */
/*
unlink(MBFILE);
if (mknod(MBFILE, S_IFCHR|0600, makedev(100, 0)) < 0)
{
printf("Failed to create mailbox device\n");
return 0;
}*/
mbox.handle = mbox_open();
if (mbox.handle < 0)
{
printf("Failed to open mailbox\n");
return(0);
}
printf("%d Size NUM PAGES %d PAGE_SIZE %d\n",(sizeof(struct control_data_s)),NUM_PAGES,PAGE_SIZE);
mbox.mem_ref = mem_alloc(mbox.handle, NUM_PAGES* PAGE_SIZE, PAGE_SIZE, mem_flag);
/* TODO: How do we know that succeeded? */
//printf("mem_ref %x\n", mbox.mem_ref);
mbox.bus_addr = mem_lock(mbox.handle, mbox.mem_ref);
//printf("bus_addr = %x\n", mbox.bus_addr);
mbox.virt_addr = mapmem(BUS_TO_PHYS(mbox.bus_addr), NUM_PAGES* PAGE_SIZE);
//printf("virt_addr %p\n", mbox.virt_addr);
virtbase = (uint8_t *)((uint32_t *)mbox.virt_addr);
//printf("virtbase %p\n", virtbase);
return(1);
}
uint32_t mem_virt_to_phys(volatile void *virt)
{
//MBOX METHOD
uint32_t offset = (uint8_t *)virt - mbox.virt_addr;
return mbox.bus_addr + offset;
}
uint32_t mem_phys_to_virt(volatile uint32_t phys)
{
//MBOX METHOD
uint32_t offset=phys-mbox.bus_addr;
uint32_t result=(uint32_t)((uint8_t *)mbox.virt_addr+offset);
//printf("MemtoVirt:Offset=%lx phys=%lx -> %lx\n",offset,phys,result);
return result;
}

Wyświetl plik

@ -1,128 +0,0 @@
#ifndef RPI_DMA
#define RPI_DMA
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "mailbox.h"
char InitDma(void *FunctionTerminate, int* skipSignals);
uint32_t mem_virt_to_phys(volatile void *virt);
uint32_t mem_phys_to_virt(volatile uint32_t phys);
#define NBSAMPLES_PWM_FREQ_MAX 500
#define NUM_CB_PWM_FREQUENCY 8
//#define MBFILE DEVICE_FILE_NAME /* From mailbox.h */
#define NUM_SAMPLES_MAX (4000)
#define CBS_SIZE_BY_SAMPLE (3)
#define NUM_CBS_MAIN ((NUM_SAMPLES_MAX * CBS_SIZE_BY_SAMPLE))
#define NUM_CBS (NUM_CBS_MAIN)
#define BCM2708_DMA_SRC_IGNOR (1<<11)
#define BCM2708_DMA_SRC_INC (1<<8)
#define BCM2708_DMA_DST_IGNOR (1<<7)
#define BCM2708_DMA_NO_WIDE_BURSTS (1<<26)
#define BCM2708_DMA_WAIT_RESP (1<<3)
#define BCM2708_DMA_D_DREQ (1<<6)
#define BCM2708_DMA_PER_MAP(x) ((x)<<16)
#define BCM2708_DMA_END (1<<1)
#define BCM2708_DMA_RESET (1<<31)
#define BCM2708_DMA_ABORT (1<<30)
#define BCM2708_DMA_INT (1<<2)
#define DMA_CS (0x00/4)
#define DMA_CONBLK_AD (0x04/4)
#define DMA_DEBUG (0x20/4)
#define BUS_TO_PHYS(x) ((x)&~0xC0000000)
#define DMA_CS_RESET (1<<31)
#define DMA_CS_ABORT (1<<30)
#define DMA_CS_DISDEBUG (1<<28)
#define DMA_CS_END (1<<1)
#define DMA_CS_ACTIVE (1<<0)
#define DMA_CS_PRIORITY(x) ((x)&0xf << 16)
#define DMA_CS_PANIC_PRIORITY(x) ((x)&0xf << 20)
#define PAGE_SIZE 4096
#define PAGE_SHIFT 12
#define NUM_PAGES ((sizeof(struct control_data_s) + PAGE_SIZE - 1) >> PAGE_SHIFT)
struct {
int handle; /* From mbox_open() */
unsigned mem_ref; /* From mem_alloc() */
unsigned bus_addr; /* From mem_lock() */
uint8_t *virt_addr; /* From mapmem() */
} mbox;
// The GPU reserves channels 1, 3, 6, and 7 (kernel mask dma.dmachans=0x7f35)
// And, I think sdcard will always get 2 and fbturbo zero
//8 Crash
// 5 seems OK, 14 ALSO
//cat /sys/module/dma/parameters/dmachans
//On Wheezy
//32565: 111111100110101
//On Jessie Pi2:
//3893 : 111100110101
// USE CHANNEL 4 AND 5 which seems to be free
// On Jessie, channel 4 and 5 seems to crash : set to DMA 8 .
#define DMA_CHANNEL_WHEEZY 14
#define DMA_CHANNEL_JESSIE 5
//#define DMA_CHANNEL_PWMFREQUENCY 5
char DMA_CHANNEL;
//#define DMA_CHANNEL 8
#define DMA_CHANNEL_PWMFREQUENCY (DMA_CHANNEL+1)
typedef struct {
uint32_t info, src, dst, length,
stride, next, pad[2];
} dma_cb_t;
typedef struct {
uint8_t *virtaddr;
uint32_t physaddr;
} page_map_t;
page_map_t *page_map;
uint8_t *virtbase;
#define PWM_STEP_MAXI 200
typedef struct {
uint32_t FrequencyTab[PWM_STEP_MAXI];
uint32_t Amplitude1;
uint32_t Amplitude2;
} sample_t;
struct control_data_s {
dma_cb_t cb[NUM_CBS];//+1 ??
sample_t sample[NUM_SAMPLES_MAX];
};
struct control_data_s *ctl;
#endif

Wyświetl plik

@ -1,97 +0,0 @@
#include "RpiGpio.h"
#include "mailbox.h"
#include "raspberry_pi_revision.h"
static volatile unsigned int BCM2708_PERI_BASE;
static uint32_t dram_phys_base;
char InitGpio()
{
int rev, mem, maker, overVolted ;
//printf("*********** Init GPIO *************\n");
RASPBERRY_PI_INFO_T info;
if (getRaspberryPiInformation(&info) > 0)
{
if(info.peripheralBase==RPI_BROADCOM_2835_PERIPHERAL_BASE)
{
BCM2708_PERI_BASE = info.peripheralBase ;
dram_phys_base = 0x40000000;
mem_flag = MEM_FLAG_L1_NONALLOCATING|MEM_FLAG_HINT_PERMALOCK|MEM_FLAG_NO_INIT;//0x0c;
}
if((info.peripheralBase==RPI_BROADCOM_2836_PERIPHERAL_BASE)||(info.peripheralBase==RPI_BROADCOM_2837_PERIPHERAL_BASE))
{
BCM2708_PERI_BASE = info.peripheralBase ;
dram_phys_base = 0xc0000000;
mem_flag = MEM_FLAG_L1_NONALLOCATING/*MEM_FLAG_DIRECT*/|MEM_FLAG_HINT_PERMALOCK|MEM_FLAG_NO_INIT;//0x04;
}
}
DisplayInfo();
dma_reg = map_peripheral(DMA_BASE, DMA_LEN);
pwm_reg = map_peripheral(PWM_BASE, PWM_LEN);
clk_reg = map_peripheral(CLK_BASE, CLK_LEN);
pcm_reg = map_peripheral(PCM_BASE, PCM_LEN);
gpio_reg = map_peripheral(GPIO_BASE, GPIO_LEN);
pad_gpios_reg = map_peripheral(PADS_GPIO, PADS_GPIO_LEN);
return 1;
}
void * map_peripheral(uint32_t base, uint32_t len)
{
void * vaddr;
vaddr=mapmem(base,len);
//printf("Vaddr =%lx \n",vaddr);
return vaddr;
}
int gpioSetMode(unsigned gpio, unsigned mode)
{
int reg, shift;
reg = gpio/10;
shift = (gpio%10) * 3;
gpio_reg[reg] = (gpio_reg[reg] & ~(7<<shift)) | (mode<<shift);
return 0;
}
void DisplayInfo()
{
RASPBERRY_PI_INFO_T info;
if (getRaspberryPiInformation(&info) > 0)
{
printf("memory: %s\n", raspberryPiMemoryToString(info.memory));
printf("processor: %s\n",
raspberryPiProcessorToString(info.processor));
printf("i2cDevice: %s\n",
raspberryPiI2CDeviceToString(info.i2cDevice));
printf("model: %s\n",
raspberryPiModelToString(info.model));
printf("manufacturer: %s\n",
raspberryPiManufacturerToString(info.manufacturer));
printf("pcb revision: %d\n", info.pcbRevision);
printf("warranty void: %s\n", (info.warrantyBit) ? "yes" : "no");
printf("revision: %04x\n", info.revisionNumber);
printf("peripheral base: 0x%x\n", info.peripheralBase);
}
}

Wyświetl plik

@ -1,107 +0,0 @@
#ifndef RPI_GPIO
#define RPI_GPIO
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <ctype.h>
char InitGpio(void);
void DisplayInfo();
int model;
uint32_t mem_flag;
volatile uint32_t *pwm_reg;
volatile uint32_t *clk_reg;
volatile uint32_t *dma_reg;
volatile uint32_t *gpio_reg;
volatile uint32_t *pcm_reg;
volatile uint32_t *pad_gpios_reg;
void * map_peripheral(uint32_t base, uint32_t len);
int gpioSetMode(unsigned gpio, unsigned mode);
#define DMA_BASE (BCM2708_PERI_BASE + 0x00007000 )
#define DMA_LEN 0xF00
#define PWM_BASE (BCM2708_PERI_BASE + 0x0020C000)
#define PWM_LEN 0x28
#define CLK_BASE (BCM2708_PERI_BASE + 0x00101000)
#define CLK_LEN 0xA8
#define GPIO_BASE (BCM2708_PERI_BASE + 0x00200000)
#define GPIO_LEN 0xB4
#define PCM_BASE (BCM2708_PERI_BASE + 0x00203000)
#define PCM_LEN 0x24
#define PADS_GPIO (BCM2708_PERI_BASE + 0x00100000)
#define PADS_GPIO_LEN (0x40/4)
#define PADS_GPIO_0 (0x2C/4)
#define PADS_GPIO_1 (0x30/4)
#define PADS_GPIO_2 (0x34/4)
#define PWM_CTL (0x00/4)
#define PWM_DMAC (0x08/4)
#define PWM_RNG1 (0x10/4)
#define PWM_RNG2 (0x20/4)
#define PWM_FIFO (0x18/4)
#define PWMCLK_CNTL 40
#define PWMCLK_DIV 41
#define GPCLK_CNTL (0x70/4)
#define GPCLK_DIV (0x74/4)
#define PWMCTL_MSEN2 (1<<15)
#define PWMCTL_USEF2 (1<<13)
#define PWMCTL_RPTL2 (1<<10)
#define PWMCTL_MODE2 (1<<9)
#define PWMCTL_PWEN2 (1<<8)
#define PWMCTL_MSEN1 (1<<7)
#define PWMCTL_CLRF (1<<6)
#define PWMCTL_USEF1 (1<<5)
#define PWMCTL_POLA1 (1<<4)
#define PWMCTL_RPTL1 (1<<2)
#define PWMCTL_MODE1 (1<<1)
#define PWMCTL_PWEN1 (1<<0)
#define PWMDMAC_ENAB (1<<31)
#define PWMDMAC_THRSHLD ((15<<8)|(15<<0))
#define PCM_CS_A (0x00/4)
#define PCM_FIFO_A (0x04/4)
#define PCM_MODE_A (0x08/4)
#define PCM_RXC_A (0x0c/4)
#define PCM_TXC_A (0x10/4)
#define PCM_DREQ_A (0x14/4)
#define PCM_INTEN_A (0x18/4)
#define PCM_INT_STC_A (0x1c/4)
#define PCM_GRAY (0x20/4)
#define PCMCLK_CNTL 38
#define PCMCLK_DIV 39
#define GPFSEL0 (0x00/4)
#define GPFSEL1 (0x04/4)
#define GPFSEL2 (0x08/4)
// ---- Memory allocating defines
// https://github.com/raspberrypi/firmware/wiki/Mailbox-property-interface
#define MEM_FLAG_DISCARDABLE (1 << 0) /* can be resized to 0 at any time. Use for cached data */
#define MEM_FLAG_NORMAL (0 << 2) /* normal allocating alias. Don't use from ARM */
#define MEM_FLAG_DIRECT (1 << 2) /* 0xC alias uncached */
#define MEM_FLAG_COHERENT (2 << 2) /* 0x8 alias. Non-allocating in L2 but coherent */
#define MEM_FLAG_L1_NONALLOCATING (MEM_FLAG_DIRECT | MEM_FLAG_COHERENT) /* Allocating in L2 */
#define MEM_FLAG_ZERO ( 1 << 4) /* initialise buffer to all zeros */
#define MEM_FLAG_NO_INIT ( 1 << 5) /* don't initialise (default is initialise to all ones */
#define MEM_FLAG_HINT_PERMALOCK (1 << 6) /* Likely to be locked for long periods of time. */
#endif

Plik diff jest za duży Load Diff

Wyświetl plik

@ -1,29 +0,0 @@
#ifndef RPITX_H
#define RPITX_H
#include <ctype.h>
int pitx_init(int SampleRate, double TuningFrequency, int* skipSignals,int SetDma);
int pitx_SetTuneFrequencyu(uint32_t Frequency);
#define MODE_IQ 0
#define MODE_RF 1
#define MODE_RFA 2
#define MODE_IQ_FLOAT 3
#define MODE_VFO 4
int pitx_run(
char Mode,
int SampleRate,
float SetFrequency,
float ppmpll,
char NoUsePwmFrequency,
// Wrapper around read to read wav file bytes
ssize_t (*readWrapper)(void *buffer, size_t count),
// Wrapper to reset file for looping
void (*reset)(void),
int* skipSignals,
int SetDma
);
#endif

110
src/chirp/chirp.cpp 100644
Wyświetl plik

@ -0,0 +1,110 @@
#include <unistd.h>
#include "../librpitx/src/librpitx.h"
#include <unistd.h>
#include "stdio.h"
#include <cstring>
#include <signal.h>
bool running=true;
void SimpleTestDMA(uint64_t Freq)
{
int SR=1000;
int FifoSize=4096;
ngfmdmasync ngfmtest(Freq,SR,14,FifoSize);
for(int i=0;running;)
{
//usleep(10);
usleep(FifoSize*1000000.0*3.0/(4.0*SR));
int Available=ngfmtest.GetBufferAvailable();
if(Available>FifoSize/2)
{
int Index=ngfmtest.GetUserMemIndex();
//printf("GetIndex=%d\n",Index);
for(int j=0;j<Available;j++)
{
//ngfmtest.SetFrequencySample(Index,((i%10000)>5000)?1000:0);
ngfmtest.SetFrequencySample(Index+j,(i%SR)/10.0);
i++;
}
}
}
fprintf(stderr,"End\n");
ngfmtest.stop();
}
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating\n");
}
int main(int argc, char* argv[])
{
if(argc<3) {printf("Usage : pichirp Frequency(Hz) Bandwidth(Hz) Time(Seconds)\n");exit(0);}
float Frequency=atof(argv[1]);
float Bandwidth=atof(argv[2]);
float Time=atof(argv[3]);
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
int SR=100000;
int FifoSize=4096;
ngfmdmasync ngfmtest(Frequency,SR,14,FifoSize);
float Step=Bandwidth/Time; //Deviation Hz by second
float StepWithSR=Step/(float)SR;
int NbStepWithSR=Time*SR;
float FrequencyDeviation=0;
int count=0;
for(int i=0;running;)
{
usleep(FifoSize*1000000.0*3.0/(4.0*SR));
int Available=ngfmtest.GetBufferAvailable();
if(Available>FifoSize/2)
{
int Index=ngfmtest.GetUserMemIndex();
for(int j=0;j<Available;j++)
{
ngfmtest.SetFrequencySample(Index+j,StepWithSR*count);
count++;
if(count>NbStepWithSR) count=0;
}
}
fprintf(stderr,"Freq=%f\n",Frequency+StepWithSR*count);
}
fprintf(stderr,"End\n");
ngfmtest.stop();
}

140
src/drone/drone.c 100644
Wyświetl plik

@ -0,0 +1,140 @@
//
// Simple FSQ beacon for Arduino, with the Etherkit Si5351A Breakout
// Board, by Jason Milldrum NT7S.
//
// Original code based on Feld Hell beacon for Arduino by Mark
// Vandewettering K6HX, adapted for the Si5351A by Robert
// Liesenfeld AK6L <ak6l@ak6l.org>. Timer setup
// code by Thomas Knutsen LA3PNA.
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject
// to the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
// ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
// CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#define TONE_SPACING 8789 // ~8.7890625 Hz
#define BAUD_2 7812 // CTC value for 2 baud
#define BAUD_3 5208 // CTC value for 3 baud
#define BAUD_4_5 3472 // CTC value for 4.5 baud
#define BAUD_6 2604 // CTC value for 6 baud
#define LED_PIN 13
#define bool char
#define false 0
#define true 1
// Global variables
unsigned long freq = 0;//7105350; // Base freq is 1350 Hz higher than dial freq in USB
uint8_t cur_tone = 0;
static uint8_t crc8_table[256];
char callsign[10] = "F5OEO";
char tx_buffer[40];
uint8_t callsign_crc;
int FileText;
int FileFreqTiming;
// Global variables used in ISRs
volatile bool proceed = false;
void WriteTone(double Frequency,uint32_t Timing)
{
typedef struct {
double Frequency;
uint32_t WaitForThisSample;
} samplerf_t;
samplerf_t RfSample;
RfSample.Frequency=Frequency;
RfSample.WaitForThisSample=Timing; //en 100 de nanosecond
//printf("Freq =%f Timing=%d\n",RfSample.Frequency,RfSample.WaitForThisSample);
if (write(FileFreqTiming, &RfSample,sizeof(samplerf_t)) != sizeof(samplerf_t)) {
fprintf(stderr, "Unable to write sample\n");
}
}
int main(int argc, char **argv)
{
char *sText;
if (argc > 2)
{
sText=(char *)argv[1];
//FileText = open(argv[1], O_RDONLY);
char *sFileFreqTiming=(char *)argv[2];
FileFreqTiming = open(argv[2], O_WRONLY|O_CREAT);
}
else
{
printf("usage : pidrone StringToTransmit file.ft\n");
exit(0);
}
//100KHZ
int Freq_span = 100000;
int NbStep = 2000;
int i;
for(i=1;i<NbStep;i++)
{
WriteTone(Freq_span*i/NbStep-Freq_span/2,1000e6/NbStep);
}
WriteTone(00000,250e6);
for (i=0;i<strlen(sText);i++)
{
int bit;
WriteTone(25000,1250e3);//Start bit
for(bit=0;bit<8;bit++)
{
if((sText[i]&(1<<(7-bit)))>0)
{
WriteTone(25000,1250e3);
printf("1");
}
else
{
WriteTone(-25000,1250e3);
printf("0");
}
}
WriteTone(25000,1250e3);//Stop bit
printf("\n");
}
WriteTone(00000,250e6);
close(FileFreqTiming);
}

Plik binarny nie jest wyświetlany.

Plik diff jest za duży Load Diff

298
src/dvb/dvbrf.cpp 100644
Wyświetl plik

@ -0,0 +1,298 @@
#include <unistd.h>
#include "../librpitx/src/librpitx.h"
#include "stdio.h"
#include <cstring>
#include <signal.h>
// DVBS ENCODER
extern "C"
{
#include "fec100.h"
}
extern "C" void dvbsenco_init (void) ;
extern "C" uchar* dvbsenco (uchar*) ;
extern "C" void energy (uchar* input,uchar *output) ;
extern "C" void reed (uchar *input188) ;
extern "C" uchar* interleave (uchar* packetin) ;
// DVBS2 ENCODER
extern "C" uint32_t _dvbs2arm_control (uint32_t command, uint32_t param1) ;
extern "C" uchar* _dvbs2arm_process_packet (uchar *packet188) ;
bool running=true;
#define PROGRAM_VERSION "0.1"
void SimpleTestFileIQ(uint64_t Freq)
{
}
void print_usage(void)
{
fprintf(stderr,\
"\ndvbrf -%s\n\
Usage:\ndvbrf [-i File Input][-s Samplerate][-l] [-f Frequency] [-h Harmonic number] \n\
-i path to Transport Stream File Input \n\
-s SampleRate 10000-250000 \n\
-c Fec : {1/2,3/4,5/6,7/8} \n\
-f float central frequency Hz(50 kHz to 1500 MHz),\n\
-l loop mode for file input\n\
-n Use harmonic number n\n\
-? help (this help).\n\
\n",\
PROGRAM_VERSION);
} /* end function print_usage */
static void
terminate(int num)
{
if(running)
fprintf(stderr,"Caught signal - Terminating %x\n",num);
running=false;
}
#define MAX_SAMPLERATE 2000000
int main(int argc, char* argv[])
{
int a;
int anyargs = 1;
float SetFrequency=434e6;
int SampleRate=48000;
bool loop_mode_flag=false;
char* FileName=NULL;
int Harmonic=1;
enum {typeiq_i16,typeiq_u8,typeiq_float,typeiq_double};
int InputType=typeiq_i16;
int Decimation=1;
int FEC=-1;
enum {DVBS,DVBS2};
int DVB_Mode=DVBS;//
while(1)
{
a = getopt(argc, argv, "i:f:s:n:lt:c:m:");
if(a == -1)
{
if(anyargs) break;
else a='h'; //print usage and exit
}
anyargs = 1;
switch(a)
{
case 'i': // File name
FileName = optarg;
break;
case 'f': // Frequency
SetFrequency = atof(optarg);
break;
case 's': // SampleRate (Only needeed in IQ mode)
SampleRate = atoi(optarg);
if(SampleRate>MAX_SAMPLERATE)
{
fprintf(stderr,"SampleRate too high : >%d sample/s",MAX_SAMPLERATE);
exit(1);
};
break;
case 'c': // FEC
if(strcmp("1/2",optarg)==0) FEC=1;
if(strcmp("2/3",optarg)==0) FEC=2;
if(strcmp("3/4",optarg)==0) FEC=3;
if(strcmp("5/6",optarg)==0) FEC=5;
if(strcmp("7/8",optarg)==0) FEC=7;
if(strcmp("carrier",optarg)==0) {fprintf(stderr,"Carrier mode\n");FEC=0;}//CARRIER MODE
break;
case 'm': // FEC
if(strcmp("dvbs",optarg)==0) DVB_Mode=DVBS;
if(strcmp("dvbs2",optarg)==0) DVB_Mode=DVBS2;
break;
case 'n': // help
Harmonic=atoi(optarg);
break;
case 'l': // loop mode
loop_mode_flag = true;
break;
case -1:
break;
case '?':
if (isprint(optopt) )
{
fprintf(stderr, "dvbrf: unknown option `-%c'.\n", optopt);
}
else
{
fprintf(stderr, "dvbrf: unknown option character `\\x%x'.\n", optopt);
}
print_usage();
exit(1);
break;
default:
print_usage();
exit(1);
break;
}/* end switch a */
}/* end while getopt() */
if(FileName==NULL) {fprintf(stderr,"Need an input\n");exit(1);}
if(FEC<0) {fprintf(stderr,"Need a FEC\n");exit(1);}
for (int i = 0; i < 0xb; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
FILE *tsfile=NULL;
if(strcmp(FileName,"-")==0)
tsfile=fopen("/dev/stdin","rb");
else
tsfile=fopen(FileName,"rb");
if (tsfile==NULL)
{
printf("input file issue\n");
exit(0);
}
if(DVB_Mode==DVBS)
{
int FifoSize=204*100*4;
int NumberofPhase=4;
phasedmasync dvbsmodul(SetFrequency/Harmonic,SampleRate,NumberofPhase,14,FifoSize);
padgpio pad;
pad.setlevel(7);
#define BURST_PACKET 10
#define BURST_SIZE 204*BURST_PACKET
int PhaseBuffer[BURST_SIZE*4*2]; //4 dibit by byte
static uint32_t BuffAligned[256*2];
static uchar *TsBuffer=(uchar *)BuffAligned ;
static unsigned char BuffIQ[204*2]; //QPSK 2bit per sample : 4 dibits by byte
static uchar *pRS204=NULL;
dvbsenco_init() ;
viterbi_init(FEC);
int MapDVBS[4]={0,3,1,2};//0,-pi/2,pi/2,pi
while(running)
{
int nbread=fread(TsBuffer,sizeof(uchar),BURST_PACKET*188,tsfile);
if(nbread>0)
{
if(TsBuffer[0]!=0x47) fprintf(stderr,"SYNC ERROR \n");
for(int p=0;p<BURST_PACKET;p++)
{
pRS204 = dvbsenco (TsBuffer+p*188) ;
int NbIQOutput=viterbi (pRS204,BuffIQ);
int dibit=0;
for(int k=0;k<NbIQOutput;k++)
{
for(int i=3;i>=0;i--)
{
PhaseBuffer[dibit++]=MapDVBS[(BuffIQ[k]>>(i*2))&0x3];
}
}
dvbsmodul.SetPhaseSamples(PhaseBuffer,NbIQOutput*4);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( tsfile , 0 , SEEK_SET );
else
running=false;
}
}
dvbsmodul.stop();
}
else
{
int FifoSize=546*30*4;
int NumberofPhase=4;
phasedmasync dvbs2modul(SetFrequency/Harmonic,SampleRate,NumberofPhase,14,FifoSize);
padgpio pad;
pad.setlevel(7);
uint32_t BuffAligned[8832];
uchar *IqBuffer=(uchar *)BuffAligned ;
unsigned char TsBuffer[188];
uint32_t Result=-1;
Result=_dvbs2arm_control (1,(uint32_t)IqBuffer) ; // set DVB-S2 mode by passing buffer address
Result=_dvbs2arm_control (2,0x34) ; // set FEC 3/4
Result=_dvbs2arm_control (3,0x35) ; // set rolloff 0.35
Result=_dvbs2arm_control (4,0) ; // Get Efficiency
printf("Net Bitrate should be %f\n",Result*1e-6*SampleRate);
int PhaseBuffer[546*30]; //4 dibit by byte
unsigned char *IQTempFrame=NULL;
int MapDVBS[4]={0,3,1,2};//0,-pi/2,pi/2,pi
while(running)
{
int nbread=fread(TsBuffer,sizeof(uchar),188,tsfile);
if(nbread>0)
{
IQTempFrame =_dvbs2arm_process_packet (TsBuffer);
if(IQTempFrame!=NULL)
{
uint32_t *IQFrame=(uint32_t*)IQTempFrame;
int symbol=0;
for(int i=0;i<546/2;i++)
{
for(int j=31;j>1;j--)
{
PhaseBuffer[symbol++]=MapDVBS[(((IQFrame[2*i]>>j)&1)<<1)|(((IQFrame[2*i+1]>>j)&1))];
//printf("Symbol=%d\n",PhaseBuffer[symbol]);
}
}
//printf("Symbol=%d\n",symbol);
dvbs2modul.SetPhaseSamples(PhaseBuffer,symbol);
}
else
{
//printf("more\n");
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( tsfile , 0 , SEEK_SET );
else
running=false;
}
}
dvbs2modul.stop();
}
}

Plik diff jest za duży Load Diff

1162
src/dvb/dvbsenco8.s 100644

Plik diff jest za duży Load Diff

2867
src/dvb/fec100.c 100644

Plik diff jest za duży Load Diff

7
src/dvb/fec100.h 100644
Wyświetl plik

@ -0,0 +1,7 @@
typedef unsigned char uchar ; // 8 bit
typedef unsigned short uint16 ; // 16 bit
typedef unsigned int uint ; // 32 bits
void viterbi_init(int SetFEC);
uint16 viterbi (uchar *in, uchar *out);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -0,0 +1,105 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "../librpitx/src/librpitx.h"
int FileVCO;
bool running=true;
ngfmdmasync *fmmod;
static double GlobalTuningFrequency=00000.0;
int FifoSize=10000; //10ms
void playtone(float Frequency)
{
float VCOFreq[100];
for(int i=0;i<100;i++) VCOFreq[i]=Frequency;
fmmod->SetFrequencySamples(VCOFreq,100);
}
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating\n");
}
int main(int argc, char **argv)
{
float frequency=144.5e6;
int SampleRate=400;
if (argc >2 )
{
char *sFileVCO=(char *)argv[1];
FileVCO = open(sFileVCO, O_RDONLY);
frequency=atof(argv[2]);
}
if (argc >3 )
{
SampleRate=(int)atof(argv[3]);
}
if(argc<=2)
{
printf("usage : freedv vco.rf frequency(Hz) samplerate(Hz)\n");
exit(0);
}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
fmmod=new ngfmdmasync(frequency,100*SampleRate,14,FifoSize); //400 bits*100 for 800XA
padgpio pad;
pad.setlevel(7);// Set max power
fmmod->enableclk(20);//CLK1 duplicate on GPIO20 for more power ?
short VCOFreq;
while(running)
{
int ByteRead=read(FileVCO,&VCOFreq,sizeof(short));
if(ByteRead==sizeof(short))
{
playtone(VCOFreq);
}
else
running=false;
/*else
{
lseek(FileVCO,0,SEEK_SET);
ByteRead=1;
}*/
}
fmmod->disableclk(20);
printf("End of Tx\n");
close(FileVCO);
delete fmmod;
return 0;
}

Wyświetl plik

@ -40,6 +40,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "../librpitx/src/librpitx.h"
#define TONE_SPACING 8789 // ~8.7890625 Hz
#define BAUD_2 7812 // CTC value for 2 baud
@ -62,7 +63,9 @@ char callsign[10] = "F5OEO";
char tx_buffer[40];
uint8_t callsign_crc;
int FileText;
int FileFreqTiming;
ngfmdmasync *fsqmod=NULL;
int FifoSize=1000;
float Frequency=0;
// Global variables used in ISRs
volatile bool proceed = false;
@ -204,22 +207,7 @@ void encode_tone(uint8_t tone);
// appropriate glyph and sets output from the Si5351A to key the
// FSQ signal.
void WriteTone(double Frequency,uint32_t Timing)
{
typedef struct {
double Frequency;
uint32_t WaitForThisSample;
} samplerf_t;
samplerf_t RfSample;
RfSample.Frequency=Frequency;
RfSample.WaitForThisSample=Timing*1000L; //en 100 de nanosecond
//printf("Freq =%f Timing=%d\n",RfSample.Frequency,RfSample.WaitForThisSample);
if (write(FileFreqTiming, &RfSample,sizeof(samplerf_t)) != sizeof(samplerf_t)) {
fprintf(stderr, "Unable to write sample\n");
}
}
void encode_char(int ch)
{
@ -268,7 +256,29 @@ void encode_tone(uint8_t tone)
{
cur_tone = ((cur_tone + tone + 1) % 33);
//printf("Current tone =%d\n",cur_tone);
WriteTone(1000 + (cur_tone * TONE_SPACING*0.001),500000L);
//WriteTone(1000 + (cur_tone * TONE_SPACING*0.001),500000L);
int count=0;
while(count<1000)
{
int Available=fsqmod->GetBufferAvailable();
if(Available>FifoSize/2)
{
int Index=fsqmod->GetUserMemIndex();
for(int j=0;j<Available;j++)
{
fsqmod->SetFrequencySample(Index+j,1000 + (cur_tone * TONE_SPACING*0.001));
count++;
}
}
else
usleep(100);
}
//TO DO FREQUENCY PI si5351.set_freq((freq * 100) + (cur_tone * TONE_SPACING), 0, SI5351_CLK0);
}
@ -329,7 +339,7 @@ uint8_t crc8(char * text)
{
uint8_t crc='\0';
uint8_t ch;
int i;
size_t i;
for(i = 0; i < strlen(text); i++)
{
ch = text[i];
@ -348,12 +358,12 @@ int main(int argc, char **argv)
sText=(char *)argv[1];
//FileText = open(argv[1], O_RDONLY);
char *sFileFreqTiming=(char *)argv[2];
FileFreqTiming = open(argv[2], O_WRONLY|O_CREAT, 0644);
Frequency = atof(argv[2]);
}
else
{
printf("usage : pifsq StringToTransmit file.ft\n");
printf("usage : pifsq StringToTransmit Frequency(in Hz)\n");
exit(0);
}
@ -363,17 +373,19 @@ int main(int argc, char **argv)
// Generate the CRC for the callsign
callsign_crc = crc8(callsign);
// We are building a directed message here, but you can do whatever.
// So apparently, FSQ very specifically needs " \b " in
// directed mode to indicate EOT. A single backspace won't do it.
sprintf(tx_buffer, "%s:%02x%s%s", callsign, callsign_crc,sText," \b ");
int SR=2000;
fsqmod = new ngfmdmasync(Frequency,SR,14,FifoSize);
encode(tx_buffer);
int i;
for(i=0;i<10;i++)
{
WriteTone(0,500000L);
}
close(FileFreqTiming);
fsqmod->stop();
delete(fsqmod);
}

Wyświetl plik

@ -1,278 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <stdint.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include "mailbox.h"
#define PAGE_SIZE (4*1024)
void *mapmem(unsigned base, unsigned size)
{
int mem_fd;
unsigned offset = base % PAGE_SIZE;
base = base - offset;
/* open /dev/mem */
if ((mem_fd = open("/dev/mem", O_RDWR|O_SYNC) ) < 0) {
printf("can't open /dev/mem\nThis program should be run as root. Try prefixing command with: sudo\n");
exit (-1);
}
void *mem = mmap(
0,
size,
PROT_READ|PROT_WRITE,
MAP_SHARED/*|MAP_FIXED*/,
mem_fd,
base);
#ifdef DEBUG
printf("base=0x%x, mem=%p\n", base, mem);
#endif
if (mem == MAP_FAILED) {
printf("mmap error %d\n", (int)mem);
exit (-1);
}
close(mem_fd);
return (char *)mem + offset;
}
void *unmapmem(void *addr, unsigned size)
{
int s = munmap(addr, size);
if (s != 0) {
printf("munmap error %d\n", s);
exit (-1);
}
return NULL;
}
/*
* use ioctl to send mbox property message
*/
static int mbox_property(int file_desc, void *buf)
{
int ret_val = ioctl(file_desc, IOCTL_MBOX_PROPERTY, buf);
if (ret_val < 0) {
printf("ioctl_set_msg failed:%d\n", ret_val);
}
#ifdef DEBUG
unsigned *p = buf; int i; unsigned size = *(unsigned *)buf;
for (i=0; i<size/4; i++)
printf("%04x: 0x%08x\n", i*sizeof *p, p[i]);
#endif
return ret_val;
}
unsigned mem_alloc(int file_desc, unsigned size, unsigned align, unsigned flags)
{
int i=0;
unsigned p[32];
//printf("Requesting %d bytes\n", size);
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x3000c; // (the tag id)
p[i++] = 12; // (size of the buffer)
p[i++] = 12; // (size of the data)
p[i++] = size; // (num bytes? or pages?)
p[i++] = align; // (alignment)
p[i++] = flags; // (MEM_FLAG_L1_NONALLOCATING)
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned mem_free(int file_desc, unsigned handle)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x3000f; // (the tag id)
p[i++] = 4; // (size of the buffer)
p[i++] = 4; // (size of the data)
p[i++] = handle;
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned mem_lock(int file_desc, unsigned handle)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x3000d; // (the tag id)
p[i++] = 4; // (size of the buffer)
p[i++] = 4; // (size of the data)
p[i++] = handle;
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned mem_unlock(int file_desc, unsigned handle)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x3000e; // (the tag id)
p[i++] = 4; // (size of the buffer)
p[i++] = 4; // (size of the data)
p[i++] = handle;
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned execute_code(int file_desc, unsigned code, unsigned r0, unsigned r1, unsigned r2, unsigned r3, unsigned r4, unsigned r5)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x30010; // (the tag id)
p[i++] = 28; // (size of the buffer)
p[i++] = 28; // (size of the data)
p[i++] = code;
p[i++] = r0;
p[i++] = r1;
p[i++] = r2;
p[i++] = r3;
p[i++] = r4;
p[i++] = r5;
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned qpu_enable(int file_desc, unsigned enable)
{
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x30012; // (the tag id)
p[i++] = 4; // (size of the buffer)
p[i++] = 4; // (size of the data)
p[i++] = enable;
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigned noflush, unsigned timeout) {
int i=0;
unsigned p[32];
p[i++] = 0; // size
p[i++] = 0x00000000; // process request
p[i++] = 0x30011; // (the tag id)
p[i++] = 16; // (size of the buffer)
p[i++] = 16; // (size of the data)
p[i++] = num_qpus;
p[i++] = control;
p[i++] = noflush;
p[i++] = timeout; // ms
p[i++] = 0x00000000; // end tag
p[0] = i*sizeof *p; // actual size
mbox_property(file_desc, p);
return p[5];
}
int mbox_open() {
int file_desc;
// Open a char device file used for communicating with kernel mbox driver.
file_desc = open(VCIO_DEVICE_FILE_NAME, 0);
if(file_desc >= 0) {
printf("Using mbox device " VCIO_DEVICE_FILE_NAME ".\n");
return file_desc;
}
// Try to create one
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_A, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
printf("Using local mbox device file with major %d.\n", MAJOR_NUM_A);
return file_desc;
}
unlink(LOCAL_DEVICE_FILE_NAME);
if(mknod(LOCAL_DEVICE_FILE_NAME, S_IFCHR|0600, makedev(MAJOR_NUM_B, 0)) >= 0 &&
(file_desc = open(LOCAL_DEVICE_FILE_NAME, 0)) >= 0) {
printf("Using local mbox device file with major %d.\n", MAJOR_NUM_B);
return file_desc;
}
return file_desc;
}
void mbox_close(int file_desc) {
close(file_desc);
}

Wyświetl plik

@ -1,50 +0,0 @@
/*
Copyright (c) 2012, Broadcom Europe Ltd.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include <linux/ioctl.h>
// Newer kernels (>= 4.1) use major 249, older ones major 100.
#define MAJOR_NUM_A 249
#define MAJOR_NUM_B 100
#define IOCTL_MBOX_PROPERTY _IOWR(MAJOR_NUM_B, 0, char *)
#define LOCAL_DEVICE_FILE_NAME "/dev/rpidatv-mb"
#define VCIO_DEVICE_FILE_NAME "/dev/vcio"
int mbox_open();
void mbox_close(int file_desc);
unsigned get_version(int file_desc);
unsigned mem_alloc(int file_desc, unsigned size, unsigned align, unsigned flags);
unsigned mem_free(int file_desc, unsigned handle);
unsigned mem_lock(int file_desc, unsigned handle);
unsigned mem_unlock(int file_desc, unsigned handle);
void *mapmem(unsigned base, unsigned size);
void *unmapmem(void *addr, unsigned size);
unsigned execute_code(int file_desc, unsigned code, unsigned r0, unsigned r1, unsigned r2, unsigned r3, unsigned r4, unsigned r5);
unsigned execute_qpu(int file_desc, unsigned num_qpus, unsigned control, unsigned noflush, unsigned timeout);
unsigned qpu_enable(int file_desc, unsigned enable);

Wyświetl plik

@ -0,0 +1,761 @@
// OPERA_Decode_Test.cpp : Defines the entry point for the console application.
//
// Purpose : to study coding and decoding of OPERA which was developed by EA5HVK.
//
// Usage : "OPERA_Decode_Test [? | d | s | w]
// where : s= help, d = debug, s = AA1AA and w = 7L1RLL
//
// Version : 1.0.3, 11/27/2015 change print_char() to print_str()
// Version : 1.0.2, 11/27/2015 bug fix at unpack(), and add 7L1RLL as a 2nd sample.
// Version : 1.0.1, 11/27/2015 Add a function of print_char()
// Version : 1.0.0, 11/25/2015 Initial Release, but under construction on error correction.
//
// Copyright : 7L1RLL(Rick Wakatori) 2015 under Terms of The GNU General
// Public License.
//
// Environments : Microsoft Visual C++ 2010 Express under Windows 10.
// Compiler version : 10.0.40219.1 SPIRel
//
// Acknowledgements :
// a)EA5HVK(Jose) for work on OPERA
// b)F4GCB(Patrick) for PIC program on CRC16 which is a copy into this program.
// c)PE1NNZ(Guido), for Article titled Opera Protocol Specification.
//#include "stdafx.h"
#include "stdio.h"
#include "math.h"
#include "string.h"
short int call_AA1AA[239] =
{ // callsign = "AA1AA"
1,0,1,1, 0,1,0,0, 1,0,1,1, 0,0,1,0, // 0xB4, 0xB2
1,1,0,0, 1,1,0,1, 0,0,1,1, 0,0,1,0, // 0xCD, 0x32
1,0,1,0, 1,1,0,0, 1,0,1,1, 0,0,1,1, // 0xAC, 0xB3
0,1,0,0, 1,0,1,0, 1,1,0,0, 1,1,0,0, // 0x4A, 0xCC
1,1,0,0, 1,1,0,1, 0,0,1,1, 0,0,1,0, // 0xCD, 0x32
1,0,1,0, 1,0,1,1, 0,0,1,1, 0,1,0,1, // 0xA9, 0x35
0,1,0,0, 1,1,0,0, 1,1,0,1, 0,1,0,0, // 0x4C, 0xD4
1,0,1,1, 0,1,0,0, 1,0,1,0, 1,1,0,1, // 0xB4, 0xAD
0,0,1,1, 0,1,0,0, 1,1,0,1, 0,1,0,0, // 0x34, 0xD4
1,1,0,0, 1,0,1,0, 1,0,1,1, 0,0,1,1, // 0xCA, 0xB3
0,0,1,0, 1,0,1,0, 1,1,0,1, 0,1,0,0, // 0x2A, 0xD4
1,0,1,0, 1,1,0,1, 0,1,0,1, 0,1,0,1, // 0xAD, 0x55
0,1,0,0, 1,0,1,0, 1,1,0,1, 0,0,1,1, // 0x4A, 0xD3
0,0,1,1, 0,1,0,1, 0,0,1,0, 1,1,0,0, // 0x35, 0x2C
1,1,0,1, 0,1,0,0, 1,1,0,0, 1,0,1 // 0xD4, 0xCA
};
short int call_F5OEO[239] = {1,0,1,1, 0,1,0,1, 0,0,1,0, 1,1,0,1, 0,1,0,1, 0,1,0,1, 0,1,0,0, 1,1,0,1, 0,1,0,0, 1,1,0,0,
1,1,0,0, 1,1,0,0, 1,0,1,0, 1,1,0,1, 0,1,0,1, 0,0,1,0, 1,0,1,0, 1,1,0,1, 0,0,1,1, 0,1,0,0,
1,0,1,0, 1,0,1,1, 0,1,0,1, 0,1,0,1, 0,0,1,0, 1,0,1,0, 1,1,0,1, 0,0,1,1, 0,0,1,1, 0,0,1,0,
1,1,0,0, 1,1,0,1, 0,0,1,0, 1,1,0,1, 0,1,0,1, 0,1,0,0, 1,0,1,1, 0,1,0,0, 1,0,1,1, 0,0,1,1,
0,1,0,1, 0,0,1,1, 0,1,0,1 ,0,1,0,0, 1,0,1,0, 1,0,1,0, 1,1,0,1, 0,1,0,0, 1,1,0,1, 0,1,0,1,
0,0,1,0, 1,0,1,1, 0,0,1,0, 1,1,0,1 ,0,0,1,1, 0,1,0,1, 0,0,1,1, 0,1,0,0, 1,1,0,0, 1,0,1
};
short int call_7L1RLL[239] =
{
1,0,1,0, 1,1,0,1, 0,0,1,0, 1,1,0,1, // 0xAD, 0x2D
0,0,1,0, 1,0,1,0, 1,1,0,0, 1,0,1,0, // 0x2A, 0xCA
1,0,1,0, 1,0,1,0, 1,0,1,1, 0,1,0,0, // 0xAA, 0xB4
1,0,1,1, 0,0,1,0, 1,0,1,0, 1,0,1,1, // 0xB2, 0xAB
0,0,1,1, 0,1,0,1, 0,0,1,0, 1,0,1,0, // 0x35, 0x2A
1,0,1,0, 1,0,1,1, 0,1,0,1, 0,0,1,1, // 0xAB, 0x53
0,0,1,1, 0,0,1,0, 1,1,0,0, 1,1,0,0, // 0x32, 0xCC
1,1,0,1, 0,0,1,0, 1,0,1,0, 1,0,1,1, // 0xD2, 0xAB
0,0,1,1, 0,0,1,0, 1,1,0,0, 1,0,1,1, // 0x32, 0xCB
0,1,0,0, 1,1,0,0, 1,1,0,1, 0,1,0,1, // 0x4C, 0xD5
0,1,0,1, 0,0,1,1, 0,1,0,1, 0,0,1,1, // 0x53, 0x53
0,0,1,0, 1,1,0,0, 1,1,0,0, 1,1,0,1, // 0x2C, 0xCD
0,1,0,0, 1,1,0,1, 0,1,0,0, 1,0,1,1, // 0x4D, 0x4B
0,1,0,0, 1,1,0,0, 1,0,1,1, 0,1,0,0, // 0x4C, 0xB4
1,0,1,0, 1,0,1,0, 1,0,1,0, 1,1,0 // 0xAA, 0xAC
};
short int interleave_target[119] =
{ //after interleave
1,0,0,1, 1,0,1,1, 0,1,0,0, 1,0,1,1, //0x9B, 0x4B
1,1,0,1, 1,0,1,0, 0,1,1,1, 0,1,0,1, //0xDA, 0x75
0,1,0,0, 1,0,1,1, 1,1,1,0, 1,0,0,0, //0x4B, 0xE8
0,1,0,1, 0,0,0,1, 1,0,0,1, 1,1,0,0, //0x51, 0x9C
1,0,0,1, 0,0,0,1, 0,1,1,1, 1,0,1,0, //0x91, 0x7A
1,1,1,1, 0,0,0,1, 1,1,0,0, 0,0,0,0, //0xF1, 0xC0
0,1,1,1, 0,0,1,0, 1,0,0,0, 1,1,0,1, //0x72, 0x8D
0,0,0,1, 0,1,1 //0x16
};
short int before_interleave_target[119] =
{ // before interleave
1,1,0,1, 0,0,1,0, 0,0,0,0, 0,0,0,1, // 0xD2, 0x01
1,0,0,1, 1,1,1,0, 0,1,1,0, 1,0,1,1, // 0x9E, 0x6B
0,1,0,0, 1,1,1,1, 0,0,1,0, 1,0,1,0, // 0x4F, 0x2A
1,1,0,1, 0,1,0,1, 0,1,1,1, 1,0,0,1, // 0xD5, 0x79
1,0,1,0, 0,1,0,1, 1,1,1,0, 0,0,0,0, // 0xA5, 0xE0
0,0,0,0, 1,1,0,0, 1,1,0,0, 0,0,1,1, // 0x0C, 0xC3
1,1,1,1, 0,0,1,1, 0,1,0,1, 0,1,0,1, // 0xF3, 0x55
1,1,0,1, 0,0,1 // 0xD2
};
short int walsh_matrix[8][7] = {
{0,0,0,0,0,0,0},{1,0,1,0,1,0,1},{0,1,1,0,0,1,1},{1,1,0,0,1,1,0},
{0,0,0,1,1,1,1},{1,0,1,1,0,1,0},{0,1,1,1,1,0,0},{1,1,0,1,0,0,1}
};
short int pseudo_sequence[51] =
{
1,1,1,0, 0,0,0,1, 0,1,0,1, 0,1,1,1, // 0xE1, 0x57
1,1,1,0, 0,1,1,0, 1,1,0,1, 0,0,0,0, // 0xE6, 0xD0
0,0,0,1, 1,0,0,1, 0,0,0,1, 0,1,0,1, // 0x19, 0x15
0,1,1 // 0x60
};
char before_scramble_target[52] =
"000000000110110001101111000011110001111000001100100";
short int before_WH_target[52] =
{
1,1,1,0, 0,0,0,1, 0,0,1,1, 1,0,1,1, // 0xE1, 0x3B
1,0,0,0, 1,0,0,1, 1,1,0,1, 1,1,1,1, // 0x89, 0xDF
0,0,0,0, 0,1,1,1, 0,0,0,1, 1,0,0,1, // 0x07, 0x19
1,1,1 // 0xE0
};
char packed_target[29] ="0000011011000110111100001111"; //0x0606F0F
char call_target[7] = "AA1AA ";
// **** Grobal variables ****
short int symbol[239]; // to be decode
short int interleaved[119];
short int before_interleave[119];
short int error_position[239]; // does not use in V1.0.0
short int before_WH[51];
char before_scramble[51];
char packed[28];
char call[7];
short int DEBUG = 0;
// **** functions ****
void decode_opera(short int symbol[239]);
void manchester_decode(short int symbol[239], short int interleaved[119]);
void de_interleave(short int interleaved[119], short int before_interleave[119]);
void de_walsh_matrix(short int before_interleave[119], short int before_WH[51]);
void de_scramble(short int befor_WH[51], char before_scramble[51]);
void de_crc(char before_scramble[51], char packed[28]);
void generate_crc(char datas[28], char crc[17], int length);
void unpack(char packed[28], char call[7]);
char de_normalizer(int bc, int byte_num);
void print_help();
void print_short_int(const char* caption, short int* code, int length);
void print_str(const char* caption, char* code);
void strcpy_w(char * s1, char * s2, int length);
void strcat_w(char * s1, char * s2, int lenS1, int lenS2);
//**********************************
int main(int argc, char* argv[])
//**********************************
{
char s1 = 0x00;
int i;
printf("argc=%d\n", argc);
switch(argc)
{
case 1 : // Help required
{
printf("%s\n","More argument is required !");
print_help();
return 0;
}
case 2 : // 2 arguments
{
s1 = (char) argv[1][0];
if ((s1 == '?') && (argv[1][1] == 0x00))
{
printf("%s\n", "Help selected");
print_help();
return 0;
}
else if ((s1 == 'd' || s1 == 's' || s1 == 'w') && (argv[1][1] == 0x00))
{
if (s1 =='d')
{
printf("%s\n", "Debug selected.");
DEBUG = 1;
for (i = 0; i < 239; i++)
symbol[i] = call_AA1AA[i];
decode_opera(symbol);
DEBUG = 0;
return 0;
}
else if (s1 == 's')
{
printf("%s\n", "Sample selected.");
for (i = 0; i < 239; i++)
symbol[i] = call_F5OEO[i];
decode_opera(symbol);
DEBUG = 0;
return 0;
}
else
{
printf("%s\n", "Sample 7L1RLL selected.");
DEBUG = 0;
for (i = 0; i < 239; i++)
symbol[i] = call_7L1RLL[i];
decode_opera(symbol);
DEBUG = 0;
return 0;
}
}
}
default : // 3 arguments
{
printf("%s\n", "Too many arguments.");
print_help();
return 0;
}
}
} // end of _tmain()
//**************************************************
void decode_opera(short int * symbol)
//**************************************************
{
print_short_int("symbol given =", symbol, 239);
manchester_decode(symbol, interleaved);
print_short_int("de_manchester code =", interleaved, 119);
if (DEBUG)
print_short_int("de_manchester_target =", interleave_target, 119);
de_interleave(interleaved, before_interleave);
print_short_int("de_interleave =", before_interleave, 119);
if (DEBUG)
print_short_int("de_interleave_target =", before_interleave_target, 119);
de_walsh_matrix(before_interleave, before_WH);
print_short_int("de_Walsh-Hamadard =", before_WH, 51);
if (DEBUG)
print_short_int("de_WH_target =", before_WH_target, 51);
de_scramble(before_WH, before_scramble);
print_str("de_scramble = ", before_scramble);
if (DEBUG)
print_str("de_scramble_target = ", before_scramble_target);
de_crc(before_scramble, packed);
print_str("de_CRC = ", packed);
if (DEBUG)
print_str("de_CRC_target = ", packed_target);
unpack(packed, call);
printf("unpached call = %s\n", call);
if (DEBUG)
printf("call_target = %s\n", call_target);
} // end of decode_opera()
//***********************************************************************
void manchester_decode(short int* symbol, short int* symbol_interleaving)
//***********************************************************************
{
int i = 0;
int idx = 0; // delete start 2 bit
while (idx < 238)
{
if ((symbol[idx + 1] == 1) && (symbol[idx + 2] == 0))
{
symbol_interleaving[i] = (short) 0;
}
else if ((symbol[idx + 1] == 0) && (symbol[idx + 2] == 1))
{
symbol_interleaving[i] = (short) 1;
}
else
{
error_position[idx] = (short) 1;
}
i++; idx += 2;
}
} // end of manchester_decode()
//************************************************************************
void de_interleave(short int* interleaved, short int* before_interleave)
//************************************************************************
{
int i =0, idx = 0, j = 0;
for (i = 0; i < 7; i++)
{
for (j = i; j < 119; j += 7)
{
before_interleave[j] = interleaved[idx];
idx++;
}
}
} // end of de_interleave
//*********************************************************************
void de_walsh_matrix(short int* vector_to_tx, short int* symbol_coding)
//*********************************************************************
{ // 119 bit to 51 bit
int idx = 0, i, j, k, data = 0;
short int temp[7];
for (i = 0; i < 119; i += 7)
{
for(j = 0; j < 7; j++) temp[j] = vector_to_tx[i + j];
temp[7]=0x00;
// search the value for match
data = 0;
for (k = 0; k < 7; k++)
{
if (k < 6)
{
data = data + (int) pow((double)(temp[k]*2), (6 - k));
}
else if (k == 6)
{
if (temp[6] == 1) data = data + 1;
}
}
if (data == 0) // 0000000 = 0
{
symbol_coding[idx + 0] = 0;
symbol_coding[idx + 1] = 0;
symbol_coding[idx + 2] = 0;
}
else if (data == 85) // 1010101 = 2^6 + 2^4 + 2^2 + 1 = 85
{
symbol_coding[idx + 0] = 0;
symbol_coding[idx + 1] = 0;
symbol_coding[idx + 2] = 1;
}
else if (data == 51) // 0110011 = 2^5 + 2^4 + 2 + 1 = 51
{
symbol_coding[idx + 0] = 0;
symbol_coding[idx + 1] = 1;
symbol_coding[idx + 2] = 0;
}
else if (data == 102) // 1100110 = 2^6 + 2^5 + 2^2 + 2 = 102
{
symbol_coding[idx + 0] = 0;
symbol_coding[idx + 1] = 1;
symbol_coding[idx + 2] = 1;
}
else if (data == 15) // 0001111 = 2^3 + 2^2 + 2 + 1 = 15
{
symbol_coding[idx + 0] = 1;
symbol_coding[idx + 1] = 0;
symbol_coding[idx + 2] = 0;
}
else if (data == 90) // 1011010 = 2^6 + 2^4 + 2^3 + 2 = 90
{
symbol_coding[idx + 0] = 1;
symbol_coding[idx + 1] = 0;
symbol_coding[idx + 2] = 1;
}
else if (data == 60) //0111100 = 2^5 + 2^4 + 2^3 + 2^2 = 60
{
symbol_coding[idx + 0] = 1;
symbol_coding[idx + 1] = 1;
symbol_coding[idx + 2] = 0;
}
else if (data == 105) // 1101001 = 2^6 + 2^5 + 2^3 + 1 = 105
{
symbol_coding[idx + 0] = 1;
symbol_coding[idx + 1] = 1;
symbol_coding[idx + 2] = 1;
}
else printf("xxxx");
idx +=3;
}
} // enf of de-WH
//************************************************************
void de_scramble(short int * vector_to_tx, char * vector)
//************************************************************
{ // | 51 bit | to | 51 bit |
short int vector_temp[51];
int i;
// convert binary to ASCII
for (i = 0; i < 51; i++)
{
vector_temp[i] = vector_to_tx[i] ^ pseudo_sequence[i];
vector[i] = (char) vector_temp[i] + 0x30;
}
} //end of de_scramble()
//*************************************************
void de_crc(char * vector, char * packed)
//*************************************************
{ // 51 bits to 28bits
char crc1[17], crc1a[17], crc2[4], crc2a[4];
int i, crc_ok;
char temp[52] = {0};
// extract packed from received data
for (i = 0; i < 28; i++) //4..31 for packed
packed[i] = temp[i] = vector[i + 4];
packed[28] = temp[28] = 0x00;
if (DEBUG)
print_str("temp in de_crc = ", temp);
if (DEBUG)
print_str("packed in de_crc = ", packed);
// extract crc1 from received data
for (i = 0; i < 16; i++) //32..47 for crc1
crc1[i] = vector[i + 32];
crc1[16] = 0x00;
if (DEBUG)
print_str("crc1 exracted from received data = ", crc1);
//crc2 extracted from received data
for (i = 0; i < 3; i++) //48..50 for crc2
crc2[i] = vector[i + 48];
crc2[3] = 0x00;
if (DEBUG)
print_str("crc2 extracted from received data = ", crc2);
generate_crc(temp, crc1a, 16);
if (DEBUG)
print_str("temp before crc add = ", temp);
if (DEBUG)
print_str("crc1a calcurated = ", crc1a);
strcat_w(temp, crc1a, 28, 16); // 28 + 16 = 44
generate_crc(temp, crc2a, 3);
strcat_w(temp, crc2a, 44, 3); // 44 + 3 = 47
// verify crc1 and crc2
crc_ok = 1;
for (i = 0; i < 16; i++)
if (crc1[i] != crc1a[i]) crc_ok = 0;
for (i = 0; i < 3; i++)
if (crc2[i] != crc2a[i]) crc_ok = 0;
if (crc_ok)
printf("CRC : OK\n");
else
{
printf("CRC : No good\n");
print_str("crc1a calcurated = ", crc1a);
print_str("crc1_received = ", crc1);
print_str("crc2a calcurated = ", crc2a);
print_str("crc2a_received = ", crc2);
}
} //end of de_crc()
//************************************************************************
void generate_crc(char * datas, char * crc, int length)
//************************************************************************
{ // 32 + 16(length) = 48 or 48 + 3(length) = 51
// CRC16-IBM : Polynominal = X16+X15+X2+1 = 1000 0000 0000 0101
// This function is a copy of JUMA TX136/500 control program
// whitch was written by F4GCB (Patrick). Thanks Patrick.
int i, j, k, len;
char buffer[52];
short int wcrc[17] = {0}, byte1 = 0, byte2 = 0;
len = strlen(datas);
for (i = 0; i < len; i++)
buffer[i] = datas[i];
buffer[len] = 0x00;
if (DEBUG)
print_str("input datas in generate_crc =", buffer);
for (i = 0; i < len; i++)
{
for (j = 0; j < 8; j++)
{
if (j > 0) buffer[i] = buffer[i] >> 1;
byte1 = buffer[i] & 0x01;
byte2 = byte1 ^ wcrc[0]; // XOR with X16
wcrc[0] = byte2 ^ wcrc[1]; // XOR with X15
for (k = 1; k < 13; k++)
wcrc[k] = wcrc[k + 1];
wcrc[13] = byte2 ^ wcrc[14]; // XOR with X2
wcrc[14] = wcrc[15]; //
wcrc[15] = byte2; //
}
}
// if msb byte crc = 0 then value at 27
byte2 = 0;
for (i = 0; i < 8; i++)
byte2 = byte2 + (int)(wcrc[i] * pow (2.0, i));
if (byte2 == 0) byte2 = 27; // 0x1B = 0b0001 1011
// if lsb byte crc = 0 then value at 43
byte1 = 0;
for (i = 8; i < 16; i++)
byte1 = byte1 + (int)(wcrc[i] * pow(2.0, i - 8));
if (byte1 == 0) byte1 = 43; // 0x2B = 0b0010 1011
if (DEBUG)
printf("byte1 before replace =%2x, byte2 =%2x\n", byte1, byte2);
// merge crc into a bit string
for (i = 0; i < 8; i++)
{
if (i > 0) byte2 = byte2 >> 1;
wcrc[7 - i] = byte2 & 0x01; // (binary)
if (i > 0) byte1 = byte1 >> 1;
wcrc[15 - i] = byte1 & 0x01; // (binary)
}
if (length > 16) length = 16;
for (i = 16 - length; i < 16; i++)
crc[i - (16 - length)] = wcrc[i] + 0x30;
crc[length]= 0x00;
if (DEBUG)
print_str("crc =", crc);
} // end of generate_crc()
//*************************************
void unpack(char * packed, char * call)
//*************************************
{ // 28 bits to 48 bits
int i;
int temp;
unsigned long code_sum = 0, remains = 0;
if (DEBUG)
print_str("packed in unpack = ", packed);
// separate a string to coded callsign
for (i = 0; i < 28; i++)
code_sum = code_sum + (unsigned long)(packed[27 - i] - '0') * pow(2.0, i);
// de_normalizer of callsign
remains = 36*10*27*27*27;
if (DEBUG)
{
printf(" 0 : code_sum = %9Lu\n", code_sum);
printf(" 0 : remains = %9Lu\n", remains);
}
if (code_sum > remains)
{
temp = code_sum / remains;
code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 0 : temp = %9Lu\n", temp);
call[0] = de_normalizer(temp, 0);
remains = 10*27*27*27;
if (DEBUG)
{
printf(" 1 : code_sum = %9Lu\n", code_sum);
printf(" 1 : remains = %9Lu\n", remains);
}
if (code_sum >= remains)
{
temp = code_sum / remains;
code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 1 : temp = %9Lu\n", temp);
call[1] = de_normalizer(temp, 1);
remains = 27*27*27;
if (DEBUG)
{
printf(" 2 : code_sum = %9Lu\n", code_sum);
printf(" 2 : remains = %9Lu\n", remains);
}
if (code_sum >= remains)
{
temp = code_sum / remains;
code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 2 : temp = %9Lu\n", temp);
call[2] = de_normalizer(temp, 2);
remains = 27*27;
if (DEBUG)
{
printf(" 3 : code_sum = %9Lu\n", code_sum);
printf(" 3 : remains = %9Lu\n", remains);
}
if (code_sum >= remains)
{
temp = code_sum / remains;
code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 3 : temp = %9Lu\n", temp);
call[3] = de_normalizer(temp, 3);
remains = 27;
if (DEBUG)
{
printf(" 4 : code_sum = %9Lu\n", code_sum);
printf(" 4 : remains = %9Lu\n", remains);
}
if (code_sum >= remains)
{
temp = code_sum / remains;
code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 4 : temp = %9Lu\n", temp);
call[4] = de_normalizer(temp, 4);
remains = 1;
if (DEBUG)
{
printf(" 5 : code_sum = %9Lu\n", code_sum);
printf(" 5 : remains = %9Lu\n", remains);
}
if (code_sum >= remains)
{
temp = code_sum;
//code_sum %= remains;
}
else temp = 0;
if (DEBUG)
printf(" 5 : temp = %9Lu\n", temp);
call[5] = de_normalizer(temp, 5);
call[6] = 0x00;
} // end of unpack
//********************************
char de_normalizer(int bc, int n)
//********************************
{
char cc = 0;
if (DEBUG)
printf(" %u : input of de_normalizer, bc = %9Lu\n", n, bc);
switch (n)
{
case 0 :
{
if (bc == 0) cc = ' ';
else if (bc >= 1 && bc <= 26) cc = bc - 1 +'A';
else if (bc >= 27 && bc <= 37) cc = bc - 27 + '0';
break;
}
case 1 :
{
if (bc >= 0 && bc <= 25) cc = bc + 'A';
else if (bc >= 26 && bc <= 36) cc = bc - 26 + '0';
break;
}
case 2 :
{
if (bc >= 0 && bc <= 9) cc = bc + '0';
break;
}
case 3: case 4: case 5:
{
if (bc == 0) cc = ' ';
else if (bc >= 1 && bc <= 26) cc = bc - 1 + 'A';
break;
}
default : break;
}
if (DEBUG)
printf(" %u : output of de_normalizer, cc = %c\n", n, cc);
return (cc);
} // end of de _normlizer
//********************************************************************
void print_short_int(const char *caption, short int *code, int length)
//********************************************************************
{ // This is a service function for debugging
int i = 0;
printf("%s\n", caption);
for (i = 0; i < length; i++)
{
printf("%u", code[i]);
if (((i + 1) % 4) == 0) printf(" ");
if (((i + 1) % 40) == 0) printf("\n");
}
printf("\n");
} // end fo print_short_int
//********************************************************************
void print_short_char(const char * caption, char * code, int length)
//********************************************************************
{ // This is a service function for debugging
int i = 0;
printf("%s\n", caption);
for (i = 0; i < length; i++)
{
printf("%c", code[i]);
if (((i + 1) % 4) == 0) printf(" ");
if (((i + 1) % 40) == 0) printf("\n");
}
printf("\n");
} // end fo print_short_char
//********************************************************************
void print_str(const char * caption, char * code)
//********************************************************************
{ // This is a service function for debugging
int i = 0;
printf("%s\n", caption);
for (i = 0; i < strlen(code); i++)
{
printf("%c", code[i]);
if (((i + 1) % 4) == 0) printf(" ");
if (((i + 1) % 40) == 0) printf("\n");
}
printf("\n");
} // end fo print_char
//*******************************************************
void strcpy_w(char * s1, char * s2, int length)
//*******************************************************
{
int i;
for (i = 0; i < length; i++)
s1[i] = s2[i];
s1[length] = 0x00;
} // end of strcpy_w
//****************************************************************
void strcat_w(char * s1, char * s2, int lenS1, int lenS2)
//****************************************************************
{
int i;
for (i = 0; i < lenS2; i++)
s1[i + lenS1] = s2[i];
s1[lenS1 + lenS2]= 0x00;
} // end of strcat_w()
//***************
void print_help()
//***************
{
printf("%s\n","Usage : OPERA_Decode_Test [ ? | d | s | w]");
printf("%s\n"," Help : OPERA_Decode_Test ?");
printf("%s\n"," Debug : OPERA_Decode_Test d");
printf("%s\n"," AA1AA : OPERA_Decode_Test s");
printf("%s\n"," 7L1RLL : OPERA_Decode_Test w");
printf("%s\n"," Sample callsign is \"AA1AA\". ");
} // end of help
//************** End of Program **************************************

539
src/opera/opera.cpp 100644
Wyświetl plik

@ -0,0 +1,539 @@
//******************************************************************************
// OPERA_Coding_Test.cpp : Defines the entry point for the console application.
//
// Purpose : Algorithm testing by a laptop computer before implementation
// into PIC micro processor.
//
// Usage: "OPERA_Coding_Test [? | d | s] ["callsign"]";
// where : s = help, d = debug and s = sample";
//
// Version 1.0.4, 2015/11/29: Modified print format
// Version 1.0.3, 2015/11/13: Delete an additional start bit for decoder
// Version 1.0.2, 2015/11/11: Add Visual C++ directives
// Version 1.0.1, 2015/11/10: Changed help message
// Version 1.0.0, 2015/11/07: Initial Release
//
// Copyright(C) 2015 F4GCB
// Partial copyright (C)2015 7L1RLL
// Partial copyright (C)2017 F5OEO Add output format to Rpitx RFA Mode
//
// Acknowledgement :
// 1)Portion of this OPERA is derived from the work of EA5HVK.
// 2)All functions of this program are a copy of JUMA-TX500/136
// Transmitter Controller which written by F4GCB.
//******************************************************************************
//#include "stdafx.h"
//#include <locale.h>
//#include <tchar.h>
#include "stdio.h"
#include "cstring"
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "stdint.h"
#include "math.h"
#include <signal.h>
#include <unistd.h>
#include "../librpitx/src/librpitx.h"
bool running=true;
//#define __VCpp__ TRUE
// Grobal Variables
float Frequency=0;
static const short int pseudo_sequence[51] = {
1,1,1,0,0,0,0,1,0,1, 0,1,0,1,1,1,1,1,1,0, 0,1,1,0,1,1,0,1,0,0, 0,0,0,0,0,1,1,0,0,1,
0,0,0,1,0,1,0,1,0,1, 1
};
static short int walsh_matrix[8][7] = {
{0,0,0,0,0,0,0},{1,0,1,0,1,0,1},{0,1,1,0,0,1,1},{1,1,0,0,1,1,0},
{0,0,0,1,1,1,1},{1,0,1,1,0,1,0},{0,1,1,1,1,0,0},{1,1,0,1,0,0,1}
};
static short int symbol[239];
char call[7], call_coded[45], vector[52];
short int vector_to_tx[51];
short int symbol_interleaving[119], symbol_coding[119];
short int DEBUG = 0;
const char sampleCall[7] = "AA1AA";
// Declaration of functions
void genn_opera(float mode);
void generate_call(char call[7], char call_coded[45]);
void add_crc16(char call_coded[45], char vector[52]);
void scramble(char vector[52], short int symbol_coding[119]);
void Walsh_Hammered_code(short int symbol_coding[119], short int vector_to_tx[51]);
void interleave(short int vector_to_tx[51], short int symbol_interleaving[119]);
void ManchesterEncode(short int symbol_interleaving[119], short int symbol[239]);
char chr_norm_opera(char bc);
void print_short_int(const char caption[], short int code[239], int length);
void print_str(const char caption[250], char code[52]);
void strcpy_w(char s1[52], char s2[52], int length);
void strcat_w(char s1[52], char s2[52], int lenS1, int lenS2);
void encodepitx(short int *code, int length,float Nop);
#ifdef __VCpp__
//**********************************
// main forVisual C++
int _tmain(int argc, _TCHAR* argv[])
//**********************************
{
_tsetlocale(LC_ALL, _T("")); //Change Unicode to OS-Default locale
#else
int main(int argc, char* argv[])
//**********************************
{
#endif
int i = 0;
//char s1 = 0x00;
char s2[7] = "";
switch (argc)
{
case 1 : // Help required
case 2 : // Help required
case 3 : // Help required
{
printf("Usage : %s CALLSIGN OperaMode[0.5,1,2,4,8} \n", argv[0]);
return 0;
}
case 4: // 3 arguments
{
//s1 = (char)argv[1][0];
// range check
if (!((argv[1][0] >= '0' && argv[1][0] <= '9') || (argv[1][0] >= 'A' && argv[1][0] <= 'Z') ||
(argv[1][0] >= 'a' && argv[1][0] <= 'z')))
{
printf("%s\n","Callsign must be began with an alphan/numeric character");
return 0;
}
DEBUG = 0; i = 0;
while (argv[1][i] != 0 && i < 7)
{
call[i] = argv[1][i]; call[++i] = 0x00;
}
float Mode=atof(argv[2]);
Frequency=atof(argv[3]);
genn_opera(Mode);
return 0;
}
default:
{
printf("Usage : %s CALLSIGN OperaMode[0.5,1,2,4,8} file.rfa \n", argv[0]);
break;
}
} // end of switch argc
return 0;
} // end of _tmain
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating %x\n",num);
}
//*******************
void genn_opera(float mode)
//*******************
{
printf("\nGenerate Op%.1f Callsign = %s\n",mode,call);
generate_call(call, call_coded);
if (DEBUG)
print_str("call_coded =", call_coded);
add_crc16(call_coded, vector);
if (DEBUG)
print_str("crc16 vector =", vector);
scramble(vector, vector_to_tx);
if (DEBUG)
print_short_int("vector_to_tx =", vector_to_tx, 44);
Walsh_Hammered_code(vector_to_tx, symbol_coding);
if (DEBUG)
print_short_int("symbol_coding =", symbol_coding, 119);
interleave(symbol_coding, symbol_interleaving);
if (DEBUG)
print_short_int("symbol_interleaving =", symbol_interleaving, 119);
ManchesterEncode(symbol_interleaving, symbol);
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
encodepitx(symbol,239,mode);
} // genn_opera
//****************************************************
// Normalize characters space S..Z 0..9 in order 0..36
char chr_norm_opera(char bc)
//****************************************************
{
char cc = 0;
if (bc >= '0' && bc <= '9') cc = bc - '0' + 27;
if (bc >= 'A' && bc <= 'Z') cc = bc - 'A' + 1;
if (bc >= 'a' && bc <= 'z') cc = bc - 'a' + 1;
if (bc == ' ') cc = 0;
return (cc);
} // enf of chr_norm_opera
//**********************************************
void generate_call(char *call, char *call_coded)
//**********************************************
{
int i;
unsigned long code_sum;
//the thired character must always be a number
if (chr_norm_opera(call[2]) < 27)
{
for (i=5; i> 0; i--) call[i] = call[i-1];
call[0]=' ';
}
// the call must always have 6 characters
for (i=strlen(call); i < 6; i++)
call[i] = ' ';
call[6] = 0x00;
if (DEBUG) printf("NormalizedCall=%s\n", call);
code_sum = chr_norm_opera(call[0]);
code_sum = code_sum * 36 + chr_norm_opera(call[1]) - 1;
code_sum = code_sum * 10 + chr_norm_opera(call[2]) - 27;
code_sum = code_sum * 27 + chr_norm_opera(call[3]);
code_sum = code_sum * 27 + chr_norm_opera(call[4]);
code_sum = code_sum * 27 + chr_norm_opera(call[5]);
if (DEBUG) printf("code_sum=%lu\n", code_sum);
// merge coded callsign ino a string
call_coded[28] = 0x00;
call_coded[27] = (short int) ((code_sum & 0x01) + 0x30);
for (i = 26; i >= 0; i--)
{
code_sum = code_sum >> 1;
call_coded[i] = (short int)((code_sum & 0x01) + 0x30);
}
} // end of pack_callsign
//***************************************************
void generate_crc(char *datas, char *crc, int length)
//***************************************************
{
unsigned int i, j, k;
char buffer[52]; //strlen(datas)];
short int wcrc[16] = {0}, byte1 = 0, byte2 = 0;
#ifdef __VCpp__
strcpy_s(buffer, 52, datas);// strcpy(buffer, datas);
#else
strcpy(buffer, datas);// strcpy(buffer, datas);
#endif
if (DEBUG)
print_str("buffer_crc = ", buffer);
for (i = 0; i < strlen(datas); i++)
{
for (j = 0; j < 8; j++)
{
if (j > 0) buffer[i] = buffer[i] >> 1;
byte1 = buffer[i] & 0x01;
byte2 = byte1 ^ wcrc[0];
wcrc[0] = byte2 ^ wcrc[1];
for (k = 1; k < 13; k++)
wcrc[k] = wcrc[k+1];
wcrc[13] = byte2 ^ wcrc[14];
wcrc[14] = wcrc[15];
wcrc[15] = byte2;
}
}
// if msb byte crc = 0 then value at 27
byte2 = 0;
for (i = 0; i < 8; i++)
#ifdef __VCpp__ // add for Visual C++ by 7L1RLL 11/07/2015
byte2 = byte2 + (short) wcrc[i] * pow((double)2.0, (int)i);
#else
byte2 = byte2 + wcrc[i] * pow(2, i);
#endif
if (byte2 == 0) byte2 =27;
// if lsb byte crc = 0 then value at 43
byte1 = 0;
for (i = 8; i < 16; i++)
#ifdef __VCpp__
byte1 = byte1 + (short) (wcrc[i] * (double)pow(2.0, (int)i - 8)); // add cast by 7L1RLL
#else
byte1 = byte1 + (wcrc[i] * pow(2, i - 8));
#endif
if (byte1 == 0) byte1 = 43;
if (DEBUG) printf("byte1 = %x, byte2 = %x\n", byte1, byte2);
// merge crc into a string
for (i = 0; i < 8; i++)
{
if (i > 0) byte2 = byte2 >> 1;
wcrc[7 - i] = byte2 & 0x01;
if ( i > 0) byte1 = byte1 >> 1;
wcrc[15 - i] = byte1 & 0x01;
}
if (length > 16) length = 16;
for (i = 16 - length; i < 16; i++)
crc[i - (16 - length)] = wcrc[i] + 0x30;
crc[length] = 0x00;
} // end of genarate_crc
//*********************************************
void add_crc16(char * call_coded, char *vector)
//*********************************************
{ // input: |28 bits|, output : |51 bits|
char crc1[17] = "", crc2[4] = "";
#ifdef __VCpp__ // for wide character compiler
char temp[52] = "";
_tsetlocale(LC_ALL, _T("")); //Change Unicode to OS-Default locale
if (DEBUG)
print_str("call_coded in add CRC16 =", call_coded);
strcpy_w(temp, call_coded, 28); // 28 bit
if (DEBUG)
print_str("temp in add CRC16=", temp);
generate_crc(call_coded, crc1, 16);
if (DEBUG)
print_str("crc1 =", crc1);
strcat_w(temp, crc1, 28, 16); // 28 + 16 = 44
generate_crc( temp, crc2, 3);
if (DEBUG)
print_str("crc2 =", crc2);
#else // PIC C compiler using ASCII
// char crc1[17] = "", crc2[4] = "";
generate_crc(call_coded, crc1, 16);
if (DEBUG) printf("crc1 =%s\n", crc1);
generate_crc(strcat(call_coded, crc1), crc2, 3);
if (DEBUG) printf("crc2 =%s\n", crc2);
#endif
// |4 bits sync| + |28 bits call| + |19 bit crc|
#ifdef __VCpp__
strcpy_w(vector, "0000", 4); // 4
strcat_w(vector, temp, 4, 44); // 4 + 44 = 48
strcat_w(vector, crc2, 48, 3); // 48 + 3 = 51
#else // not VC++ ex : PIC
strcpy(vector, "0000"); // 4
strcat(vector, call_coded); // 4 + 44 = 48
strcat(vector, crc2); // 48 + 3 = 51
#endif
} // end of add_crc16
//**************************************************
void scramble(char *vector, short int *vector_to_tx)
//**************************************************
{ // encoding |51 bits|
int i=0;
for (i = 0; i < 51; i++)
{
vector_to_tx[i] = vector[i] & 0x01;
// convert ASCII to binary
vector_to_tx[i] = vector_to_tx[i] ^ pseudo_sequence[i];
}
} // end of scrambling
//*************************************************************************
void Walsh_Hammered_code(short int *vector_to_tx, short int *symbol_coding)
//*************************************************************************
{ // order 8 walsh matrix codification : |119 bits|
int data = 0, idx = 0, i = 0, j = 0;
for (i = 0; i < 51; i += 3)
{
data = 0;
for (j = 0; j < 3; j++)
data = data + (vector_to_tx[i + j] << (2 - j));
for (j = 0; j < 7; j++)
{
symbol_coding[idx] = walsh_matrix[data][j];
idx++;
}
}
} //end of Walsh_Hammered_code
//***********************************************************************
void interleave(short int *symbol_coding, short int *symbol_interleaving)
//***********************************************************************
{ // interleaving : |119 bits|
int idx = 0, i = 0, j = 0;
idx = 0;
for (i = 0; i < 7; i++)
{
for (j = i; j < 119; j += 7)
{
symbol_interleaving[idx]= symbol_coding[j];
idx++;
}
}
} // end of interleave
//**********************************************************************
void ManchesterEncode(short int *symbol_interleaving, short int *symbol)
//**********************************************************************
{ // manchester codification : |11| + |238 bits| - |1 bit| modified by 7L1RLL 11/07/2015
int idx = 0;
int i = 0, j = 0;
symbol[0] = 1;
for (i = 0; i < 119; i++)
{
if (symbol_interleaving[i] == 0)
{
symbol[idx + 1] = 1;
symbol[idx + 2] = 0;
}
else
{
symbol[idx + 1] = 0;
symbol[idx + 2] = 1;
}
idx += 2;
}
} // end of Manchester_encode
//***************
void print_help()
//***************
{
printf("%s\n","Usage : OPERA_Coding_Test [? | s | [d \"callsign\"]]");
printf("%s\n"," Normal : OPERA_Coding_Test \"callsign\"");
printf("%s\n"," Help : OPERA_Coding_Test ?");
printf("%s\n"," Sample : OPERA_Coding_Test s");
printf("%s\n"," Debug : OPERA_Coding_Test d \"callsign\"");
printf("%s\n"," Callsign format shall be like \"AA1AAA\". ");
printf("%s\n"," Third character mast be a numeric character(0..9).");
} // end of help
//********************************************************************
void print_short_int(const char *caption, short int *code, int length)
//********************************************************************
{ // This is service function for debugging
int i = 0;
printf("%s\n", caption);
for (i = 0; i < length; i++)
{
printf("%d", code[i]);
if (((i+1) % 4) == 0) printf(" ");
if (((i+1) % 40) == 0) printf("\n");
}
printf("\n");
} // end fo print_short_int
void encodepitx(short int *code, int length,float Nop)
{
/*and each of the
239 symbols are transmitted by keying the transmitter as CW on and off with a symbol
rate of 0.256*n s/symbol, where n is the integer of operation mode OPn that corresponds
with the Opera frequency recommendation: */
int SR=1e4/((0.256*Nop));
fprintf(stderr,"SR=%d\n",SR);
int FifoSize=512;
amdmasync amtest(Frequency,SR,14,FifoSize);
int count=0;
for (int i = 0; (i < length-1)&&(running==true); )
{
int Available=amtest.GetBufferAvailable();
if(Available>FifoSize/2)
{
int Index=amtest.GetUserMemIndex();
for(int j=0;j<Available;j++)
{
if(i==-1)
amtest.SetAmSample(Index+j,1);
else
amtest.SetAmSample(Index+j,code[i]);
count++;
if(count>1e4)
{
count=0;
i++;
}
}
}
else
usleep(100);
}
}
//********************************************************************
void print_str(const char * caption, char * code)
//********************************************************************
{ // This is a service function for debugging
size_t i = 0;
printf("%s\n", caption);
for (i = 0; i < strlen(code); i++)
{
printf("%c", code[i]);
if (((i + 1) % 4) == 0) printf(" ");
if (((i + 1) % 40) == 0) printf("\n");
}
printf("\n");
} // end fo print_str
//*******************************************************
void strcpy_w(char * s1, char * s2, int length)
//*******************************************************
{
int i;
for (i = 0; i < length; i++)
s1[i] = s2[i];
s1[length] = 0x00;
} // end of strcpy_w
//****************************************************************
void strcat_w(char * s1, char * s2, int lenS1, int lenS2)
//****************************************************************
{
int i;
for (i = 0; i < lenS2; i++)
s1[i + lenS1] = s2[i];
s1[lenS1 + lenS2]= 0x00;
} // end of strcat_w()
//************** End of Program ********************************

674
src/pifmrds/LICENSE 100644
Wyświetl plik

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
{one line to give the program's name and a brief idea of what it does.}
Copyright (C) {year} {name of author}
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
{project} Copyright (C) {year} {fullname}
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

Wyświetl plik

@ -0,0 +1,213 @@
Pi-FM-RDS
=========
## FM-RDS transmitter using the Raspberry Pi
This program generates an FM modulation, with RDS (Radio Data System) data generated in real time. It can include monophonic or stereophonic audio.
This version modulates the PLL instead of the clock divider for superior signal purity. The harmonics are unaffected, so the [legal warning](#warning-and-disclaimer) still applies.
![](doc/spectrum.png)
TODO list
*watchdog for PLL settings to prevent radio interference
*measure PLL loop filter response
It is based on the FM transmitter created by [Oliver Mattos and Oskar Weigl](http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter), and later adapted to using DMA by [Richard Hirst](https://github.com/richardghirst). Christophe Jacquet adapted it and added the RDS data generator and modulator. The transmitter uses the Raspberry Pi's clock divider to produce VHF signals.
It is compatible with both the Raspberry Pi 1 (the original one) and the Raspberry Pi 2 and 3. Users of Raspberry Pi 3 should add gpu_freq=250 to /boot/config.txt . The Pi 3 has very sensitive low voltage detection. When low voltage is detected, clocks are reduced to safe values in an attempt to prevent crashes. This program changes clocks to generate the desired radio frequency without the knowledge of the power management system. While it would be possible to detect and undo changes, this would cause radio interference each time it happens. Setting gpu_freq=250 appears to prevent undesired clock changes because the normal value and safe value are the same.
![](doc/vfd_display.jpg)
PiFmRds has been developed for experimentation only. It is not a media center, it is not intended to broadcast music to your stereo system. See the [legal warning](#warning-and-disclaimer).
## How to use it?
Pi-FM-RDS, depends on the `sndfile` library. To install this library on Debian-like distributions, for instance Raspbian, run `sudo apt-get install libsndfile1-dev`.
Pi-FM-RDS also depends on the Linux `rpi-mailbox` driver, so you need a recent Linux kernel. The Raspbian releases from August 2015 have this.
**Important.** The binaries compiled for the Raspberry Pi 1 are not compatible with the Raspberry Pi 2/3, and conversely. Always re-compile when switching models, so do not skip the `make clean` step in the instructions below!
Clone the source repository and run `make` in the `src` directory:
```bash
git clone https://github.com/F5OEO/PiFmRds.git
cd PiFmRds/src
git clone https://github.com/F5OEO/librpitx.git
cd librpitx/src
make
cd ../../
make clean
make
```
Then you can just run:
```
sudo ./pi_fm_rds
```
This will generate an FM transmission on 107.9 MHz, with default station name (PS), radiotext (RT) and PI-code, without audio. The radiofrequency signal is emitted on GPIO 4 (pin 7 on header P1).
You can add monophonic or stereophonic audio by referencing an audio file as follows:
```
sudo ./pi_fm_rds -audio sound.wav
```
To test stereophonic audio, you can try the file `stereo_44100.wav` provided.
The more general syntax for running Pi-FM-RDS is as follows:
```
pi_fm_rds [-freq freq] [-audio file] [-ppm ppm_error] [-pi pi_code] [-ps ps_text] [-rt rt_text]
```
All arguments are optional:
* `-freq` specifies the carrier frequency (in MHz). Example: `-freq 107.9`.
* `-audio` specifies an audio file to play as audio. The sample rate does not matter: Pi-FM-RDS will resample and filter it. If a stereo file is provided, Pi-FM-RDS will produce an FM-Stereo signal. Example: `-audio sound.wav`. The supported formats depend on `libsndfile`. This includes WAV and Ogg/Vorbis (among others) but not MP3. Specify `-` as the file name to read audio data on standard input (useful for piping audio into Pi-FM-RDS, see below).
* `-pi` specifies the PI-code of the RDS broadcast. 4 hexadecimal digits. Example: `-pi FFFF`.
* `-ps` specifies the station name (Program Service name, PS) of the RDS broadcast. Limit: 8 characters. Example: `-ps RASP-PI`.
* `-rt` specifies the radiotext (RT) to be transmitted. Limit: 64 characters. Example: `-rt 'Hello, world!'`.
* `-ctl` specifies a named pipe (FIFO) to use as a control channel to change PS and RT at run-time (see below).
* `-ppm` specifies your Raspberry Pi's oscillator error in parts per million (ppm), see below.
By default the PS changes back and forth between `Pi-FmRds` and a sequence number, starting at `00000000`. The PS changes around one time per second.
### Clock calibration (only if experiencing difficulties)
The RDS standards states that the error for the 57 kHz subcarrier must be less than ± 6 Hz, i.e. less than 105 ppm (parts per million). The Raspberry Pi's oscillator error may be above this figure. That is where the `-ppm` parameter comes into play: you specify your Pi's error and Pi-FM-RDS adjusts the clock dividers accordingly.
In practice, I found that Pi-FM-RDS works okay even without using the `-ppm` parameter. I suppose the receivers are more tolerant than stated in the RDS spec.
One way to measure the ppm error is to play the `pulses.wav` file: it will play a pulse for precisely 1 second, then play a 1-second silence, and so on. Record the audio output from a radio with a good audio card. Say you sample at 44.1 kHz. Measure 10 intervals. Using [Audacity](http://audacity.sourceforge.net/) for example determine the number of samples of these 10 intervals: in the absence of clock error, it should be 441,000 samples. With my Pi, I found 441,132 samples. Therefore, my ppm error is (441132-441000)/441000 * 1e6 = 299 ppm, **assuming that my sampling device (audio card) has no clock error...**
### Piping audio into Pi-FM-RDS
If you use the argument `-audio -`, Pi-FM-RDS reads audio data on standard input. This allows you to pipe the output of a program into Pi-FM-RDS. For instance, this can be used to read MP3 files using Sox:
```
sox -t mp3 http://www.linuxvoice.com/episodes/lv_s02e01.mp3 -t wav - | sudo ./pi_fm_rds -audio -
```
Or to pipe the AUX input of a sound card into Pi-FM-RDS:
```
sudo arecord -fS16_LE -r 44100 -Dplughw:1,0 -c 2 - | sudo ./pi_fm_rds -audio -
```
### Changing PS, RT and TA at run-time
You can control PS, RT and TA (Traffic Announcement flag) at run-time using a named pipe (FIFO). For this run Pi-FM-RDS with the `-ctl` argument.
Example:
```
mkfifo rds_ctl
sudo ./pi_fm_rds -ctl rds_ctl
```
Then you can send “commands” to change PS, RT and TA:
```
cat >rds_ctl
PS MyText
RT A text to be sent as radiotext
TA ON
PS OtherTxt
TA OFF
...
```
Every line must start with either `PS`, `RT` or `TA`, followed by one space character, and the desired value. Any other line format is silently ignored. `TA ON` switches the Traffic Announcement flag to *on*, any other value switches it to *off*.
## Warning and Disclaimer
PiFmRds is an **experimental** program, designed **only for experimentation**. It is in no way intended to become a personal *media center* or a tool to operate a *radio station*, or even broadcast sound to one's own stereo system.
In most countries, transmitting radio waves without a state-issued licence specific to the transmission modalities (frequency, power, bandwidth, etc.) is **illegal**.
Therefore, always connect a shielded transmission line from the RaspberryPi directly
to a radio receiver, so as **not** to emit radio waves. Never use an antenna.
Even if you are a licensed amateur radio operator, using PiFmRds to transmit radio waves on ham frequencies without any filtering between the RaspberryPi and an antenna is most probably illegal because the square-wave carrier is very rich in harmonics, so the bandwidth requirements are likely not met.
I could not be held liable for any misuse of your own Raspberry Pi. Any experiment is made under your own responsibility.
## Tests
Pi-FM-RDS was successfully tested with all my RDS-able devices, namely:
* a Sony ICF-C20RDS alarm clock from 1995,
* a Sangean PR-D1 portable receiver from 1998, and an ATS-305 from 1999,
* a Samsung Galaxy S2 mobile phone from 2011,
* a Philips MBD7020 hifi system from 2012,
* a Silicon Labs [USBFMRADIO-RD](http://www.silabs.com/products/mcu/Pages/USBFMRadioRD.aspx) USB stick, employing an Si4701 chip, and using my [RDS Surveyor](http://rds-surveyor.sourceforge.net/) program,
* a “PCear Fm Radio”, a Chinese clone of the above, again using RDS Surveyor.
Reception works perfectly with all the devices above. RDS Surveyor reports no group errors.
![](doc/galaxy_s2.jpg)
### CPU Usage
CPU usage on a Raspberry Pi 1 is as follows:
* without audio: 9%
* with mono audio: 33%
* with stereo audio: 40%
CPU usage increases dramatically when adding audio because the program has to upsample the (unspecified) sample rate of the input audio file to 228 kHz, its internal operating sample rate. Doing so, it has to apply an FIR filter, which is costly.
## Design
The RDS data generator lies in the `rds.c` file.
The RDS data generator generates cyclically four 0A groups (for transmitting PS), and one 2A group (for transmitting RT). In addition, every minute, it inserts a 4A group (for transmitting CT, clock time). `get_rds_group` generates one group, and uses `crc` for computing the CRC.
To get samples of RDS data, call `get_rds_samples`. It calls `get_rds_group`, differentially encodes the signal and generates a shaped biphase symbol. Successive biphase symbols overlap: the samples are added so that the result is equivalent to applying the shaping filter (a [root-raised-cosine (RRC) filter ](http://en.wikipedia.org/wiki/Root-raised-cosine_filter) specified in the RDS standard) to a sequence of Manchester-encoded pulses.
The shaped biphase symbol is generated once and for all by a Python program called `generate_waveforms.py` that uses [Pydemod](https://github.com/ChristopheJacquet/Pydemod), one of my other software radio projects. This Python program generates an array called `waveform_biphase` that results from the application of the RRC filter to a positive-negative impulse pair. *Note that the output of `generate_waveforms.py`, two files named `waveforms.c` and `waveforms.h`, are included in the Git repository, so you don't need to run the Python script yourself to compile Pi-FM-RDS.*
Internally, the program samples all signals at 228 kHz, four times the RDS subcarrier's 57 kHz.
The FM multiplex signal (baseband signal) is generated by `fm_mpx.c`. This file handles the upsampling of the input audio file to 228 kHz, and the generation of the multiplex: unmodulated left+right signal (limited to 15 kHz), possibly the stereo pilot at 19 kHz, possibly the left-right signal, amplitude-modulated on 38 kHz (suppressed carrier) and RDS signal from `rds.c`. Upsampling is performed using a polyphase filter bank of 32 filters, each with 32 coefficients. To help understand the polyphase filter bank, consider upsampling the input signal by zero stuffing. Then, apply a low pass filter with the cutoff at the original Nyquist frequency. Finally, collect some of the filtered samples at the new sampling rate. The polyphase filter bank does the same thing mathematically, but avoids computing output samples that will not be used. It also avoids processing all of the suffed zeros. The low pass part of the filter is a sampled sinc. The filter is also used to provide pre-emphasis. The low pass filter coefficients are convolved with the pre-emphasis filter, providing pre-emphasis at no additional cost. The combined filter is windowed by a Hamming window. The filter coefficients are generated at startup so that the filter cuts frequencies above the minimum of:
* the Nyquist frequency of the input audio file (half the sample rate) to avoid aliasing (this is the typical case for resampling),
* 15 kHz, the bandpass of the left+right and left-right channels, as per the FM broadcasting standards.
An Octave script to compute the frequency response of the filter is provided in the doc folder.
The samples are played by `pi_fm_rds.c` that is adapted from Richard Hirst's [PiFmDma](https://github.com/richardghirst/PiBits/tree/master/PiFmDma). The program was changed to support a sample rate of precisely 228 kHz.
### References
* [EN 50067, Specification of the radio data system (RDS) for VHF/FM sound broadcasting in the frequency range 87.5 to 108.0 MHz](http://www.interactive-radio-system.com/docs/EN50067_RDS_Standard.pdf)
## History
* 2018-11-01: Integrate in rpitx project. Hope not to hurt the author , copying readme and licence.
* 2018-03-19: Use librpitx for easy integration
* 2015-09-05: support for the Raspberry Pi 2
* 2014-11-01: support for toggling the Traffic Announcement (TA) flag at run-time
* 2014-10-19: bugfix (cleanly stop the DMA engine when the specified file does not exist, or it's not possible to read from stdin)
* 2014-08-04: bugfix (ppm now uses floats)
* 2014-06-22: generate CT (clock time) signals, bugfixes
* 2014-05-04: possibility to change PS and RT at run-time
* 2014-04-28: support piping audio file data to Pi-FM-RDS' standard input
* 2014-04-14: new release that supports any sample rate for the audio input, and that can generate a proper FM-Stereo signal if a stereophonic input file is provided
* 2014-04-06: initial release, which only supported 228 kHz monophonic audio input files
--------
© [Christophe Jacquet](http://www.jacquet80.eu/) (F8FTK), 2014-2015. Released under the GNU GPL v3.

Wyświetl plik

@ -0,0 +1,102 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
file. It requires libsndfile.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
control_pipe.c: handles command written to a non-blocking control pipe,
in order to change RDS PS and RT at runtime.
*/
#include <string.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include "rds.h"
#include "control_pipe.h"
#define CTL_BUFFER_SIZE 100
FILE *f_ctl;
/*
* Opens a file (pipe) to be used to control the RDS coder, in non-blocking mode.
*/
int open_control_pipe(char *filename) {
int fd = open(filename, O_RDONLY | O_NONBLOCK);
if(fd == -1) return -1;
int flags;
flags = fcntl(fd, F_GETFL, 0);
flags |= O_NONBLOCK;
if( fcntl(fd, F_SETFL, flags) == -1 ) return -1;
f_ctl = fdopen(fd, "r");
if(f_ctl == NULL) return -1;
return 0;
}
/*
* Polls the control file (pipe), non-blockingly, and if a command is received,
* processes it and updates the RDS data.
*/
int poll_control_pipe() {
static char buf[CTL_BUFFER_SIZE];
char *res = fgets(buf, CTL_BUFFER_SIZE, f_ctl);
if(res == NULL) return -1;
if(strlen(res) > 3 && res[2] == ' ') {
char *arg = res+3;
if(arg[strlen(arg)-1] == '\n') arg[strlen(arg)-1] = 0;
if(res[0] == 'P' && res[1] == 'S') {
arg[8] = 0;
set_rds_ps(arg);
printf("PS set to: \"%s\"\n", arg);
return CONTROL_PIPE_PS_SET;
}
if(res[0] == 'R' && res[1] == 'T') {
arg[64] = 0;
set_rds_rt(arg);
printf("RT set to: \"%s\"\n", arg);
return CONTROL_PIPE_RT_SET;
}
if(res[0] == 'T' && res[1] == 'A') {
int ta = ( strcmp(arg, "ON") == 0 );
set_rds_ta(ta);
printf("Set TA to ");
if(ta) printf("ON\n"); else printf("OFF\n");
return CONTROL_PIPE_TA_SET;
}
}
return -1;
}
/*
* Closes the control pipe.
*/
int close_control_pipe() {
if(f_ctl) return fclose(f_ctl);
else return 0;
}

Wyświetl plik

@ -0,0 +1,31 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
file. It requires libsndfile.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define CONTROL_PIPE_PS_SET 1
#define CONTROL_PIPE_RT_SET 2
#define CONTROL_PIPE_TA_SET 3
extern int open_control_pipe(char *filename);
extern int close_control_pipe();
extern int poll_control_pipe();

Wyświetl plik

@ -0,0 +1,335 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
file. It requires libsndfile.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
fm_mpx.c: generates an FM multiplex signal containing RDS plus possibly
monaural or stereo audio.
*/
#include <sndfile.h>
#include <stdlib.h>
#include <strings.h>
#include <math.h>
#include "rds.h"
#define PI 3.141592654
#define FIR_PHASES (32)
#define FIR_TAPS (32) // MUST be a power of 2 for the circular buffer
size_t length;
// coefficients of the low-pass FIR filter
float low_pass_fir[FIR_PHASES][FIR_TAPS];
float carrier_38[] = {0.0, 0.8660254037844386, 0.8660254037844388, 1.2246467991473532e-16, -0.8660254037844384, -0.8660254037844386};
float carrier_19[] = {0.0, 0.5, 0.8660254037844386, 1.0, 0.8660254037844388, 0.5, 1.2246467991473532e-16, -0.5, -0.8660254037844384, -1.0, -0.8660254037844386, -0.5};
int phase_38 = 0;
int phase_19 = 0;
float downsample_factor;
float *audio_buffer;
int audio_index = 0;
int audio_len = 0;
float audio_pos;
float fir_buffer_left[FIR_TAPS] = {0};
float fir_buffer_right[FIR_TAPS] = {0};
int fir_index = 0;
int channels;
float left_max=1, right_max=1; // start compressor with low gain
SNDFILE *inf;
float *alloc_empty_buffer(size_t length) {
float *p =(float *) malloc(length * sizeof(float));
if(p == NULL) return NULL;
bzero(p, length * sizeof(float));
return p;
}
int fm_mpx_open(char *filename, size_t len) {
length = len;
if(filename != NULL) {
// Open the input file
SF_INFO sfinfo;
// stdin or file on the filesystem?
if(filename[0] == '-') {
if(! (inf = sf_open_fd(fileno(stdin), SFM_READ, &sfinfo, 0))) {
fprintf(stderr, "Error: could not open stdin for audio input.\n") ;
return -1;
} else {
printf("Using stdin for audio input.\n");
}
} else {
if(! (inf = sf_open(filename, SFM_READ, &sfinfo))) {
fprintf(stderr, "Error: could not open input file %s.\n", filename) ;
return -1;
} else {
printf("Using audio file: %s\n", filename);
}
}
int in_samplerate = sfinfo.samplerate;
downsample_factor = 228000. / in_samplerate;
printf("Input: %d Hz, upsampling factor: %.2f\n", in_samplerate, downsample_factor);
channels = sfinfo.channels;
if(channels > 1) {
printf("%d channels, generating stereo multiplex.\n", channels);
} else {
printf("1 channel, monophonic operation.\n");
}
// Choose a cutoff frequency for the low-pass FIR filter
float cutoff_freq = 15700;
//float cutoff_freq = 3000; //For NBFM
if(in_samplerate/2 < cutoff_freq) cutoff_freq = in_samplerate/2 * .8;
// Create the low-pass FIR filter, with pre-emphasis
double window, firlowpass, firpreemph , sincpos;
double gain=FIR_PHASES/25.0; // Why??? Maybe gain adjustment for preemphais
// IIR pre-emphasis filter
// Reference material: http://jontio.zapto.org/hda1/preempiir.pdf
double tau=75e-6;
double delta=1.96e-6;
double taup, deltap, bp, ap, a0, a1, b1;
taup=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*tau*(in_samplerate*FIR_PHASES) ));
deltap=1.0/(2.0*(in_samplerate*FIR_PHASES))/tan( 1.0/(2*delta*(in_samplerate*FIR_PHASES) ));
bp=sqrt( -taup*taup + sqrt(taup*taup*taup*taup + 8.0*taup*taup*deltap*deltap) ) / 2.0 ;
ap=sqrt( 2*bp*bp + taup*taup );
a0=( 2.0*ap + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
a1=(-2.0*ap + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
b1=( 2.0*bp + 1/(in_samplerate*FIR_PHASES) )/(2.0*bp + 1/(in_samplerate*FIR_PHASES) );
double x=0,y=0;
for(int i=0; i<FIR_TAPS; i++) {
for(int j=0; j<FIR_PHASES; j++) {
int mi=i*FIR_PHASES + j+1;// match indexing of Matlab script
sincpos = (mi)-(((FIR_TAPS*FIR_PHASES)+1.0)/2.0); // offset by 0.5 so sincpos!=0 (causes NaN x/0 )
//printf("%d=%f \n",mi ,sincpos);
firlowpass = sin(2 * PI * cutoff_freq * sincpos / (in_samplerate*FIR_PHASES) ) / (PI * sincpos) ;
y=a0*firlowpass + a1*x + b1*y ; // Find the combined impulse response
x=firlowpass; // of FIR low-pass and IIR pre-emphasis
firpreemph=y; // y could be replaced by firpreemph but this
// matches the example in the reference material
window = (.54 - .46 * cos(2*PI * (mi) / (double) FIR_TAPS*FIR_PHASES )) ; // Hamming window
low_pass_fir[j][i] = firpreemph * window * gain ;
}
}
printf("Created low-pass FIR filter for audio channels, with cutoff at %.1f Hz\n", cutoff_freq);
if( 0 )
{
printf("f = [ ");
for(int i=0; i<FIR_TAPS; i++) {
for(int j=0; j<FIR_PHASES; j++) {
printf("%.5f ", low_pass_fir[j][i]);
}
}
printf("]; \n");
}
audio_pos = downsample_factor;
audio_buffer = alloc_empty_buffer(length * channels);
if(audio_buffer == NULL) return -1;
} // end if(filename != NULL)
else {
inf = NULL;
// inf == NULL indicates that there is no audio
}
return 0;
}
// samples provided by this function are in 0..10: they need to be divided by
// 10 after.
int fm_mpx_get_samples(float *mpx_buffer) {
get_rds_samples(mpx_buffer, length);
if(inf == NULL) return 0; // if there is no audio, stop here
for(int i=0; i<length; i++) {
if(audio_pos >= downsample_factor) {
audio_pos -= downsample_factor;
if(audio_len <= channels ) {
for(int j=0; j<2; j++) { // one retry
audio_len = sf_read_float(inf, audio_buffer, length);
if (audio_len < 0) {
fprintf(stderr, "Error reading audio\n");
return -1;
}
if(audio_len == 0) {
if( sf_seek(inf, 0, SEEK_SET) < 0 ) {
fprintf(stderr, "Could not rewind in audio file, terminating\n");
return -1;
}
} else {
break;
}
}
audio_index = 0;
} else {
audio_index += channels;
audio_len -= channels;
}
fir_index++; // fir_index will point to newest valid data soon
if(fir_index >= FIR_TAPS) fir_index = 0;
// Store the current sample(s) into the FIR filter's ring buffer
fir_buffer_left[fir_index] = audio_buffer[audio_index];
if(channels > 1) {
fir_buffer_right[fir_index] = audio_buffer[audio_index+1];
}
} // if need new sample
// Polyphase FIR filter
float out_left = 0;
float out_right = 0;
// Calculate which FIR phase to use
//int iphase = FIR_PHASES-1 - ((int) (audio_pos/downsample_factor*FIR_PHASES) );
int iphase = ((int) (audio_pos*FIR_PHASES/downsample_factor) );// I think this is correct
//int iphase=FIR_PHASES-1; // test override
//printf("%d %d \n",fir_index,iphase); // diagnostics
// Sanity checks
if ( iphase < 0 ) {iphase=0; printf("low\n"); }// Seems to run faster with these checks in place
if ( iphase >= FIR_PHASES ) {iphase=FIR_PHASES-2; printf("high\n"); }
if( channels > 1 )
{
for(int fi=0; fi<FIR_TAPS; fi++) // fi = Filter Index
{ // use bit masking to implement circular buffer
out_left+= low_pass_fir[iphase][fi]* fir_buffer_left[(fir_index-fi)&(FIR_TAPS-1)];
out_right+=low_pass_fir[iphase][fi]*fir_buffer_right[(fir_index-fi)&(FIR_TAPS-1)];
}
}
else
{
for(int fi=0; fi<FIR_TAPS; fi++) // fi = Filter Index
{ // use bit masking to implement circular buffer
out_left+=low_pass_fir[iphase][fi] * fir_buffer_left[(fir_index-fi)&(FIR_TAPS-1)];
}
}
// Simple broadcast compressor
//
// The goal is to get the loudest sounding audio while
// keeping the deviation within legal limits, and
// without degrading the audio quality significantly.
// Don't expect this simple code to match the
// performance of commercial broadcast equipment.
float left_abs, right_abs;
float compressor_decay=0.999995;
float compressor_attack=1.0;
// Setting attack to anything other than 1.0 could cause overshoot.
float compressor_max_gain_recip=0.01;
left_abs=fabsf(out_left);
if( left_abs>left_max )
{
left_max+= (left_abs-left_max)*compressor_attack;
}
else
{
left_max*=compressor_decay;
}
if( channels > 1 )
{
right_abs=fabsf(out_right);
if( right_abs>right_max )
{
right_max+= (right_abs-right_max)*compressor_attack;
}
else
{
right_max*=compressor_decay;
}
if( 1 )// Experimental joint compressor mode
{
if( left_max > right_max )
right_max=left_max;
else if( left_max < right_max )
left_max=right_max;
}
out_right=out_right/(right_max+compressor_max_gain_recip);
}
out_left= out_left/(left_max+compressor_max_gain_recip); // Adjust volume with limited maximum gain
// Generate the stereo mpx
if( channels > 1 ) {
mpx_buffer[i] += 4.05*(out_left+out_right) + // Stereo sum signal
4.05 * carrier_38[phase_38] * (out_left-out_right) + // Stereo difference signal
.9*carrier_19[phase_19]; // Stereo pilot tone
phase_19++;
phase_38++;
if(phase_19 >= 12) phase_19 = 0;
if(phase_38 >= 6) phase_38 = 0;
}
else
{
mpx_buffer[i] =
mpx_buffer[i] + // RDS data samples are currently in mpx_buffer :to be Remove in NBFM
9.0*out_left; // Unmodulated monophonic signal
}
audio_pos++;
}
return 0;
}
int fm_mpx_close() {
if(sf_close(inf) ) {
fprintf(stderr, "Error closing audio file");
}
if(audio_buffer != NULL) free(audio_buffer);
return 0;
}

Wyświetl plik

@ -0,0 +1,26 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
file. It requires libsndfile.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
extern int fm_mpx_open(char *filename, size_t len);
extern int fm_mpx_get_samples(float *mpx_buffer);
extern int fm_mpx_close();

Wyświetl plik

@ -0,0 +1,36 @@
#!/usr/bin/python
# PiFmRds - FM/RDS transmitter for the Raspberry Pi
# Copyright (C) 2014 Christophe Jacquet, F8FTK
#
# See https://github.com/ChristopheJacquet/PiFmRds
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This program generates a WAV file with a 1-second sine wave at 440 Hz,
# followed by a 1-second silence.
import scipy.io.wavfile as wavfile
import numpy
sample_rate = 228000
samples = numpy.zeros(2 * sample_rate, dtype=numpy.dtype('>i2'))
# 1-second tune
samples[:sample_rate] = (numpy.sin(2*numpy.pi*440*numpy.arange(sample_rate)/sample_rate)
* 20000).astype(numpy.dtype('>i2'))
wavfile.write("pulses.wav", sample_rate, samples)

Wyświetl plik

@ -0,0 +1,83 @@
#!/usr/bin/python
# PiFmRds - FM/RDS transmitter for the Raspberry Pi
# Copyright (C) 2014 Christophe Jacquet, F8FTK
#
# See https://github.com/ChristopheJacquet/PiFmRds
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program 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. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# This program generates the waveform of a single biphase symbol
#
# This program uses Pydemod, see https://github.com/ChristopheJacquet/Pydemod
import pydemod.app.rds as rds
import numpy
import scipy.io.wavfile as wavfile
import io
import matplotlib.pyplot as plt
sample_rate = 228000
outc = io.open("waveforms.c", mode="w", encoding="utf8")
outh = io.open("waveforms.h", mode="w", encoding="utf8")
header = u"""
/* This file was automatically generated by "generate_waveforms.py".
(C) 2014 Christophe Jacquet.
Released under the GNU GPL v3 license.
*/
"""
outc.write(header)
outh.write(header)
def generate_bit(name):
offset = 240
l = 96
count = 2
sample = numpy.zeros(3*l)
sample[l] = 1
sample[2*l] = -1
# Apply the data-shaping filter
sf = rds.pulse_shaping_filter(96*8, 228000)
shapedSamples = numpy.convolve(sample, sf)
out = shapedSamples[528-288:528+288] #[offset:offset+l*count]
#plt.plot(sf)
#plt.plot(out)
#plt.show()
iout = (out * 20000./max(abs(out)) ).astype(numpy.dtype('>i2'))
wavfile.write(u"waveform_{}.wav".format(name), sample_rate, iout)
outc.write(u"float waveform_{name}[] = {{{values}}};\n\n".format(
name = name,
values = u", ".join(map(unicode, out/2.5))))
# note: need to limit the amplitude so as not to saturate when the biphase
# waveforms are summed
outh.write(u"extern float waveform_{name}[{size}];\n".format(name=name, size=len(out)))
generate_bit("biphase")
outc.close()
outh.close()

Wyświetl plik

@ -0,0 +1,306 @@
/*
* PiFmRds - FM/RDS transmitter for the Raspberry Pi
* Copyright (C) 2018 Evariste Courjaud, F5OEO
* Copyright (C) 2014, 2015 Christophe Jacquet, F8FTK
* Copyright (C) 2012, 2015 Richard Hirst
* Copyright (C) 2012 Oliver Mattos and Oskar Weigl
*
* See https://github.com/ChristopheJacquet/PiFmRds
*
* PI-FM-RDS: RaspberryPi FM transmitter, with RDS.
*
* This file contains the VHF FM modulator. All credit goes to the original
* authors, Oliver Mattos and Oskar Weigl for the original idea, and to
* Richard Hirst for using the Pi's DMA engine, which reduced CPU usage
* dramatically.
*
* I (Christophe Jacquet) have adapted their idea to transmitting samples
* at 228 kHz, allowing to build the 57 kHz subcarrier for RDS BPSK data.
*
* To make it work on the Raspberry Pi 2, I used a fix by Richard Hirst
* (again) to request memory using Broadcom's mailbox interface. This fix
* was published for ServoBlaster here:
* https://www.raspberrypi.org/forums/viewtopic.php?p=699651#p699651
*
* Never use this to transmit VHF-FM data through an antenna, as it is
* illegal in most countries. This code is for testing purposes only.
* Always connect a shielded transmission line from the RaspberryPi directly
* to a radio receiver, so as *not* to emit radio waves.
*
* ---------------------------------------------------------------------------
* These are the comments from Richard Hirst's version:
*
* RaspberryPi based FM transmitter. For the original idea, see:
*
* http://www.icrobotics.co.uk/wiki/index.php/Turning_the_Raspberry_Pi_Into_an_FM_Transmitter
*
* All credit to Oliver Mattos and Oskar Weigl for creating the original code.
*
* I have taken their idea and reworked it to use the Pi DMA engine, so
* reducing the CPU overhead for playing a .wav file from 100% to about 1.6%.
*
* I have implemented this in user space, using an idea I picked up from Joan
* on the Raspberry Pi forums - credit to Joan for the DMA from user space
* idea.
*
* The idea of feeding the PWM FIFO in order to pace DMA control blocks comes
* from ServoBlaster, and I take credit for that :-)
*
* This code uses DMA channel 5 and the PWM hardware, with no regard for
* whether something else might be trying to use it at the same time (such as
* the 3.5mm jack audio driver).
*
* I know nothing much about sound, subsampling, or FM broadcasting, so it is
* quite likely the sound quality produced by this code can be improved by
* someone who knows what they are doing. There may be issues realting to
* caching, as the user space process just writes to its virtual address space,
* and expects the DMA controller to see the data; it seems to work for me
* though.
*
* NOTE: THIS CODE MAY WELL CRASH YOUR PI, TRASH YOUR FILE SYSTEMS, AND
* POTENTIALLY EVEN DAMAGE YOUR HARDWARE. THIS IS BECAUSE IT STARTS UP THE DMA
* CONTROLLER USING MEMORY OWNED BY A USER PROCESS. IF THAT USER PROCESS EXITS
* WITHOUT STOPPING THE DMA CONTROLLER, ALL HELL COULD BREAK LOOSE AS THE
* MEMORY GETS REALLOCATED TO OTHER PROCESSES WHILE THE DMA CONTROLLER IS STILL
* USING IT. I HAVE ATTEMPTED TO MINIMISE ANY RISK BY CATCHING SIGNALS AND
* RESETTING THE DMA CONTROLLER BEFORE EXITING, BUT YOU HAVE BEEN WARNED. I
* ACCEPT NO LIABILITY OR RESPONSIBILITY FOR ANYTHING THAT HAPPENS AS A RESULT
* OF YOU RUNNING THIS CODE. IF IT BREAKS, YOU GET TO KEEP ALL THE PIECES.
*
* NOTE ALSO: THIS MAY BE ILLEGAL IN YOUR COUNTRY. HERE ARE SOME COMMENTS
* FROM MORE KNOWLEDGEABLE PEOPLE ON THE FORUM:
*
* "Just be aware that in some countries FM broadcast and especially long
* distance FM broadcast could get yourself into trouble with the law, stray FM
* broadcasts over Airband aviation is also strictly forbidden."
*
* "A low pass filter is really really required for this as it has strong
* harmonics at the 3rd, 5th 7th and 9th which sit in licensed and rather
* essential bands, ie GSM, HAM, emergency services and others. Polluting these
* frequencies is immoral and dangerous, whereas "breaking in" on FM bands is
* just plain illegal."
*
* "Don't get caught, this GPIO use has the potential to exceed the legal
* limits by about 2000% with a proper aerial."
*
*
* As for the original code, this code is released under the GPL.
*
* Richard Hirst <richardghirst@gmail.com> December 2012
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include <sndfile.h>
extern "C"
{
#include "rds.h"
#include "fm_mpx.h"
#include "control_pipe.h"
}
#include "../librpitx/src/librpitx.h"
ngfmdmasync *fmmod;
// The deviation specifies how wide the signal is.
// Use 75kHz for WBFM (broadcast radio)
// and about 2.5kHz for NBFM (walkie-talkie style radio)
#define DEVIATION 75000
//FOR NBFM
//#define DEVIATION 2500
static void
terminate(int num)
{
delete fmmod;
fm_mpx_close();
close_control_pipe();
exit(num);
}
static void
fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
terminate(0);
}
#define SUBSIZE 512
#define DATA_SIZE 5000
int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt, float ppm, char *control_pipe) {
// Catch all signals possible - it is vital we kill the DMA engine
// on process exit!
for (int i = 0; i < 64; i++) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
// Data structures for baseband data
float data[DATA_SIZE];
float devfreq[DATA_SIZE];
int data_len = 0;
int data_index = 0;
// Initialize the baseband generator
if(fm_mpx_open(audio_file, DATA_SIZE) < 0) return 1;
// Initialize the RDS modulator
char myps[9] = {0};
set_rds_pi(pi);
set_rds_rt(rt);
uint16_t count = 0;
uint16_t count2 = 0;
int varying_ps = 0;
if(ps) {
set_rds_ps(ps);
printf("PI: %04X, PS: \"%s\".\n", pi, ps);
} else {
printf("PI: %04X, PS: <Varying>.\n", pi);
varying_ps = 1;
}
printf("RT: \"%s\"\n", rt);
// Initialize the control pipe reader
if(control_pipe) {
if(open_control_pipe(control_pipe) == 0) {
printf("Reading control commands on %s.\n", control_pipe);
} else {
printf("Failed to open control pipe: %s.\n", control_pipe);
control_pipe = NULL;
}
}
printf("Starting to transmit on %3.1f MHz.\n", carrier_freq/1e6);
float deviation_scale_factor;
//if( divider ) // PLL modulation
{ // note samples are [-10:10]
deviation_scale_factor= 0.1 * (DEVIATION ) ; // todo PPM
}
for (;;)
{
// Default (varying) PS
if(varying_ps) {
if(count == 512) {
snprintf(myps, 9, "%08d", count2);
set_rds_ps(myps);
count2++;
}
if(count == 1024) {
set_rds_ps("RPi-Live");
count = 0;
}
count++;
}
if(control_pipe && poll_control_pipe() == CONTROL_PIPE_PS_SET) {
varying_ps = 0;
}
if( fm_mpx_get_samples(data) < 0 ) {
terminate(0);
}
data_len = DATA_SIZE;
for(int i=0;i< data_len;i++)
{
devfreq[i] = data[i]*deviation_scale_factor;
}
fmmod->SetFrequencySamples(devfreq,data_len);
}
return 0;
}
int main(int argc, char **argv) {
char *audio_file = NULL;
char *control_pipe = NULL;
uint32_t carrier_freq = 107900000;
char *ps = "Librpitx";
char *rt = "PiFmRds: live FM-RDS transmission from the RaspberryPi";
uint16_t pi = 0x1234;
float ppm = 0;
// Parse command-line arguments
for(int i=1; i<argc; i++) {
char *arg = argv[i];
char *param = NULL;
if(arg[0] == '-' && i+1 < argc) param = argv[i+1];
if((strcmp("-wav", arg)==0 || strcmp("-audio", arg)==0) && param != NULL) {
i++;
audio_file = param;
} else if(strcmp("-freq", arg)==0 && param != NULL) {
i++;
carrier_freq = 1e6 * atof(param);
//if(carrier_freq < 76e6 || carrier_freq > 108e6)
// fatal("Incorrect frequency specification. Must be in megahertz, of the form 107.9, between 76 and 108.\n");
} else if(strcmp("-pi", arg)==0 && param != NULL) {
i++;
pi = (uint16_t) strtol(param, NULL, 16);
} else if(strcmp("-ps", arg)==0 && param != NULL) {
i++;
ps = param;
} else if(strcmp("-rt", arg)==0 && param != NULL) {
i++;
rt = param;
} else if(strcmp("-ppm", arg)==0 && param != NULL) {
i++;
ppm = atof(param);
} else if(strcmp("-ctl", arg)==0 && param != NULL) {
i++;
control_pipe = param;
}
else {
fatal("Unrecognised argument: %s.\n"
"Syntax: pi_fm_rds [-freq freq] [-audio file] [-ppm ppm_error] [-pi pi_code]\n"
" [-ps ps_text] [-rt rt_text] [-ctl control_pipe]\n", arg);
}
}
int FifoSize=DATA_SIZE*2;
fmmod=new ngfmdmasync(carrier_freq,228000,14,FifoSize);
int errcode = tx(carrier_freq, audio_file, pi, ps, rt, ppm, control_pipe);
terminate(errcode);
}

255
src/pifmrds/rds.c 100644
Wyświetl plik

@ -0,0 +1,255 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#include "waveforms.h"
#define RT_LENGTH 64
#define PS_LENGTH 8
#define GROUP_LENGTH 4
struct {
uint16_t pi;
int ta;
char ps[PS_LENGTH];
char rt[RT_LENGTH];
} rds_params = { 0 };
/* Here, the first member of the struct must be a scalar to avoid a
warning on -Wmissing-braces with GCC < 4.8.3
(bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119)
*/
/* The RDS error-detection code generator polynomial is
x^10 + x^8 + x^7 + x^5 + x^4 + x^3 + x^0
*/
#define POLY 0x1B9
#define POLY_DEG 10
#define MSB_BIT 0x8000
#define BLOCK_SIZE 16
#define BITS_PER_GROUP (GROUP_LENGTH * (BLOCK_SIZE+POLY_DEG))
#define SAMPLES_PER_BIT 192
#define FILTER_SIZE (sizeof(waveform_biphase)/sizeof(float))
#define SAMPLE_BUFFER_SIZE (SAMPLES_PER_BIT + FILTER_SIZE)
uint16_t offset_words[] = {0x0FC, 0x198, 0x168, 0x1B4};
// We don't handle offset word C' here for the sake of simplicity
/* Classical CRC computation */
uint16_t crc(uint16_t block) {
uint16_t crc = 0;
for(int j=0; j<BLOCK_SIZE; j++) {
int bit = (block & MSB_BIT) != 0;
block <<= 1;
int msb = (crc >> (POLY_DEG-1)) & 1;
crc <<= 1;
if((msb ^ bit) != 0) {
crc = crc ^ POLY;
}
}
return crc;
}
/* Possibly generates a CT (clock time) group if the minute has just changed
Returns 1 if the CT group was generated, 0 otherwise
*/
int get_rds_ct_group(uint16_t *blocks) {
static int latest_minutes = -1;
// Check time
time_t now;
struct tm *utc;
now = time (NULL);
utc = gmtime (&now);
if(utc->tm_min != latest_minutes) {
// Generate CT group
latest_minutes = utc->tm_min;
int l = utc->tm_mon <= 1 ? 1 : 0;
int mjd = 14956 + utc->tm_mday +
(int)((utc->tm_year - l) * 365.25) +
(int)((utc->tm_mon + 2 + l*12) * 30.6001);
blocks[1] = 0x4400 | (mjd>>15);
blocks[2] = (mjd<<1) | (utc->tm_hour>>4);
blocks[3] = (utc->tm_hour & 0xF)<<12 | utc->tm_min<<6;
utc = localtime(&now);
int offset = utc->tm_gmtoff / (30 * 60);
blocks[3] |= abs(offset);
if(offset < 0) blocks[3] |= 0x20;
//printf("Generated CT: %04X %04X %04X\n", blocks[1], blocks[2], blocks[3]);
return 1;
} else return 0;
}
/* Creates an RDS group. This generates sequences of the form 0A, 0A, 0A, 0A, 2A, etc.
The pattern is of length 5, the variable 'state' keeps track of where we are in the
pattern. 'ps_state' and 'rt_state' keep track of where we are in the PS (0A) sequence
or RT (2A) sequence, respectively.
*/
void get_rds_group(int *buffer) {
static int state = 0;
static int ps_state = 0;
static int rt_state = 0;
uint16_t blocks[GROUP_LENGTH] = {rds_params.pi, 0, 0, 0};
// Generate block content
if(! get_rds_ct_group(blocks)) { // CT (clock time) has priority on other group types
if(state < 4) {
blocks[1] = 0x0400 | ps_state;
if(rds_params.ta) blocks[1] |= 0x0010;
blocks[2] = 0xCDCD; // no AF
blocks[3] = rds_params.ps[ps_state*2]<<8 | rds_params.ps[ps_state*2+1];
ps_state++;
if(ps_state >= 4) ps_state = 0;
} else { // state == 5
blocks[1] = 0x2400 | rt_state;
blocks[2] = rds_params.rt[rt_state*4+0]<<8 | rds_params.rt[rt_state*4+1];
blocks[3] = rds_params.rt[rt_state*4+2]<<8 | rds_params.rt[rt_state*4+3];
rt_state++;
if(rt_state >= 16) rt_state = 0;
}
state++;
if(state >= 5) state = 0;
}
// Calculate the checkword for each block and emit the bits
for(int i=0; i<GROUP_LENGTH; i++) {
uint16_t block = blocks[i];
uint16_t check = crc(block) ^ offset_words[i];
for(int j=0; j<BLOCK_SIZE; j++) {
*buffer++ = ((block & (1<<(BLOCK_SIZE-1))) != 0);
block <<= 1;
}
for(int j=0; j<POLY_DEG; j++) {
*buffer++= ((check & (1<<(POLY_DEG-1))) != 0);
check <<= 1;
}
}
}
/* Get a number of RDS samples. This generates the envelope of the waveform using
pre-generated elementary waveform samples, and then it amplitude-modulates the
envelope with a 57 kHz carrier, which is very efficient as 57 kHz is 4 times the
sample frequency we are working at (228 kHz).
*/
void get_rds_samples(float *buffer, int count) {
static int bit_buffer[BITS_PER_GROUP];
static int bit_pos = BITS_PER_GROUP;
static float sample_buffer[SAMPLE_BUFFER_SIZE] = {0};
static int prev_output = 0;
static int cur_output = 0;
static int cur_bit = 0;
static int sample_count = SAMPLES_PER_BIT;
static int inverting = 0;
static int phase = 0;
static int in_sample_index = 0;
static int out_sample_index = SAMPLE_BUFFER_SIZE-1;
for(int i=0; i<count; i++) {
if(sample_count >= SAMPLES_PER_BIT) {
if(bit_pos >= BITS_PER_GROUP) {
get_rds_group(bit_buffer);
bit_pos = 0;
}
// do differential encoding
cur_bit = bit_buffer[bit_pos];
prev_output = cur_output;
cur_output = prev_output ^ cur_bit;
inverting = (cur_output == 1);
float *src = waveform_biphase;
int idx = in_sample_index;
for(int j=0; j<FILTER_SIZE; j++) {
float val = (*src++);
if(inverting) val = -val;
sample_buffer[idx++] += val;
if(idx >= SAMPLE_BUFFER_SIZE) idx = 0;
}
in_sample_index += SAMPLES_PER_BIT;
if(in_sample_index >= SAMPLE_BUFFER_SIZE) in_sample_index -= SAMPLE_BUFFER_SIZE;
bit_pos++;
sample_count = 0;
}
float sample = sample_buffer[out_sample_index];
sample_buffer[out_sample_index] = 0;
out_sample_index++;
if(out_sample_index >= SAMPLE_BUFFER_SIZE) out_sample_index = 0;
// modulate at 57 kHz
// use phase for this
switch(phase) {
case 0:
case 2: sample = 0; break;
case 1: break;
case 3: sample = -sample; break;
}
phase++;
if(phase >= 4) phase = 0;
*buffer++ = sample;
sample_count++;
}
}
void set_rds_pi(uint16_t pi_code) {
rds_params.pi = pi_code;
}
void set_rds_rt(char *rt) {
strncpy(rds_params.rt, rt, 64);
for(int i=0; i<64; i++) {
if(rds_params.rt[i] == 0) rds_params.rt[i] = 32;
}
}
void set_rds_ps(char *ps) {
strncpy(rds_params.ps, ps, 8);
for(int i=0; i<8; i++) {
if(rds_params.ps[i] == 0) rds_params.ps[i] = 32;
}
}
void set_rds_ta(int ta) {
rds_params.ta = ta;
}

34
src/pifmrds/rds.h 100644
Wyświetl plik

@ -0,0 +1,34 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RDS_H
#define RDS_H
#include <stdint.h>
extern void get_rds_samples(float *buffer, int count);
extern void set_rds_pi(uint16_t pi_code);
extern void set_rds_rt(char *rt);
extern void set_rds_ps(char *ps);
extern void set_rds_ta(int ta);
#endif /* RDS_H */

Wyświetl plik

@ -0,0 +1,101 @@
/*
PiFmRds - FM/RDS transmitter for the Raspberry Pi
Copyright (C) 2014 Christophe Jacquet, F8FTK
See https://github.com/ChristopheJacquet/PiFmRds
rds_wav.c is a test program that writes a RDS baseband signal to a WAV
file. It requires libsndfile.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <sndfile.h>
#include <string.h>
#include "rds.h"
#include "fm_mpx.h"
#define LENGTH 114000
/* Simple test program */
int main(int argc, char **argv) {
if(argc < 4) {
fprintf(stderr, "Error: missing argument.\n");
fprintf(stderr, "Syntax: rds_wav <in_audio.wav> <out_mpx.wav> <text>\n");
return EXIT_FAILURE;
}
set_rds_pi(0x1234);
set_rds_ps(argv[3]);
set_rds_rt(argv[3]);
char *in_file = argv[1];
if(strcmp("NONE", argv[1]) == 0) in_file = NULL;
if(fm_mpx_open(in_file, LENGTH) != 0) {
printf("Could not setup FM mulitplex generator.\n");
return EXIT_FAILURE;
}
// Set the format of the output file
SNDFILE *outf;
SF_INFO sfinfo;
sfinfo.frames = LENGTH;
sfinfo.samplerate = 228000;
sfinfo.channels = 1;
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
sfinfo.sections = 1;
sfinfo.seekable = 0;
// Open the output file
char *out_file = argv[2];
if (! (outf = sf_open(out_file, SFM_WRITE, &sfinfo))) {
fprintf(stderr, "Error: could not open output file %s.\n", out_file);
return EXIT_FAILURE;
}
float mpx_buffer[LENGTH];
for(int j=0; j<40; j++) {
if( fm_mpx_get_samples(mpx_buffer) < 0 ) break;
// scale samples
for(int i=0; i<LENGTH; i++) {
mpx_buffer[i] /= 10.;
}
if(sf_write_float(outf, mpx_buffer, LENGTH) != LENGTH) {
fprintf(stderr, "Error: writing to file %s.\n", argv[1]);
return EXIT_FAILURE;
}
}
if(sf_close(outf) ) {
fprintf(stderr, "Error: closing file %s.\n", argv[1]);
}
fm_mpx_close();
return EXIT_SUCCESS;
}

Plik binarny nie jest wyświetlany.

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -0,0 +1,7 @@
/* This file was automatically generated by "generate_waveforms.py".
(C) 2014 Christophe Jacquet.
Released under the GNU GPL v3 license.
*/
extern float waveform_biphase[576];

17
src/pift8/Makefile 100644
Wyświetl plik

@ -0,0 +1,17 @@
CXXFLAGS = -std=c++14 -I.
LDFLAGS = -lm
gen_ft8: gen_ft8.o ft8/encode.o ft8/pack.o ft8/text.o ft8/pack_77.o ft8/encode_91.o common/wave.o
$(CXX) $(LDFLAGS) -o $@ $^
pift8: pift8.o ft8/encode.o ft8/pack.o ft8/text.o ft8/pack_77.o ft8/encode_91.o common/wave.o ../librpitx/src/librpitx.a
$(CXX) $(LDFLAGS) -o $@ $^
.PHONY: run_tests
run_tests: test
@./test
test: test.o ft8/encode.o ft8/pack.o ft8/text.o ft8/pack_77.o ft8/encode_91.o ft8/unpack.o
$(CXX) $(LDFLAGS) -o $@ $^

127
src/pift8/pift8.cpp 100644
Wyświetl plik

@ -0,0 +1,127 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <signal.h>
#include "common/wave.h"
#include "ft8/pack.h"
#include "ft8/encode.h"
#include "ft8/pack_77.h"
#include "ft8/encode_91.h"
#include "../librpitx/src/librpitx.h"
bool running=true;
// Convert a sequence of symbols (tones) into a sinewave of continuous phase (FSK).
// Symbol 0 gets encoded as a sine of frequency f0, the others are spaced in increasing
// fashion.
void synth_fsk(const uint8_t *symbols, int num_symbols, float f0, float spacing,
float symbol_rate, float signal_rate, float *signal) {
float phase = 0;
float dt = 1/signal_rate;
float dt_sym = 1/symbol_rate;
float t = 0;
int j = 0;
int i = 0;
while (j < num_symbols) {
float f = f0 + symbols[j] * spacing;
phase += 2 * M_PI * f / signal_rate;
signal[i] = sin(phase);
t += dt;
if (t >= dt_sym) {
// Move to the next symbol
t -= dt_sym;
++j;
}
++i;
}
}
void usage() {
printf("Generate a 15-second WAV file encoding a given message.\n");
printf("Usage:\n");
printf("\n");
printf("gen_ft8 MESSAGE WAV_FILE\n");
printf("\n");
printf("(Note that you might have to enclose your message in quote marks if it contains spaces)\n");
}
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating\n");
}
int main(int argc, char **argv) {
// Expect two command-line arguments
if (argc < 3) {
usage();
return -1;
}
const char *message = argv[1];
const char *wav_path = argv[2];
// First, pack the text data into 72-bit binary message
uint8_t packed[10];
//int rc = packmsg(message, packed);
int rc = ft8_v2::pack77(message, packed);
if (rc < 0) {
printf("Cannot parse message!\n");
printf("RC = %d\n", rc);
return -2;
}
printf("Packed data: ");
for (int j = 0; j < 10; ++j) {
printf("%02x ", packed[j]);
}
printf("\n");
// Second, encode the binary message as a sequence of FSK tones
uint8_t tones[NN]; // NN = 79, lack of better name at the moment
//genft8(packed, 0, tones);
ft8_v2::genft8(packed, tones);
printf("FSK tones: ");
for (int j = 0; j < NN; ++j) {
printf("%d", tones[j]);
}
printf("\n");
// Third, convert the FSK tones into an audio signal
const int num_samples = (int)(0.5 + NN / 6.25 * 12000);
const int num_silence = (15 * 12000 - num_samples) / 2;
float signal[num_silence + num_samples + num_silence];
for (int i = 0; i < num_silence + num_samples + num_silence; i++) {
signal[i] = 0;
}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
ngfmdmasync fmmod(14.070e6,6.25*10000,14,1000);
padgpio pad;
pad.setlevel(7);// Set max power
float VCOFreq[10000];
for(size_t i=0;(i<NN)&&running;i++)
{
for(int j=0;j<10000;j++) VCOFreq[j]=6.25*(float)tones[i];
fmmod.SetFrequencySamples(VCOFreq,10000);
fprintf(stderr,"Freq %f\n",VCOFreq[i]);
}
return 0;
}

Wyświetl plik

@ -1,6 +1,6 @@
The MIT License (MIT)
MIT License
Copyright (c) 2015 Andrew Duncan
Copyright (c) 2016 Galen Alderson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@ -19,4 +19,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Wyświetl plik

@ -0,0 +1,450 @@
/*MIT License
Copyright (c) 2016 Galen Alderson
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Fork and modification for rpitx (c)(F5OEO 2018)
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <strings.h>
#include <time.h>
#include <unistd.h>
#include "../librpitx/src/librpitx.h"
#define PROGRAM_VERSION "0.1"
//Check out main() at the bottom of the file
//You can modify MIN_DELAY and MAX_DELAY to fit your needs.
//Check out https://en.wikipedia.org/wiki/POCSAG
//Also see http://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.584-2-199711-I!!PDF-E.pdf
//They'll be handy when trying to understand this stuff.
//The sync word exists at the start of every batch.
//A batch is 16 words, so a sync word occurs every 16 data words.
#define SYNC 0x7CD215D8
//The idle word is used as padding before the address word, and at the end
//of a message to indicate that the message is finished. Interestingly, the
//idle word does not have a valid CRC code, while the sync word does.
#define IDLE 0x7A89C197
//One frame consists of a pair of two words
#define FRAME_SIZE 2
//One batch consists of 8 frames, or 16 words
#define BATCH_SIZE 16
//The preamble comes before a message, and is a series of alternating
//1,0,1,0... bits, for at least 576 bits. It exists to allow the receiver
//to synchronize with the transmitter
#define PREAMBLE_LENGTH 576
//These bits appear as the first bit of a word, 0 for an address word and
//one for a data word
#define FLAG_ADDRESS 0x000000
#define FLAG_MESSAGE 0x100000
//The last two bits of an address word's data represent the data type
//0x3 for text, and 0x0 for numeric.
#define FLAG_TEXT_DATA 0x3
#define FLAG_NUMERIC_DATA = 0x0;
//Each data word can contain 20 bits of text information. Each character is
//7 bits wide, ASCII encoded. The bit order of the characters is reversed from
//the normal bit order; the most significant bit of a word corresponds to the
//least significant bit of a character it is encoding. The characters are split
//across the words of a message to ensure maximal usage of all bits.
#define TEXT_BITS_PER_WORD 20
//As mentioned above, characters are 7 bit ASCII encoded
#define TEXT_BITS_PER_CHAR 7
//Length of CRC codes in bits
#define CRC_BITS 10
//The CRC generator polynomial
#define CRC_GENERATOR 0b11101101001
/**
* Calculate the CRC error checking code for the given word.
* Messages use a 10 bit CRC computed from the 21 data bits.
* This is calculated through a binary polynomial long division, returning
* the remainder.
* See https://en.wikipedia.org/wiki/Cyclic_redundancy_check#Computation
* for more information.
*/
uint32_t crc(uint32_t inputMsg) {
//Align MSB of denominatorerator with MSB of message
uint32_t denominator = CRC_GENERATOR << 20;
//Message is right-padded with zeroes to the message length + crc length
uint32_t msg = inputMsg << CRC_BITS;
//We iterate until denominator has been right-shifted back to it's original value.
for (int column = 0; column <= 20; column++) {
//Bit for the column we're aligned to
int msgBit = (msg >> (30 - column)) & 1;
//If the current bit is zero, we don't modify the message this iteration
if (msgBit != 0) {
//While we would normally subtract in long division, we XOR here.
msg ^= denominator;
}
//Shift the denominator over to align with the next column
denominator >>= 1;
}
//At this point 'msg' contains the CRC value we've calculated
return msg & 0x3FF;
}
/**
* Calculates the even parity bit for a message.
* If the number of bits in the message is even, return 0, else return 1.
*/
uint32_t parity(uint32_t x) {
//Our parity bit
uint32_t p = 0;
//We xor p with each bit of the input value. This works because
//xoring two one-bits will cancel out and leave a zero bit. Thus
//xoring any even number of one bits will result in zero, and xoring
//any odd number of one bits will result in one.
for (int i = 0; i < 32; i++) {
p ^= (x & 1);
x >>= 1;
}
return p;
}
/**
* Encodes a 21-bit message by calculating and adding a CRC code and parity bit.
*/
uint32_t encodeCodeword(uint32_t msg) {
uint32_t fullCRC = (msg << CRC_BITS) | crc(msg);
uint32_t p = parity(fullCRC);
return (fullCRC << 1) | p;
}
/**
* ASCII encode a null-terminated string as a series of codewords, written
* to (*out). Returns the number of codewords written. Caller should ensure
* that enough memory is allocated in (*out) to contain the message
*
* initial_offset indicates which word in the current batch the function is
* beginning at, so that it can insert SYNC words at appropriate locations.
*/
uint32_t encodeASCII(uint32_t initial_offset, char* str, uint32_t* out) {
//Number of words written to *out
uint32_t numWordsWritten = 0;
//Data for the current word we're writing
uint32_t currentWord = 0;
//Nnumber of bits we've written so far to the current word
uint32_t currentNumBits = 0;
//Position of current word in the current batch
uint32_t wordPosition = initial_offset;
while (*str != 0) {
unsigned char c = *str;
str++;
//Encode the character bits backwards
for (int i = 0; i < TEXT_BITS_PER_CHAR; i++) {
currentWord <<= 1;
currentWord |= (c >> i) & 1;
currentNumBits++;
if (currentNumBits == TEXT_BITS_PER_WORD) {
//Add the MESSAGE flag to our current word and encode it.
*out = encodeCodeword(currentWord | FLAG_MESSAGE);
out++;
currentWord = 0;
currentNumBits = 0;
numWordsWritten++;
wordPosition++;
if (wordPosition == BATCH_SIZE) {
//We've filled a full batch, time to insert a SYNC word
//and start a new one.
*out = SYNC;
out++;
numWordsWritten++;
wordPosition = 0;
}
}
}
}
//Write remainder of message
if (currentNumBits > 0) {
//Pad out the word to 20 bits with zeroes
currentWord <<= 20 - currentNumBits;
*out = encodeCodeword(currentWord | FLAG_MESSAGE);
out++;
numWordsWritten++;
wordPosition++;
if (wordPosition == BATCH_SIZE) {
//We've filled a full batch, time to insert a SYNC word
//and start a new one.
*out = SYNC;
out++;
numWordsWritten++;
wordPosition = 0;
}
}
return numWordsWritten;
}
/**
* An address of 21 bits, but only 18 of those bits are encoded in the address
* word itself. The remaining 3 bits are derived from which frame in the batch
* is the address word. This calculates the number of words (not frames!)
* which must precede the address word so that it is in the right spot. These
* words will be filled with the idle value.
*/
int addressOffset(int address) {
return (address & 0x3) * FRAME_SIZE;
}
/**
* Encode a full text POCSAG transmission addressed to (address).
* (*message) is a null terminated C string.
* (*out) is the destination to which the transmission will be written.
*/
void encodeTransmission(int address, char* message, uint32_t* out) {
//Encode preamble
//Alternating 1,0,1,0 bits for 576 bits, used for receiver to synchronize
//with transmitter
for (int i = 0; i < PREAMBLE_LENGTH / 32; i++) {
*out = 0xAAAAAAAA;
out++;
}
uint32_t* start = out;
//Sync
*out = SYNC;
out++;
//Write out padding before adderss word
int prefixLength = addressOffset(address);
for (int i = 0; i < prefixLength; i++) {
*out = IDLE;
out++;
}
//Write address word.
//The last two bits of word's data contain the message type
//The 3 least significant bits are dropped, as those are encoded by the
//word's location.
*out = encodeCodeword( ((address >> 3) << 2) | FLAG_TEXT_DATA);
out++;
//Encode the message itself
out += encodeASCII(addressOffset(address) + 1, message, out);
//Finally, write an IDLE word indicating the end of the message
*out = IDLE;
out++;
//Pad out the last batch with IDLE to write multiple of BATCH_SIZE + 1
//words (+ 1 is there because of the SYNC words)
size_t written = out - start;
size_t padding = (BATCH_SIZE + 1) - written % (BATCH_SIZE + 1);
for (size_t i = 0; i < padding; i++) {
*out = IDLE;
out++;
}
}
/**
* Calculates the length in words of a text POCSAG message, given the address
* and the number of characters to be transmitted.
*/
size_t textMessageLength(int address, int numChars) {
size_t numWords = 0;
//Padding before address word.
numWords += addressOffset(address);
//Address word itself
numWords++;
//numChars * 7 bits per character / 20 bits per word, rounding up
numWords += (numChars * TEXT_BITS_PER_CHAR + (TEXT_BITS_PER_WORD - 1))
/ TEXT_BITS_PER_WORD;
//Idle word representing end of message
numWords++;
//Pad out last batch with idles
numWords += BATCH_SIZE - (numWords % BATCH_SIZE);
//Batches consist of 16 words each and are preceded by a sync word.
//So we add one word for every 16 message words
numWords += numWords / BATCH_SIZE;
//Preamble of 576 alternating 1,0,1,0 bits before the message
//Even though this comes first, we add it to the length last so it
//doesn't affect the other word-based calculations
numWords += PREAMBLE_LENGTH / 32;
return numWords;
}
void SendFsk(uint64_t Freq,uint32_t *Message,int Size)
{
//int SR=40625;
int SR=1200;
float Deviation=4500;
int FiFoSize=12000;
fprintf(stderr,"Fifo Size =%d, Size = %d",FiFoSize,Size);
fskburst fsktest(Freq,SR,Deviation,14,FiFoSize);
unsigned char *TabSymbol=(unsigned char *)malloc(Size*32);
int Sym=0;
for(int i=0;i<Size;i++)
{
for(int j=31;j>=0;j--)
{
TabSymbol[Sym]=(Message[i]>>j)&0x1;
//fprintf(stderr,"%x ",TabSymbol[Sym]);
Sym++;
}
}
//fprintf(stderr,"Symbols=%d\n",Sym);
fsktest.SetSymbols(TabSymbol,Sym);
sleep(1);
/*for(i=0;i<FiFoSize;i++)
{
TabSymbol[i]=1;
}
fsktest.SetSymbols(TabSymbol,FiFoSize);
sleep(1);*/
fsktest.stop();
}
void print_usage(void)
{
fprintf(stderr,\
"\npocsag -%s\n\
Usage:\npocsag [-f Frequency] \n\
-f float central frequency Hz(50 kHz to 1500 MHz),\n\
-? help (this help).\n\
\n",\
PROGRAM_VERSION);
} /* end function print_usage */
int main(int argc, char* argv[]) {
//Read in lines from STDIN.
//Lines are in the format of address:message
//The program will encode transmissions for each message, writing them
//to STDOUT. It will also encode a rand amount of silence between them,
//from 1-10 seconds in length, to act as a simulated "delay".
int a;
int anyargs = 1;
uint64_t SetFrequency=439875000L;
while(1)
{
a = getopt(argc, argv, "f:");
if(a == -1)
{
if(anyargs) break;
else a='h'; //print usage and exit
}
anyargs = 1;
switch(a)
{
case 'f': // Frequency
SetFrequency = atof(optarg);
break;
default:
print_usage();
exit(1);
break;
}/* end switch a */
}/* end while getopt() */
char line[65536];
srand(time(NULL));
for (;;) {
if (fgets(line, sizeof(line), stdin) == NULL) {
//Exit on EOF
return 0;
}
size_t colonIndex = 0;
for (size_t i = 0; i < sizeof(line); i++) {
if (line[i] == 0) {
fputs("Malformed Line!", stderr);
return 1;
}
if (line[i] == ':') {
colonIndex = i;
break;
}
}
int address = (int) strtol(line, NULL, 10);
char* message = line + colonIndex + 1;
size_t messageLength = textMessageLength(address, strlen(message));
uint32_t* transmission =
(uint32_t*) malloc(sizeof(uint32_t) * messageLength+2);
encodeTransmission(address, message, transmission);
SendFsk(SetFrequency,transmission,messageLength);
//Generate rand amount of silence. Silence is a sample with
//a value of 0.
}
}

Wyświetl plik

@ -1,763 +0,0 @@
//-------------------------------------------------------------------------
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Andrew Duncan
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-------------------------------------------------------------------------
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "raspberry_pi_revision.h"
//-------------------------------------------------------------------------
//
// The file /proc/cpuinfo contains a line such as:-
//
// Revision : 0003
//
// that holds the revision number of the Raspberry Pi.
// Known revisions (prior to the Raspberry Pi 2) are:
//
// +----------+---------+---------+--------+-------------+
// | Revision | Model | PCB Rev | Memory | Manufacture |
// +----------+---------+---------+--------+-------------+
// | 0000 | | | | |
// | 0001 | | | | |
// | 0002 | B | 1 | 256 MB | |
// | 0003 | B | 1 | 256 MB | |
// | 0004 | B | 2 | 256 MB | Sony |
// | 0005 | B | 2 | 256 MB | Qisda |
// | 0006 | B | 2 | 256 MB | Egoman |
// | 0007 | A | 2 | 256 MB | Egoman |
// | 0008 | A | 2 | 256 MB | Sony |
// | 0009 | A | 2 | 256 MB | Qisda |
// | 000a | | | | |
// | 000b | | | | |
// | 000c | | | | |
// | 000d | B | 2 | 512 MB | Egoman |
// | 000e | B | 2 | 512 MB | Sony |
// | 000f | B | 2 | 512 MB | Qisda |
// | 0010 | B+ | 1 | 512 MB | Sony |
// | 0011 | compute | 1 | 512 MB | Sony |
// | 0012 | A+ | 1 | 256 MB | Sony |
// | 0013 | B+ | 1 | 512 MB | Embest |
// | 0014 | compute | 1 | 512 MB | Sony |
// | 0015 | A+ | 1 | 256 MB | Sony |
// +----------+---------+---------+--------+-------------+
//
// If the Raspberry Pi has been over-volted (voiding the warranty) the
// revision number will have 100 at the front. e.g. 1000002.
//
//-------------------------------------------------------------------------
//
// With the release of the Raspberry Pi 2, there is a new encoding of the
// Revision field in /proc/cpuinfo. The bit fields are as follows
//
// +----+----+----+----+----+----+----+----+
// |FEDC|BA98|7654|3210|FEDC|BA98|7654|3210|
// +----+----+----+----+----+----+----+----+
// | | | | | | | |AAAA|
// | | | | | |BBBB|BBBB| |
// | | | | |CCCC| | | |
// | | | |DDDD| | | | |
// | | | EEE| | | | | |
// | | |F | | | | | |
// | | G| | | | | | |
// | | H | | | | | | |
// +----+----+----+----+----+----+----+----+
// |1098|7654|3210|9876|5432|1098|7654|3210|
// +----+----+----+----+----+----+----+----+
//
// +---+-------+--------------+--------------------------------------------+
// | # | bits | contains | values |
// +---+-------+--------------+--------------------------------------------+
// | A | 00-03 | PCB Revision | (the pcb revision number) |
// | B | 04-11 | Model name | A, B, A+, B+, B Pi2, Alpha, Compute Module |
// | | | | unknown, unknown, Zero |
// | C | 12-15 | Processor | BCM2835, BCM2836, BCM2837 |
// | D | 16-19 | Manufacturer | Sony, Egoman, Embest, unknown, Embest |
// | E | 20-22 | Memory size | 256 MB, 512 MB, 1024 MB |
// | F | 23-23 | encoded flag | (if set, revision is a bit field) |
// | G | 24-24 | waranty bit | (if set, warranty void - Pre Pi2) |
// | H | 25-25 | waranty bit | (if set, warranty void - Post Pi2) |
// +---+-------+--------------+--------------------------------------------+
//
// Also, due to some early issues the warranty bit has been move from bit
// 24 to bit 25 of the revision number (i.e. 0x2000000).
//
// e.g.
//
// Revision : A01041
//
// A - PCB Revision - 1 (first revision)
// B - Model Name - 4 (Model B Pi 2)
// C - Processor - 1 (BCM2836)
// D - Manufacturer - 0 (Sony)
// E - Memory - 2 (1024 MB)
// F - Endcoded flag - 1 (encoded cpu info)
//
// Revision : A21041
//
// A - PCB Revision - 1 (first revision)
// B - Model Name - 4 (Model B Pi 2)
// C - Processor - 1 (BCM2836)
// D - Manufacturer - 2 (Embest)
// E - Memory - 2 (1024 MB)
// F - Endcoded flag - 1 (encoded cpu info)
//
// Revision : 900092
//
// A - PCB Revision - 2 (second revision)
// B - Model Name - 9 (Model Zero)
// C - Processor - 0 (BCM2835)
// D - Manufacturer - 0 (Sony)
// E - Memory - 1 (512 MB)
// F - Endcoded flag - 1 (encoded cpu info)
//
// Revision : A02082
//
// A - PCB Revision - 2 (first revision)
// B - Model Name - 8 (Model B Pi 3)
// C - Processor - 2 (BCM2837)
// D - Manufacturer - 0 (Sony)
// E - Memory - 2 (1024 MB)
// F - Endcoded flag - 1 (encoded cpu info)
//
//-------------------------------------------------------------------------
static RASPBERRY_PI_MEMORY_T revisionToMemory[] =
{
RPI_MEMORY_UNKNOWN, // 0
RPI_MEMORY_UNKNOWN, // 1
RPI_256MB, // 2
RPI_256MB, // 3
RPI_256MB, // 4
RPI_256MB, // 5
RPI_256MB, // 6
RPI_256MB, // 7
RPI_256MB, // 8
RPI_256MB, // 9
RPI_MEMORY_UNKNOWN, // A
RPI_MEMORY_UNKNOWN, // B
RPI_MEMORY_UNKNOWN, // C
RPI_512MB, // D
RPI_512MB, // E
RPI_512MB, // F
RPI_512MB, // 10
RPI_512MB, // 11
RPI_256MB, // 12
RPI_512MB, // 13
RPI_512MB, // 14
RPI_256MB // 15
};
static RASPBERRY_PI_MEMORY_T bitFieldToMemory[] =
{
RPI_256MB,
RPI_512MB,
RPI_1024MB
};
//-------------------------------------------------------------------------
static RASPBERRY_PI_PROCESSOR_T bitFieldToProcessor[] =
{
RPI_BROADCOM_2835,
RPI_BROADCOM_2836,
RPI_BROADCOM_2837
};
//-------------------------------------------------------------------------
static RASPBERRY_PI_I2C_DEVICE_T revisionToI2CDevice[] =
{
RPI_I2C_DEVICE_UNKNOWN, // 0
RPI_I2C_DEVICE_UNKNOWN, // 1
RPI_I2C_0, // 2
RPI_I2C_0, // 3
RPI_I2C_1, // 4
RPI_I2C_1, // 5
RPI_I2C_1, // 6
RPI_I2C_1, // 7
RPI_I2C_1, // 8
RPI_I2C_1, // 9
RPI_I2C_DEVICE_UNKNOWN, // A
RPI_I2C_DEVICE_UNKNOWN, // B
RPI_I2C_DEVICE_UNKNOWN, // C
RPI_I2C_1, // D
RPI_I2C_1, // E
RPI_I2C_1, // F
RPI_I2C_1, // 10
RPI_I2C_1, // 11
RPI_I2C_1, // 12
RPI_I2C_1, // 13
RPI_I2C_1, // 14
RPI_I2C_1 // 15
};
//-------------------------------------------------------------------------
static RASPBERRY_PI_MODEL_T bitFieldToModel[] =
{
RPI_MODEL_A,
RPI_MODEL_B,
RPI_MODEL_A_PLUS,
RPI_MODEL_B_PLUS,
RPI_MODEL_B_PI_2,
RPI_MODEL_ALPHA,
RPI_COMPUTE_MODULE,
RPI_MODEL_UNKNOWN,
RPI_MODEL_B_PI_3,
RPI_MODEL_ZERO
};
static RASPBERRY_PI_MODEL_T revisionToModel[] =
{
RPI_MODEL_UNKNOWN, // 0
RPI_MODEL_UNKNOWN, // 1
RPI_MODEL_B, // 2
RPI_MODEL_B, // 3
RPI_MODEL_B, // 4
RPI_MODEL_B, // 5
RPI_MODEL_B, // 6
RPI_MODEL_A, // 7
RPI_MODEL_A, // 8
RPI_MODEL_A, // 9
RPI_MODEL_UNKNOWN, // A
RPI_MODEL_UNKNOWN, // B
RPI_MODEL_UNKNOWN, // C
RPI_MODEL_B, // D
RPI_MODEL_B, // E
RPI_MODEL_B, // F
RPI_MODEL_B_PLUS, // 10
RPI_COMPUTE_MODULE, // 11
RPI_MODEL_A_PLUS, // 12
RPI_MODEL_B_PLUS, // 13
RPI_COMPUTE_MODULE, // 14
RPI_MODEL_A_PLUS // 15
};
//-------------------------------------------------------------------------
static RASPBERRY_PI_MANUFACTURER_T bitFieldToManufacturer[] =
{
RPI_MANUFACTURER_SONY,
RPI_MANUFACTURER_EGOMAN,
RPI_MANUFACTURER_EMBEST,
RPI_MANUFACTURER_UNKNOWN,
RPI_MANUFACTURER_EMBEST
};
static RASPBERRY_PI_MANUFACTURER_T revisionToManufacturer[] =
{
RPI_MANUFACTURER_UNKNOWN, // 0
RPI_MANUFACTURER_UNKNOWN, // 1
RPI_MANUFACTURER_UNKNOWN, // 2
RPI_MANUFACTURER_UNKNOWN, // 3
RPI_MANUFACTURER_SONY, // 4
RPI_MANUFACTURER_QISDA, // 5
RPI_MANUFACTURER_EGOMAN, // 6
RPI_MANUFACTURER_EGOMAN, // 7
RPI_MANUFACTURER_SONY, // 8
RPI_MANUFACTURER_QISDA, // 9
RPI_MANUFACTURER_UNKNOWN, // A
RPI_MANUFACTURER_UNKNOWN, // B
RPI_MANUFACTURER_UNKNOWN, // C
RPI_MANUFACTURER_EGOMAN, // D
RPI_MANUFACTURER_SONY, // E
RPI_MANUFACTURER_QISDA, // F
RPI_MANUFACTURER_SONY, // 10
RPI_MANUFACTURER_SONY, // 11
RPI_MANUFACTURER_SONY, // 12
RPI_MANUFACTURER_EMBEST, // 13
RPI_MANUFACTURER_SONY, // 14
RPI_MANUFACTURER_SONY // 15
};
//-------------------------------------------------------------------------
static int revisionToPcbRevision[] =
{
0, // 0
0, // 1
1, // 2
1, // 3
2, // 4
2, // 5
2, // 6
2, // 7
2, // 8
2, // 9
0, // A
0, // B
0, // C
2, // D
2, // E
2, // F
1, // 10
1, // 11
1, // 12
1, // 13
1, // 14
1 // 15
};
//-------------------------------------------------------------------------
//
// Remove leading and trailing whitespace from a string.
static char *
trimWhiteSpace(
char *string)
{
if (string == NULL)
{
return NULL;
}
while (isspace(*string))
{
string++;
}
if (*string == '\0')
{
return string;
}
char *end = string;
while (*end)
{
++end;
}
--end;
while ((end > string) && isspace(*end))
{
end--;
}
*(end + 1) = 0;
return string;
}
//-------------------------------------------------------------------------
int
getRaspberryPiRevision()
{
int raspberryPiRevision = 0;
FILE *fp = fopen("/proc/cpuinfo", "r");
if (fp == NULL)
{
perror("/proc/cpuinfo");
return raspberryPiRevision;
}
char entry[80];
while (fgets(entry, sizeof(entry), fp) != NULL)
{
char* saveptr = NULL;
char *key = trimWhiteSpace(strtok_r(entry, ":", &saveptr));
char *value = trimWhiteSpace(strtok_r(NULL, ":", &saveptr));
if (strcasecmp("Revision", key) == 0)
{
raspberryPiRevision = strtol(value, NULL, 16);
}
}
fclose(fp);
return raspberryPiRevision;
}
//-------------------------------------------------------------------------
int
getRaspberryPiInformation(
RASPBERRY_PI_INFO_T *info)
{
int revision = getRaspberryPiRevision();
return getRaspberryPiInformationForRevision(revision, info);
}
//-------------------------------------------------------------------------
int
getRaspberryPiInformationForRevision(
int revision,
RASPBERRY_PI_INFO_T *info)
{
int result = 0;
if (info != NULL)
{
info->memory = RPI_MEMORY_UNKNOWN;
info->processor = RPI_PROCESSOR_UNKNOWN;
info->i2cDevice = RPI_I2C_DEVICE_UNKNOWN;
info->model = RPI_MODEL_UNKNOWN;
info->manufacturer = RPI_MANUFACTURER_UNKNOWN;
info->pcbRevision = 0;
info->warrantyBit = 0;
info->revisionNumber = revision;
info->peripheralBase = RPI_PERIPHERAL_BASE_UNKNOWN;
if (revision != 0)
{
size_t maxOriginalRevision = (sizeof(revisionToModel) /
sizeof(revisionToModel[0])) - 1;
// remove warranty bit
revision &= ~0x3000000;
if (revision & 0x800000)
{
// Raspberry Pi2 style revision encoding
result = 2;
if (info->revisionNumber & 0x2000000)
{
info->warrantyBit = 1;
}
int memoryIndex = (revision & 0x700000) >> 20;
size_t knownMemoryValues = sizeof(bitFieldToMemory)
/ sizeof(bitFieldToMemory[0]);
if (memoryIndex < knownMemoryValues)
{
info->memory = bitFieldToMemory[memoryIndex];
}
else
{
info->memory = RPI_MEMORY_UNKNOWN;
}
int processorIndex = (revision & 0xF000) >> 12;
size_t knownProcessorValues = sizeof(bitFieldToProcessor)
/ sizeof(bitFieldToProcessor[0]);
if (processorIndex < knownProcessorValues)
{
info->processor = bitFieldToProcessor[processorIndex];
}
else
{
info->processor = RPI_PROCESSOR_UNKNOWN;
}
// If some future firmware changes the Rev number of
// older Raspberry Pis, then need to work out the i2c
// device.
info->i2cDevice = RPI_I2C_1;
int modelIndex = (revision & 0xFF0) >> 4;
size_t knownModelValues = sizeof(bitFieldToModel)
/ sizeof(bitFieldToModel[0]);
if (modelIndex < knownModelValues)
{
info->model = bitFieldToModel[modelIndex];
}
else
{
info->model = RPI_MODEL_UNKNOWN;
}
int madeByIndex = (revision & 0xF0000) >> 16;
size_t knownManufacturerValues = sizeof(bitFieldToManufacturer)
/ sizeof(bitFieldToManufacturer[0]);
if (madeByIndex < knownManufacturerValues)
{
info->manufacturer = bitFieldToManufacturer[madeByIndex];
}
else
{
info->manufacturer = RPI_MANUFACTURER_UNKNOWN;
}
info->pcbRevision = revision & 0xF;
}
else if (revision <= maxOriginalRevision)
{
// Original revision encoding
result = 1;
if (info->revisionNumber & 0x1000000)
{
info->warrantyBit = 1;
}
info->memory = revisionToMemory[revision];
info->i2cDevice = revisionToI2CDevice[revision];
info->model = revisionToModel[revision];
info->manufacturer = revisionToManufacturer[revision];
info->pcbRevision = revisionToPcbRevision[revision];
if (info->model == RPI_MODEL_UNKNOWN)
{
info->processor = RPI_PROCESSOR_UNKNOWN;
}
else
{
info->processor = RPI_BROADCOM_2835;
}
}
}
switch (info->processor)
{
case RPI_PROCESSOR_UNKNOWN:
info->peripheralBase = RPI_PERIPHERAL_BASE_UNKNOWN;
break;
case RPI_BROADCOM_2835:
info->peripheralBase = RPI_BROADCOM_2835_PERIPHERAL_BASE;
break;
case RPI_BROADCOM_2836:
info->peripheralBase = RPI_BROADCOM_2836_PERIPHERAL_BASE;
break;
case RPI_BROADCOM_2837:
info->peripheralBase = RPI_BROADCOM_2837_PERIPHERAL_BASE;
break;
}
}
return result;
}
//-------------------------------------------------------------------------
const char *
raspberryPiMemoryToString(
RASPBERRY_PI_MEMORY_T memory)
{
const char *string = "unknown";
switch(memory)
{
case RPI_256MB:
string = "256 MB";
break;
case RPI_512MB:
string = "512 MB";
break;
case RPI_1024MB:
string = "1024 MB";
break;
default:
break;
}
return string;
}
//-------------------------------------------------------------------------
const char *
raspberryPiProcessorToString(
RASPBERRY_PI_PROCESSOR_T processor)
{
const char *string = "unknown";
switch(processor)
{
case RPI_BROADCOM_2835:
string = "Broadcom BCM2835";
break;
case RPI_BROADCOM_2836:
string = "Broadcom BCM2836";
break;
case RPI_BROADCOM_2837:
string = "Broadcom BCM2837";
break;
default:
break;
}
return string;
}
//-------------------------------------------------------------------------
const char *
raspberryPiI2CDeviceToString(
RASPBERRY_PI_I2C_DEVICE_T i2cDevice)
{
const char *string = "unknown";
switch(i2cDevice)
{
case RPI_I2C_0:
string = "/dev/i2c-0";
break;
case RPI_I2C_1:
string = "/dev/i2c-1";
break;
default:
break;
}
return string;
}
//-------------------------------------------------------------------------
const char *
raspberryPiModelToString(
RASPBERRY_PI_MODEL_T model)
{
const char *string = "unknown";
switch(model)
{
case RPI_MODEL_A:
string = "Model A";
break;
case RPI_MODEL_B:
string = "Model B";
break;
case RPI_MODEL_A_PLUS:
string = "Model A+";
break;
case RPI_MODEL_B_PLUS:
string = "Model B+";
break;
case RPI_MODEL_B_PI_2:
string = "Model B Pi 2";
break;
case RPI_MODEL_ALPHA:
string = "Alpha";
break;
case RPI_COMPUTE_MODULE:
string = "Compute Module";
break;
case RPI_MODEL_ZERO:
string = "Model Zero";
break;
case RPI_MODEL_B_PI_3:
string = "Model B Pi 3";
break;
default:
break;
}
return string;
}
//-------------------------------------------------------------------------
const char *
raspberryPiManufacturerToString(
RASPBERRY_PI_MANUFACTURER_T manufacturer)
{
const char *string = "unknown";
switch(manufacturer)
{
case RPI_MANUFACTURER_SONY:
string = "Sony";
break;
case RPI_MANUFACTURER_EGOMAN:
string = "Egoman";
break;
case RPI_MANUFACTURER_QISDA:
string = "Qisda";
break;
case RPI_MANUFACTURER_EMBEST:
string = "Embest";
break;
default:
break;
}
return string;
}

Wyświetl plik

@ -1,163 +0,0 @@
//-------------------------------------------------------------------------
//
// The MIT License (MIT)
//
// Copyright (c) 2015 Andrew Duncan
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
// CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
// TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-------------------------------------------------------------------------
#ifndef RASPBERRY_PI_INFO_H
#define RASPBERRY_PI_INFO_H
//-------------------------------------------------------------------------
#include <stdint.h>
//-------------------------------------------------------------------------
#ifdef __cplusplus
extern "C" {
#endif
//-------------------------------------------------------------------------
#define RPI_PERIPHERAL_BASE_UNKNOWN 0
#define RPI_BROADCOM_2835_PERIPHERAL_BASE 0x20000000
#define RPI_BROADCOM_2836_PERIPHERAL_BASE 0x3F000000
#define RPI_BROADCOM_2837_PERIPHERAL_BASE 0x3F000000
typedef enum
{
RPI_MEMORY_UNKNOWN = -1,
RPI_256MB = 256,
RPI_512MB = 512,
RPI_1024MB = 1024,
}
RASPBERRY_PI_MEMORY_T;
typedef enum
{
RPI_PROCESSOR_UNKNOWN = -1,
RPI_BROADCOM_2835 = 2835,
RPI_BROADCOM_2836 = 2836,
RPI_BROADCOM_2837 = 2837
}
RASPBERRY_PI_PROCESSOR_T;
typedef enum
{
RPI_I2C_DEVICE_UNKNOWN = -1,
RPI_I2C_0 = 0,
RPI_I2C_1 = 1
}
RASPBERRY_PI_I2C_DEVICE_T;
typedef enum
{
RPI_MODEL_UNKNOWN = -1,
RPI_MODEL_A,
RPI_MODEL_B,
RPI_MODEL_A_PLUS,
RPI_MODEL_B_PLUS,
RPI_MODEL_B_PI_2,
RPI_MODEL_ALPHA,
RPI_COMPUTE_MODULE,
RPI_MODEL_ZERO,
RPI_MODEL_B_PI_3
}
RASPBERRY_PI_MODEL_T;
typedef enum
{
RPI_MANUFACTURER_UNKNOWN = -1,
RPI_MANUFACTURER_SONY,
RPI_MANUFACTURER_EGOMAN,
RPI_MANUFACTURER_QISDA,
RPI_MANUFACTURER_EMBEST,
}
RASPBERRY_PI_MANUFACTURER_T;
//-------------------------------------------------------------------------
typedef struct
{
RASPBERRY_PI_MEMORY_T memory;
RASPBERRY_PI_PROCESSOR_T processor;
RASPBERRY_PI_I2C_DEVICE_T i2cDevice;
RASPBERRY_PI_MODEL_T model;
RASPBERRY_PI_MANUFACTURER_T manufacturer;
int pcbRevision;
int warrantyBit;
int revisionNumber;
uint32_t peripheralBase;
}
RASPBERRY_PI_INFO_T;
//-------------------------------------------------------------------------
// getRaspberryPiInformation()
//
// return - 0 - failed to get revision from /proc/cpuinfo
// 1 - found classic revision number
// 2 - found Pi 2 style revision number
int
getRaspberryPiInformation(
RASPBERRY_PI_INFO_T *info);
int
getRaspberryPiInformationForRevision(
int revision,
RASPBERRY_PI_INFO_T *info);
int
getRaspberryPiRevision(void);
const char *
raspberryPiMemoryToString(
RASPBERRY_PI_MEMORY_T memory);
const char *
raspberryPiProcessorToString(
RASPBERRY_PI_PROCESSOR_T processor);
const char *
raspberryPiI2CDeviceToString(
RASPBERRY_PI_I2C_DEVICE_T i2cDevice);
const char *
raspberryPiModelToString(
RASPBERRY_PI_MODEL_T model);
const char *
raspberryPiManufacturerToString(
RASPBERRY_PI_MANUFACTURER_T manufacturer);
//-------------------------------------------------------------------------
#ifdef __cplusplus
}
#endif
//-------------------------------------------------------------------------
#endif

Wyświetl plik

@ -0,0 +1,364 @@
/*<rpitx is a software which use the GPIO of Raspberry Pi to transmit HF>
This version is to allow back compatibility with rpitx v1
Copyright (C) 2015-2018 Evariste COURJAUD F5OEO (evaristec@gmail.com)
Transmitting on HF band is surely not permitted without license (Hamradio for example).
Usage of this software is not the responsability of the author.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program 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. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Thanks to first test of RF with Pifm by Oliver Mattos and Oskar Weigl
INSPIRED BY THE IMPLEMENTATION OF PIFMDMA by Richard Hirst <richardghirst@gmail.com> December 2012
Helped by a code fragment by PE1NNZ (http://pe1nnz.nl.eu.org/2013/05/direct-ssb-generation-on-pll.html)
*/
#include <unistd.h>
#include "../librpitx/src/librpitx.h"
#include "stdio.h"
#include <stdarg.h> /* va_list, va_start, va_arg, va_end */
#include <cstring>
#include <signal.h>
#define PROGRAM_VERSION "2.0"
bool running=true;
void print_usage(void)
{
fprintf(stderr,"Warning : rpitx V2 is only to try to be compatible with version 1\n");
fprintf(stderr,\
"\nrpitx -%s\n\
Usage:\nrpitx [-i File Input][-m ModeInput] [-f frequency output] [-s Samplerate] [-l] [-p ppm] [-h] \n\
-m {IQ(FileInput is a Stereo Wav contains I on left Channel, Q on right channel)}\n\
{IQFLOAT(FileInput is a Raw float interlaced I,Q)}\n\
{RF(FileInput is a (double)Frequency,Time in nanoseconds}\n\
{RFA(FileInput is a (double)Frequency,(int)Time in nanoseconds,(float)Amplitude}\n\
{VFO (constant frequency)}\n\
-i path to File Input \n\
-f float frequency to output on GPIO_4 pin 7 in khz : (130 kHz to 750 MHz),\n\
-l loop mode for file input\n\
-p float frequency correction in parts per million (ppm), positive or negative, for calibration, default 0.\n\
-h help (this help).\n\
\n",\
PROGRAM_VERSION);
} /* end function print_usage */
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating %x\n",num);
}
static void fatal(char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
va_end(ap);
terminate(0);
}
int main(int argc, char* argv[])
{
enum {MODE_RPITX_IQ=0,MODE_RPITX_RF,MODE_RPITX_RFA,MODE_RPITX_IQ_FLOAT,MODE_RPITX_VFO};
int a;
int anyargs = 0;
char Mode = MODE_IQ; // By default
int SampleRate=48000;
float SetFrequency=1e6;//1MHZ
float ppmpll=0.0;
int SetDma=0;
char *FileName=NULL;
FILE *FileInHandle=NULL;
bool loop_mode_flag=false;
bool useStdin;
int Harmonic=1;
while(1)
{
a = getopt(argc, argv, "i:f:m:s:p:hld:w:c:ra:");
if(a == -1)
{
if(anyargs) break;
else a='h'; //print usage and exit
}
anyargs = 1;
switch(a)
{
case 'i': // File name
FileName = optarg;
break;
case 'f': // Frequency
SetFrequency = atof(optarg)*1e3;
break;
case 'm': // Mode (IQ,IQFLOAT,RF,RFA)
if(strcmp("IQ",optarg)==0) Mode=MODE_RPITX_IQ;
if(strcmp("RF",optarg)==0) Mode=MODE_RPITX_RF;
if(strcmp("RFA",optarg)==0) Mode=MODE_RPITX_RFA;
if(strcmp("IQFLOAT",optarg)==0) Mode=MODE_RPITX_IQ_FLOAT;
if(strcmp("VFO",optarg)==0) Mode=MODE_RPITX_VFO;
break;
case 's': // SampleRate (Only needeed in IQ mode)
SampleRate = atoi(optarg);
break;
case 'p': // ppmcorrection
ppmpll = atof(optarg);
break;
case 'h': // help
print_usage();
exit(1);
break;
case 'l': // loop mode
loop_mode_flag = true;
break;
case 'd': // Dma Sample Burst
fprintf(stderr,"Warning : 'd' parameter not used in this version\n");
break;
case 'c': fprintf(stderr,"Warning : 'c' parameter not used in this version\n");
break;
case 'w': // No use pwmfrequency
fprintf(stderr,"Warning : 'w' parameter not used in this version\n");
break;
case 'r': // Randomize PWM frequency
fprintf(stderr,"Warning : 'r' parameter not used in this version\n");
break;
case 'a': // DMA Channel 1-14
fprintf(stderr,"Warning : 'a' parameter not used in this version\n");
break;
case -1:
break;
case '?':
if (isprint(optopt) )
{
fprintf(stderr, "rpitx: unknown option `-%c'.\n", optopt);
}
else
{
fprintf(stderr, "rpitx: unknown option character `\\x%x'.\n", optopt);
}
print_usage();
exit(1);
break;
default:
print_usage();
exit(1);
break;
}/* end switch a */
}/* end while getopt() */
//Open File Input for modes which need it
if((Mode==MODE_RPITX_IQ)||(Mode==MODE_RPITX_IQ_FLOAT)||(Mode==MODE_RPITX_RF)||(Mode==MODE_RPITX_RFA))
{
if(FileName && strcmp(FileName,"-")==0)
{
FileInHandle = stdin;
useStdin = true;
}
else FileInHandle = fopen(FileName ,"rb");
if (FileInHandle ==NULL)
{
fatal("Failed to read Filein %s\n",FileName);
}
}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
fprintf(stderr,"Warning : rpitx V2 is only to try to be compatible with version 1\n");
// For IQ
#define IQBURST 4000
iqdmasync *iqsender=NULL;
std::complex<float> CIQBuffer[IQBURST];
int Decimation=1;
// For RF (FM)
//For RFA (AM)
amdmasync *amsender=NULL;
ngfmdmasync *fmsender=NULL;
float AmOrFmBuffer[IQBURST];
int FifoSize=IQBURST*4;
//Init
switch(Mode)
{
case MODE_RPITX_IQ:
case MODE_RPITX_IQ_FLOAT:
{
iqsender=new iqdmasync(SetFrequency,SampleRate,14,FifoSize,MODE_IQ);
iqsender->Setppm(ppmpll);
}
break;
case MODE_RPITX_RFA://Amplitude
{
amsender=new amdmasync(SetFrequency,SampleRate,14,FifoSize);
}
break;
case MODE_RPITX_RF://Frequency
{
fmsender=new ngfmdmasync(SetFrequency,SampleRate,14,FifoSize);
}
}
//resetFile();
//return pitx_run(Mode, SampleRate, SetFrequency, ppmpll, NoUsePwmFrequency, readFile, resetFile, NULL,SetDma);
while(running)
{
switch(Mode)
{
case MODE_RPITX_IQ:
case MODE_RPITX_IQ_FLOAT:
{
int CplxSampleNumber=0;
switch(Mode)
{
case MODE_RPITX_IQ://I16
{
static short IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(short),IQBURST*2,FileInHandle);
if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>(IQBuffer[i*2]/32768.0,IQBuffer[i*2+1]/32768.0);
}
}
}
else
{
printf("End of file\n");
if(loop_mode_flag&&!useStdin)
fseek ( FileInHandle , 0 , SEEK_SET );
else
running=false;
}
}
break;
case MODE_RPITX_IQ_FLOAT:
{
static float IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(float),IQBURST*2,FileInHandle);
if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>(IQBuffer[i*2],IQBuffer[i*2+1]);
}
//printf("%f %f\n",(IQBuffer[i*2]-127.5)/128.0,(IQBuffer[i*2+1]-127.5)/128.0);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag&&useStdin)
fseek ( FileInHandle , 0 , SEEK_SET );
else
running=false;
}
}
break;
}
iqsender->SetIQSamples(CIQBuffer,CplxSampleNumber,Harmonic);
}
break;
case MODE_RPITX_RFA://Amplitude
case MODE_RPITX_RF://Frequence
{
typedef struct {
double Frequency;
uint32_t WaitForThisSample;
} samplerf_t;
int SampleNumber=0;
static samplerf_t RfBuffer[IQBURST];
int nbread=fread(RfBuffer,sizeof(samplerf_t),IQBURST,FileInHandle);
if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread;i++)
{
AmOrFmBuffer[SampleNumber++]=(float)(RfBuffer[i].Frequency);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag&&useStdin)
fseek ( FileInHandle , 0 , SEEK_SET );
else
running=false;
}
switch(Mode)
{
case MODE_RPITX_RFA:
{
amsender->SetAmSamples(AmOrFmBuffer,SampleNumber);
}
break;
case MODE_RPITX_RF:
{
fmsender->SetFrequencySamples(AmOrFmBuffer,SampleNumber);
}
break;
}
}
break;
case MODE_RPITX_VFO:
{
}
break;
}
}
// This is the end
switch(Mode)
{
case MODE_RPITX_IQ:
case MODE_RPITX_IQ_FLOAT:delete(iqsender);
break;
case MODE_RPITX_RFA:delete(amsender);break;
case MODE_RPITX_RF:delete(fmsender);break;
}
}

286
src/sendiq.cpp 100644
Wyświetl plik

@ -0,0 +1,286 @@
#include <unistd.h>
#include "librpitx/src/librpitx.h"
#include "stdio.h"
#include <cstring>
#include <signal.h>
bool running=true;
#define PROGRAM_VERSION "0.1"
void SimpleTestFileIQ(uint64_t Freq)
{
}
void print_usage(void)
{
fprintf(stderr,\
"\nsendiq -%s\n\
Usage:\nsendiq [-i File Input][-s Samplerate][-l] [-f Frequency] [-h Harmonic number] \n\
-i path to File Input \n\
-s SampleRate 10000-250000 \n\
-f float central frequency Hz(50 kHz to 1500 MHz),\n\
-l loop mode for file input\n\
-h Use harmonic number n\n\
-t IQ type (i16 default) {i16,u8,float,double}\n\
-? help (this help).\n\
\n",\
PROGRAM_VERSION);
} /* end function print_usage */
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating %x\n",num);
}
#define MAX_SAMPLERATE 200000
int main(int argc, char* argv[])
{
int a;
int anyargs = 1;
float SetFrequency=434e6;
float SampleRate=48000;
bool loop_mode_flag=false;
char* FileName=NULL;
int Harmonic=1;
enum {typeiq_i16,typeiq_u8,typeiq_float,typeiq_double};
int InputType=typeiq_i16;
int Decimation=1;
while(1)
{
a = getopt(argc, argv, "i:f:s:h:lt:");
if(a == -1)
{
if(anyargs) break;
else a='h'; //print usage and exit
}
anyargs = 1;
switch(a)
{
case 'i': // File name
FileName = optarg;
break;
case 'f': // Frequency
SetFrequency = atof(optarg);
break;
case 's': // SampleRate (Only needeed in IQ mode)
SampleRate = atoi(optarg);
if(SampleRate>MAX_SAMPLERATE)
{
for(int i=2;i<12;i++) //Max 10 times samplerate
{
if(SampleRate/i<MAX_SAMPLERATE)
{
SampleRate=SampleRate/i;
Decimation=i;
break;
}
}
if(Decimation==1)
{
fprintf(stderr,"SampleRate too high : >%d sample/s",10*MAX_SAMPLERATE);
exit(1);
}
else
{
fprintf(stderr,"Warning samplerate too high, decimation by %d will be performed",Decimation);
}
};
break;
case 'h': // help
Harmonic=atoi(optarg);
break;
case 'l': // loop mode
loop_mode_flag = true;
break;
case 't': // inout type
if(strcmp(optarg,"i16")==0) InputType=typeiq_i16;
if(strcmp(optarg,"u8")==0) InputType=typeiq_u8;
if(strcmp(optarg,"float")==0) InputType=typeiq_float;
if(strcmp(optarg,"double")==0) InputType=typeiq_double;
break;
case -1:
break;
case '?':
if (isprint(optopt) )
{
fprintf(stderr, "sendiq: unknown option `-%c'.\n", optopt);
}
else
{
fprintf(stderr, "sendiq: unknown option character `\\x%x'.\n", optopt);
}
print_usage();
exit(1);
break;
default:
print_usage();
exit(1);
break;
}/* end switch a */
}/* end while getopt() */
if(FileName==NULL) {fprintf(stderr,"Need an input\n");exit(1);}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
FILE *iqfile=NULL;
if(strcmp(FileName,"-")==0)
iqfile=fopen("/dev/stdin","rb");
else
iqfile=fopen(FileName ,"rb");
if (iqfile==NULL)
{
printf("input file issue\n");
exit(0);
}
#define IQBURST 4000
int SR=48000;
int FifoSize=IQBURST*4;
iqdmasync iqtest(SetFrequency,SampleRate,14,FifoSize,MODE_IQ);
iqtest.SetPLLMasterLoop(3,4,0);
//iqtest.print_clock_tree();
//iqtest.SetPLLMasterLoop(5,6,0);
std::complex<float> CIQBuffer[IQBURST];
while(running)
{
int CplxSampleNumber=0;
switch(InputType)
{
case typeiq_i16:
{
static short IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(short),IQBURST*2,iqfile);
//if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>(IQBuffer[i*2]/32768.0,IQBuffer[i*2+1]/32768.0);
}
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( iqfile , 0 , SEEK_SET );
else
running=false;
}
}
break;
case typeiq_u8:
{
static unsigned char IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(unsigned char),IQBURST*2,iqfile);
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>((IQBuffer[i*2]-127.5)/128.0,(IQBuffer[i*2+1]-127.5)/128.0);
}
//printf("%f %f\n",(IQBuffer[i*2]-127.5)/128.0,(IQBuffer[i*2+1]-127.5)/128.0);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( iqfile , 0 , SEEK_SET );
else
running=false;
}
}
break;
case typeiq_float:
{
static float IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(float),IQBURST*2,iqfile);
//if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>(IQBuffer[i*2],IQBuffer[i*2+1]);
}
//printf("%f %f\n",(IQBuffer[i*2]-127.5)/128.0,(IQBuffer[i*2+1]-127.5)/128.0);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( iqfile , 0 , SEEK_SET );
else
running=false;
}
}
break;
case typeiq_double:
{
static double IQBuffer[IQBURST*2];
int nbread=fread(IQBuffer,sizeof(double),IQBURST*2,iqfile);
//if(nbread==0) continue;
if(nbread>0)
{
for(int i=0;i<nbread/2;i++)
{
if(i%Decimation==0)
{
CIQBuffer[CplxSampleNumber++]=std::complex<float>(IQBuffer[i*2],IQBuffer[i*2+1]);
}
//printf("%f %f\n",(IQBuffer[i*2]-127.5)/128.0,(IQBuffer[i*2+1]-127.5)/128.0);
}
}
else
{
printf("End of file\n");
if(loop_mode_flag)
fseek ( iqfile , 0 , SEEK_SET );
else
running=false;
}
}
break;
}
iqtest.SetIQSamples(CIQBuffer,CplxSampleNumber,Harmonic);
}
iqtest.stop();
}

Wyświetl plik

@ -0,0 +1,107 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cstring>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <math.h>
#include <time.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/mman.h>
#include "../librpitx/src/librpitx.h"
int FilePicture;
int FileFreqTiming;
iqdmasync *fmmod;
static double GlobalTuningFrequency=00000.0;
int FifoSize=35000;
bool running=true;
void ProcessPicture(float Excursion)
{
int EndOfPicture=0;
int NbRead=0;
int VIS=1;
static unsigned char Line[320*3];
std::complex<float> sample[320];
int Row;
//while(1)
{
while((EndOfPicture==0)&&(running==true))
{
NbRead=read(FilePicture,Line,320);
if(NbRead!=320) EndOfPicture=1;
for(Row=0;Row<320;Row++)
{
sample[Row]=std::complex<float>((Row/320.0-0.5)*Excursion,(Line[Row])/64);
//sample[Row]=std::complex<float>((Row/320.0-0.5)*Excursion,(Row/320.0)*8);
//fprintf(stderr,"%f ",sample[Row].imag());
}
//fprintf(stderr,"\n");
fmmod->SetIQSamples(sample,320,1);
}
}
}
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating %x\n",num);
}
int main(int argc, char **argv)
{
float frequency=144.5e6;
float Excursion=100000;
if (argc > 2)
{
char *sFilePicture=(char *)argv[1];
FilePicture = open(argv[1], O_RDONLY);
frequency=atof(argv[2]);
}
if (argc > 3)
{
Excursion=atof(argv[3]);
}
if(argc<2)
{
printf("usage : spectrum picture.rgb frequency(Hz) Excursion(Hz)\n");
exit(0);
}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
fmmod=new iqdmasync(frequency,10000,14,FifoSize,MODE_FREQ_A);
ProcessPicture(Excursion);
close(FilePicture);
delete fmmod;
return 0;
}

Wyświetl plik

@ -3,11 +3,13 @@ CC=gcc -pipe
CFLAGS=-Wall -g
OBJS=ssb_gen.o test_ssb.o
HEADERS=ssb_gen.h
LIBS=-lsndfile
LIBS=-lsndfile
%.o:%.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -c $< -o $@
testssb:$(OBJS) $(HEADERS) test_ssb.o
$(CC) -o testssb $(OBJS) $(LIBS)
$(CC) -o testssb $(OBJS) $(LIBS)

Wyświetl plik

@ -196,7 +196,7 @@ void ssb(float in, int USB, float* out_I, float* out_Q)
// low pass filter y to keep only audio band
y = fir_filt( audio_fir, y );
#define AUDIO_COMPRESSOR //???
//#define AUDIO_COMPRESSOR //???
#ifdef AUDIO_COMPRESSOR //???
//----------- audio compressor
//--- code inspired from http://www.musicdsp.org/showone.php?id=169

Wyświetl plik

@ -70,7 +70,7 @@ int main(int argc, char **argv)
printf ("Channels : %d\n", sf_out.channels);
// la porteuse SSB est décalée de +1K
ssb_init( 1000 );
ssb_init( 000 );
/* While there are.frames in the input file, read them, process
** them and write them to the output file.

Wyświetl plik

@ -2,7 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <cstring>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
@ -14,24 +14,44 @@
#include <fcntl.h>
#include <sys/mman.h>
#include "../librpitx/src/librpitx.h"
int FilePicture;
int FileFreqTiming;
static double GlobalTuningFrequency=00000.0;
void playtone(double Frequency,uint32_t Timing)
ngfmdmasync *fmmod;
static double GlobalTuningFrequency=00000.0;
int FifoSize=10000; //10ms
bool running=true;
void playtone(double Frequency,uint32_t Timing)//Timing in 0.1us
{
typedef struct {
double Frequency;
uint32_t WaitForThisSample;
} samplerf_t;
samplerf_t RfSample;
RfSample.Frequency=GlobalTuningFrequency+Frequency;
RfSample.WaitForThisSample=Timing*100L; //en 100 de nanosecond
//printf("Freq =%f Timing=%d\n",RfSample.Frequency,RfSample.WaitForThisSample);
if (write(FileFreqTiming,&RfSample,sizeof(samplerf_t)) != sizeof(samplerf_t)) {
fprintf(stderr, "Unable to write sample");
}
uint32_t SumTiming=0;
SumTiming+=Timing%100;
if(SumTiming>=100)
{
Timing+=100;
SumTiming=SumTiming-100;
}
int NbSamples=(Timing/100);
while(NbSamples>0)
{
usleep(10);
int Available=fmmod->GetBufferAvailable();
if(Available>FifoSize/2)
{
int Index=fmmod->GetUserMemIndex();
if(Available>NbSamples) Available=NbSamples;
for(int j=0;j<Available;j++)
{
fmmod->SetFrequencySample(Index+j,Frequency);
NbSamples--;
}
}
}
}
void addvisheader()
@ -93,7 +113,7 @@ void addvistrailer ()
void ProcessMartin1()
{
static uint32_t FrequencyMartin1[3]={1200,1500,1500};
static uint32_t TimingMartin1[3]={48720,5720,4576};
static uint32_t TimingMartin1[3]={48620,5720,4576};
int EndOfPicture=0;
int NbRead=0;
@ -104,7 +124,7 @@ void ProcessMartin1()
addvisheader();
addvistrailer();
while(EndOfPicture==0)
while((EndOfPicture==0)&&(running==true))
{
NbRead=read(FilePicture,Line,320*3);
if(NbRead!=320*3) EndOfPicture=1;
@ -139,25 +159,43 @@ void ProcessMartin1()
}
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating %x\n",num);
}
int main(int argc, char **argv)
{
float frequency=144.5e6;
if (argc > 2)
{
char *sFilePicture=(char *)argv[1];
FilePicture = open(argv[1], O_RDONLY);
char *sFileFreqTiming=(char *)argv[2];
FileFreqTiming = open(argv[2], O_WRONLY|O_CREAT, 0644);
frequency=atof(argv[2]);
}
else
{
printf("usage : pisstv picture.rgb outputfreq.bin\n");
printf("usage : pisstv picture.rgb frequency(Hz)\n");
exit(0);
}
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
fmmod=new ngfmdmasync(frequency,100000,14,FifoSize);
ProcessMartin1();
close(FilePicture);
close(FileFreqTiming);
close(FilePicture);
delete fmmod;
return 0;
}

124
src/tune.cpp 100644
Wyświetl plik

@ -0,0 +1,124 @@
#include <unistd.h>
#include "librpitx/src/librpitx.h"
#include "stdio.h"
#include <cstring>
#include <signal.h>
bool running=true;
#define PROGRAM_VERSION "0.1"
void print_usage(void)
{
fprintf(stderr,\
"\ntune -%s\n\
Usage:\ntune [-f Frequency] [-h] \n\
-f float frequency carrier Hz(50 kHz to 1500 MHz),\n\
-e exit immediately without killing the carrier,\n\
-h help (this help).\n\
\n",\
PROGRAM_VERSION);
} /* end function print_usage */
static void
terminate(int num)
{
running=false;
fprintf(stderr,"Caught signal - Terminating\n");
}
int main(int argc, char* argv[])
{
int a;
int anyargs = 0;
float SetFrequency=434e6;
bool NotKill=false;
while(1)
{
a = getopt(argc, argv, "f:eh");
if(a == -1)
{
if(anyargs) break;
else a='h'; //print usage and exit
}
anyargs = 1;
switch(a)
{
case 'f': // Frequency
SetFrequency = atof(optarg);
break;
case 'e': // SampleRate (Only needeed in IQ mode)
NotKill=true;
break;
case 'h': // help
print_usage();
exit(1);
break;
case -1:
break;
case '?':
if (isprint(optopt) )
{
fprintf(stderr, "tune: unknown option `-%c'.\n", optopt);
}
else
{
fprintf(stderr, "tune: unknown option character `\\x%x'.\n", optopt);
}
print_usage();
exit(1);
break;
default:
print_usage();
exit(1);
break;
}/* end switch a */
}/* end while getopt() */
for (int i = 0; i < 64; i++) {
struct sigaction sa;
std::memset(&sa, 0, sizeof(sa));
sa.sa_handler = terminate;
sigaction(i, &sa, NULL);
}
generalgpio gengpio;
gengpio.setpulloff(4);
padgpio pad;
pad.setlevel(7);
clkgpio *clk=new clkgpio;
clk->SetAdvancedPllMode(true);
clk->SetCenterFrequency(SetFrequency,10);
clk->SetFrequency(000);
clk->enableclk(4);
//clk->enableclk(6);//CLK2 : experimental
clk->enableclk(20);//CLK1 duplicate on GPIO20 for more power ?
if(!NotKill)
{
while(running)
{
sleep(1);
}
clk->disableclk(4);
clk->disableclk(20);
delete(clk);
}
else
{
//Ugly method : not destroying clk object will not call destructor thus leaving clk running
}
}

50
sv1afnfilter.sh 100755
Wyświetl plik

@ -0,0 +1,50 @@
#COMMAND A BANDPATH FILTER FROM SV1AFN
#GPIO Declaration
if [ -f /sys/class/gpio/gpio26 ]; then
echo GPIO declaration
echo 26 > /sys/class/gpio/export
echo 19 > /sys/class/gpio/export
echo 13 > /sys/class/gpio/export
echo 6 > /sys/class/gpio/export
#GPIO out
echo GPIO Mode OUT
echo out > /sys/class/gpio/gpio26/direction
echo out > /sys/class/gpio/gpio19/direction
echo out > /sys/class/gpio/gpio13/direction
echo out > /sys/class/gpio/gpio6/direction
fi
#Initialization : All at zero (disable filter)
reset_all()
{
echo 0 > /sys/class/gpio/gpio26/value
echo 0 > /sys/class/gpio/gpio19/value
echo 0 > /sys/class/gpio/gpio13/value
echo 0 > /sys/class/gpio/gpio6/value
}
reset_all
case "$1" in
"10m")
echo 1 > /sys/class/gpio/gpio26/value
;;
"15m")
echo 1 > /sys/class/gpio/gpio19/value
;;
"20m")
echo 1 > /sys/class/gpio/gpio13/value
;;
"40m")
echo 1 > /sys/class/gpio/gpio6/value
;;
*)
;;
esac

Wyświetl plik

@ -1,3 +1,3 @@
./piam sampleaudio.wav am.rfa
sudo ./rpitx -m RFA -i am.rfa -f 433900 -l
#TODO using the AM mode from librpitx
echo Need to implement
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f | csdr gain_ff 4.0 | csdr dsb_fc | sudo ./rpitx -i - -m IQFLOAT -f 434000 -s 48000

2
testchirp.sh 100755
Wyświetl plik

@ -0,0 +1,2 @@
sudo ./pichirp 433.95e6 100000 5

Wyświetl plik

@ -1,3 +0,0 @@
./pifm sampleaudio.wav fm.ft
sudo ./rpitx -m RF -i fm.ft -f 433900 -l

1
testfmrds.sh 100755
Wyświetl plik

@ -0,0 +1 @@
sudo ./pifmrds -freq 434 -audio src/pifmrds/stereo_44100.wav

2
testfreedv.sh 100755
Wyświetl plik

@ -0,0 +1,2 @@
sudo ./freedv src/freedv/VCO800XA.rf 434e6 400

Wyświetl plik

@ -1,2 +1 @@
./pifsq Test testfsq.ft
sudo ./rpitx -m RF -i testfsq.ft -f 7050 -l
sudo ./pifsq "Test" 434e6

6
testnfm.sh 100755
Wyświetl plik

@ -0,0 +1,6 @@
#This is only a Narraw Band FM modulator, for FM broadcast modulation , use PiFMRDS
# Need to use a direct FM modulation with librpitx and not using IQ : TODO
echo "If you need to test broadcast FM , use PiFMRDS"
#(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f | csdr gain_ff 2500 | sudo ./sendiq -i /dev/stdin -s 24000 -f 434e6 -t float 1
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f | csdr gain_ff 7000 | csdr convert_f_samplerf 20833 | sudo ./rpitx -i- -m RF -f 434000

3
testopera.sh 100755
Wyświetl plik

@ -0,0 +1,3 @@
sudo ./piopera F5OEO 0.5 434e6

1
testpocsag.sh 100755
Wyświetl plik

@ -0,0 +1 @@
echo -e "1:YOURCALL\n2: Hello world" | sudo ./pocsag -f 434.e6

2
testspectrum.sh 100755
Wyświetl plik

@ -0,0 +1,2 @@
convert BBC.jpg -flip -quantize YUV -dither FloydSteinberg -colors 4 -interlace partition picture.yuv
sudo ./spectrumpaint picture.Y 434.0e6 100000

Wyświetl plik

@ -1,3 +1,2 @@
./pissb ./sampleaudio.wav ./ssbIQ.wav
sudo ./rpitx -m IQ -i ./ssbIQ.wav -f 433900 -l
(while true; do cat sampleaudio.wav; done) | csdr convert_i16_f | csdr fir_interpolate_cc 2| csdr dsb_fc | csdr bandpass_fir_fft_cc 0.002 0.06 0.01 | csdr fastagc_ff | sudo ./sendiq -i /dev/stdin -s 96000 -f 434.0e6 -t float

2
testsstv.sh 100755
Wyświetl plik

@ -0,0 +1,2 @@
convert -depth 8 BBC.jpg picture.rgb
sudo ./pisstv picture.rgb 434e6

Wyświetl plik

@ -1 +1 @@
sudo ./rpitx -m VFO -f 433900
sudo tune -f 434.0e6

4
transponder.sh 100755
Wyświetl plik

@ -0,0 +1,4 @@
#You need a rtl-sdr dongle in order to run this
echo "transponder FreqIn(Mhz) Gain(0-45)"
rtl_sdr -s 250000 -g "$2" -f "$1" - | buffer | sudo ./sendiq -s 250000 -f 434.0e6 -t u8 -i -