pastebin - collaborative debugging tool
eckelmann.kpaste.net RSS

Difference between
modified post 96c3 by Anonymous on Fri 13th Dec 2019 14:57
original post 226d8e2 by Anonymous on Fri 13th Dec 2019 14:55
Download diff
Show old version | new version | both versions

    
11
/*
22
 * qaweep1.c - Quantron beeper-weeper demo V0.0.1
33
 *
44
 * Written by Roland Mainz <r.mainz@eckelmann.de>
55
 */
66
77
/*
88
 * Compile with
99
 * $ /opt/OSELAS.Toolchain-2012.12.0/arm-v5te-linux-gnueabi/gcc-4.7.2-glibc-2.16.0-binutils-2.22-kernel-3.6-sanitized/bin/arm-v5te-linux-gnueabi-gcc -std=gnu99 -g -Wall -fno-use-linker-plugin qaweep1.c
1010
 */
1111
#include <errno.h>
1212
#include <fcntl.h>
1313
#include <stdio.h>
1414
#include <stdlib.h>
1515
#include <sys/stat.h>
1616
#include <sys/types.h>
1717
#include <unistd.h>
1818
1919
#define NUM_ELEMENTS_IN_ARRAY(ar) (sizeof(ar) / sizeof (ar[0]))
2020
const double freqs[] = {
2121
	440.0000,
2222
	466.1638,
2323
	493.8833,
2424
	523.2511,
2525
	554.3653,
2626
	587.3295,
2727
	622.2540,
2828
	659.2551,
2929
	698.4565,
3030
	739.9888,
3131
	783.9909,
3232
	830.6094,
3333
	880.0000,
3434
	932.3275,
3535
	987.7666,
3636
	1046.502,
3737
	1108.731,
3838
	1174.659,
3939
	1244.508
4040
};
4141
4242
#define MICROSECONDS_PER_SEC (1000000L)
4343
4444
static
4545
int cycle_loop(int fd, long cycles, long low_delay, long high_delay)
4646
{
47-
	int retval = 0;
4847
	int i;
4948
5049
	for (i = 0; i < cycles; i++) {
51-
		if (write(fd, "1", 1) != 1) {
50+
		if (write(fd, "1", 1) != 1)
52-
			goto exit_ioerr;
51+
			return 0;
5452
5553
		(void)usleep(low_delay);
5654
57-
		if (write(fd, "0", 1) != 1) {
55+
		if (write(fd, "0", 1) != 1)
58-
			goto exit_ioerr;
56+
			return 0;
6057
6158
		(void)usleep(high_delay);
6259
	}
6360
64-
	retval = 1;
61+
	return 1;
62+
}
6663
64+
int main(int ac, char *av[])

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at