<commit_before>/*******************************************************************************
 *
 * Filename: ps2000Con.c
 *
 * Description:
 *   This is a console-mode program that demonstrates how to use the
 *   PicoScope 2000 Series (ps2000) driver API functions.
 *   
 *	Supported PicoScope models:
 *
 *		PicoScope 2104 & 2105 
 *		PicoScope 2202 & 2203 
 *		PicoScope 2204 & 2204A 
 *		PicoScope 2205 & 2205A
 *
 * Examples:
 *    Collect a block of samples immediately
 *    Collect a block of samples when a trigger event occurs
 *    Collect a block of samples using an advanced trigger
 *			- PicoScope 2202, 2204, 2205, 2204A and 2205A only
 *    Collect a block using ETS
 *			PicoScope 2104, 2105, 2203, 2204, 2204A , 2205 &
 *			2205A
 *    Collect a stream of data
 *    Collect a stream of data using an advanced trigger
 *			- PicoScope 2202, 2204, 2204A, 2205, and 2205A only
 *	  Collect a stream of data using an advanced trigger copying
 *	  the data from the callback
 *			- PicoScope 2202, 2204, 2204A, 2205 and 2205A only
 *    Set the signal generator with the built in signals 
 *			- PicoScope 2203, 2204, 2204A, 2205 and 2205A only
 *	  Set the signal generator with the arbitrary signal 
 *			- PicoScope 2203, 2204, 2204A, 2205 and 2205A only
 *	
 * To build this application:-
 *
 *	Windows platforms:
 *
 *		If Microsoft Visual Studio (including Express editions) is being used:
 *
 *			Select the solution configuration (Debug/Release) and platform (x86/x64)
 *			Ensure that the 32-/64-bit ps2000.lib can be located
 *			Ensure that the ps2000.h file can be located
 *		
 *		Otherwise:
 *
 *			Set up a project for a 32-/64-bit console mode application
 *			Add this file to the project
 *			Add ps2000.lib to the project (Microsoft C only)
 *			Build the project 
 *
 *  Linux platforms:
 *
 *		Ensure that the libps2000 driver package has been installed using the
 *		instructions from https://www.picotech.com/downloads/linux
 *
 *		Place this file in the same folder as the files from the linux-build-files
 *		folder. In a terminal window, use the following commands to build 
 *		the ps2000Con application:
 *
 *			./autogen.sh <ENTER>
 *			make <ENTER>
 *
 * Copyright (C) 2006-2018 Pico Technology Ltd. See LICENSE file for terms.
 *
 ******************************************************************************/

#include <stdio.h>

#ifdef WIN32
#include "windows.h"
#include <conio.h>
#include "ps2000.h"
#define PREF4 _stdcall
#else
#include <sys/types.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include "libps2000-2.1/ps2000.h"
#define PREF4

#define Sleep(a) usleep(1000*a)
#define scanf_s scanf
#define fscanf_s fscanf
#define memcpy_s(a,b,c,d) memcpy(a,c,d)
typedef uint8_t BYTE;
typedef enum enBOOL
{
	FALSE, TRUE
} BOOL;
/* A function to detect a keyboard press on Linux */
int32_t _getch()
{
	struct termios oldt, newt;
	int32_t ch;
	int32_t bytesWaiting;
	tcgetattr(STDIN_FILENO, &oldt);
	newt = oldt;
	newt.c_lflag &= ~(ICANON | ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &newt);
	setbuf(stdin, NULL);
	do
	{
		ioctl(STDIN_FILENO, FIONREAD, &bytesWaiting);
		if (bytesWaiting)
			getchar();
	} while (bytesWaiting);

	ch = getchar();

	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
	return ch;
}

int32_t _kbhit()
{
	struct termios oldt, newt;
	int32_t bytesWaiting;
	tcgetattr(STDIN_FILENO, &oldt);
	newt = oldt;
	newt.c_lflag &= ~(ICANON | ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &newt);
	setbuf(stdin, NULL);
	ioctl(STDIN_FILENO, FIONREAD, &bytesWaiting);

	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
	return bytesWaiting;
}

int32_t fopen_s(FILE ** a, const char * b, const char * c)
{
	FILE * fp = fopen(b, c);
	*a = fp;
	return (fp > 0) ? 0 : -1;
}

/* A function to get a single character on Linux */
#define max(a,b) ((a) > (b) ? a : b)
#define min(a,b) ((a) < (b) ? a : b)
#endif

#define BUFFER_SIZE 	1024
#define BUFFER_SIZE_STREAMING 50000		// Overview buffer size
#define NUM_STREAMING_SAMPLES 100000000	// Number of streaming samples to collect
#define MAX_CHANNELS 4
#define SINGLE_CH_SCOPE 1 // Single channel scope
#define DUAL_SCOPE 2      // Dual channel scope

// AWG Parameters - 2203, 2204, 2204A, 2205 & 2205A

#define AWG_MAX_BUFFER_SIZE		4096
#define	AWG_DAC_FREQUENCY		2e6
#define AWG_DDS_FREQUENCY		48e6
#define	AWG_PHASE_ACCUMULATOR	4294967296.0

/*******************************************************
* Data types changed:
*
* int8_t   - int8_t<commit_msg>Update number of streaming samples<commit_after>/*******************************************************************************
 *
 * Filename: ps2000Con.c
 *
 * Description:
 *   This is a console-mode program that demonstrates how to use the
 *   PicoScope 2000 Series (ps2000) driver API functions.
 *   
 *	Supported PicoScope models:
 *
 *		PicoScope 2104 & 2105 
 *		PicoScope 2202 & 2203 
 *		PicoScope 2204 & 2204A 
 *		PicoScope 2205 & 2205A
 *
 * Examples:
 *    Collect a block of samples immediately
 *    Collect a block of samples when a trigger event occurs
 *    Collect a block of samples using an advanced trigger
 *			- PicoScope 2202, 2204, 2205, 2204A and 2205A only
 *    Collect a block using ETS
 *			PicoScope 2104, 2105, 2203, 2204, 2204A , 2205 &
 *			2205A
 *    Collect a stream of data
 *    Collect a stream of data using an advanced trigger
 *			- PicoScope 2202, 2204, 2204A, 2205, and 2205A only
 *	  Collect a stream of data using an advanced trigger copying
 *	  the data from the callback
 *			- PicoScope 2202, 2204, 2204A, 2205 and 2205A only
 *    Set the signal generator with the built in signals 
 *			- PicoScope 2203, 2204, 2204A, 2205 and 2205A only
 *	  Set the signal generator with the arbitrary signal 
 *			- PicoScope 2203, 2204, 2204A, 2205 and 2205A only
 *	
 * To build this application:-
 *
 *	Windows platforms:
 *
 *		If Microsoft Visual Studio (including Express editions) is being used:
 *
 *			Select the solution configuration (Debug/Release) and platform (x86/x64)
 *			Ensure that the 32-/64-bit ps2000.lib can be located
 *			Ensure that the ps2000.h file can be located
 *		
 *		Otherwise:
 *
 *			Set up a project for a 32-/64-bit console mode application
 *			Add this file to the project
 *			Add ps2000.lib to the project (Microsoft C only)
 *			Build the project 
 *
 *  Linux platforms:
 *
 *		Ensure that the libps2000 driver package has been installed using the
 *		instructions from https://www.picotech.com/downloads/linux
 *
 *		Place this file in the same folder as the files from the linux-build-files
 *		folder. In a terminal window, use the following commands to build 
 *		the ps2000Con application:
 *
 *			./autogen.sh <ENTER>
 *			make <ENTER>
 *
 * Copyright (C) 2006-2018 Pico Technology Ltd. See LICENSE file for terms.
 *
 ******************************************************************************/

#include <stdio.h>

#ifdef WIN32
#include "windows.h"
#include <conio.h>
#include "ps2000.h"
#define PREF4 _stdcall
#else
#include <sys/types.h>
#include <string.h>
#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include "libps2000-2.1/ps2000.h"
#define PREF4

#define Sleep(a) usleep(1000*a)
#define scanf_s scanf
#define fscanf_s fscanf
#define memcpy_s(a,b,c,d) memcpy(a,c,d)
typedef uint8_t BYTE;
typedef enum enBOOL
{
	FALSE, TRUE
} BOOL;
/* A function to detect a keyboard press on Linux */
int32_t _getch()
{
	struct termios oldt, newt;
	int32_t ch;
	int32_t bytesWaiting;
	tcgetattr(STDIN_FILENO, &oldt);
	newt = oldt;
	newt.c_lflag &= ~(ICANON | ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &newt);
	setbuf(stdin, NULL);
	do
	{
		ioctl(STDIN_FILENO, FIONREAD, &bytesWaiting);
		if (bytesWaiting)
			getchar();
	} while (bytesWaiting);

	ch = getchar();

	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
	return ch;
}

int32_t _kbhit()
{
	struct termios oldt, newt;
	int32_t bytesWaiting;
	tcgetattr(STDIN_FILENO, &oldt);
	newt = oldt;
	newt.c_lflag &= ~(ICANON | ECHO);
	tcsetattr(STDIN_FILENO, TCSANOW, &newt);
	setbuf(stdin, NULL);
	ioctl(STDIN_FILENO, FIONREAD, &bytesWaiting);

	tcsetattr(STDIN_FILENO, TCSANOW, &oldt);
	return bytesWaiting;
}

int32_t fopen_s(FILE ** a, const char * b, const char * c)
{
	FILE * fp = fopen(b, c);
	*a = fp;
	return (fp > 0) ? 0 : -1;
}

/* A function to get a single character on Linux */
#define max(a,b) ((a) > (b) ? a : b)
#define min(a,b) ((a) < (b) ? a : b)
#endif

#define BUFFER_SIZE 	1024
#define BUFFER_SIZE_STREAMING 50000		// Overview buffer size
#define NUM_STREAMING_SAMPLES 10000000	// Number of streaming samples to collect
#define MAX_CHANNELS 4
#define SINGLE_CH_SCOPE 1 // Single channel scope
#define DUAL_SCOPE 2      // Dual channel scope

// AWG Parameters - 2203, 2204, 2204A, 2205 & 2205A

#define AWG_MAX_BUFFER_SIZE		4096
#define	AWG_DAC_FREQUENCY		2e6
#define AWG_DDS_FREQUENCY		48e6
#define	AWG_PHASE_ACCUMULATOR	4294967296.0

/*******************************************************
* Data types changed:
*
* int8_t   - int8_t
{'fraction_non_alphanumeric': 0.14304606568216882, 'fraction_numerical': 0.06887811329072074, 'mean_word_length': 3.8816568047337277, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '333399', 'n_tokens_mistral': 3862, 'n_tokens_neox': 3280, 'n_words': 1033}