<commit_before>/*
   This demo reads information about a comedi device and
   displays the information in a human-readable form.
 */

#include <stdio.h>
#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "examples.h"

void get_command_stuff(comedi_t *it,int s);

void help(void)
{
	fprintf(stderr,"info </dev/comediN>\n");
	exit(0);
}

char *tobinary(char *s,int bits,int n);

char *subdevice_types[]={
	"unused",
	"analog input",
	"analog output",
	"digital input",
	"digital output",
	"digital I/O",
	"counter",
	"timer",
	"memory",
	"calibration",
	"processor",
	"serial digital I/O"
};

comedi_t *it;
extern char *filename;


int main(int argc,char *argv[])
{
	int i,j;
	int n_subdevices,type;
	int chan,n_chans;
	int n_ranges;
	int subdev_flags;
	comedi_range *rng;
	struct parsed_options options;

	init_parsed_options(&options);
	parse_options(&options, argc, argv);

	it = comedi_open(options.filename);
	if(!it){
		comedi_perror(options.filename);
		exit(1);
	}

	printf("overall info:\n");
	printf("  version code: 0x%06x\n", comedi_get_version_code(it));
	printf("  driver name: %s\n", comedi_get_driver_name(it));
	printf("  board name: %s\n", comedi_get_board_name(it));
	printf("  number of subdevices: %d\n", n_subdevices = comedi_get_n_subdevices(it));

	for(i = 0; i < n_subdevices; i++){
		printf("subdevice %d:\n",i);
		type = comedi_get_subdevice_type(it, i);
		printf("  type: %d (%s)\n",type,subdevice_types[type]);
		if(type==COMEDI_SUBD_UNUSED)
			continue;
		subdev_flags = comedi_get_subdevice_flags(it, i);
		printf("  flags: 0x%08x\n",subdev_flags);
		n_chans=comedi_get_n_channels(it,i);
		printf("  number of channels: %d\n",n_chans);
		if(!comedi_maxdata_is_chan_specific(it,i)){
			printf("  max data value: %d\n",comedi_get_maxdata(it,i,0));
		}else{
			printf("  max data value: (channel specific)\n");
			for(chan=0;chan<n_chans;chan++){
				printf("    chan%d: %d\n",chan,
					comedi_get_maxdata(it,i,chan));
			}
		}
		printf("  ranges:\n");
		if(!comedi_range_is_chan_specific(it,i)){
			n_ranges=comedi_get_n_ranges(it,i,0);
			printf("    all chans:");
			for(j=0;j<n_ranges;j++){<commit_msg>print max data value as unsigned value instead of signed, so 32 bit counters show proper max value (instead of -1).<commit_after>/*
   This demo reads information about a comedi device and
   displays the information in a human-readable form.
 */

#include <stdio.h>
#include <comedilib.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include "examples.h"

void get_command_stuff(comedi_t *it,int s);

void help(void)
{
	fprintf(stderr,"info </dev/comediN>\n");
	exit(0);
}

char *tobinary(char *s,int bits,int n);

char *subdevice_types[]={
	"unused",
	"analog input",
	"analog output",
	"digital input",
	"digital output",
	"digital I/O",
	"counter",
	"timer",
	"memory",
	"calibration",
	"processor",
	"serial digital I/O"
};

comedi_t *it;
extern char *filename;


int main(int argc,char *argv[])
{
	int i,j;
	int n_subdevices,type;
	int chan,n_chans;
	int n_ranges;
	int subdev_flags;
	comedi_range *rng;
	struct parsed_options options;

	init_parsed_options(&options);
	parse_options(&options, argc, argv);

	it = comedi_open(options.filename);
	if(!it){
		comedi_perror(options.filename);
		exit(1);
	}

	printf("overall info:\n");
	printf("  version code: 0x%06x\n", comedi_get_version_code(it));
	printf("  driver name: %s\n", comedi_get_driver_name(it));
	printf("  board name: %s\n", comedi_get_board_name(it));
	printf("  number of subdevices: %d\n", n_subdevices = comedi_get_n_subdevices(it));

	for(i = 0; i < n_subdevices; i++){
		printf("subdevice %d:\n",i);
		type = comedi_get_subdevice_type(it, i);
		printf("  type: %d (%s)\n",type,subdevice_types[type]);
		if(type==COMEDI_SUBD_UNUSED)
			continue;
		subdev_flags = comedi_get_subdevice_flags(it, i);
		printf("  flags: 0x%08x\n",subdev_flags);
		n_chans=comedi_get_n_channels(it,i);
		printf("  number of channels: %d\n",n_chans);
		if(!comedi_maxdata_is_chan_specific(it,i)){
			printf("  max data value: %lu\n", (unsigned long)comedi_get_maxdata(it,i,0));
		}else{
			printf("  max data value: (channel specific)\n");
			for(chan=0;chan<n_chans;chan++){
				printf("    chan%d: %lu\n",chan,
					(unsigned long)comedi_get_maxdata(it,i,chan));
			}
		}
		printf("  ranges:\n");
		if(!comedi_range_is_chan_specific(it,i)){
			n_ranges=comedi_get_n_ranges(it,i,0);
			printf("    all chans:");
			for(j=0;j<n_ranges;j++){
{'fraction_non_alphanumeric': 0.16823864882649703, 'fraction_numerical': 0.006361044088615924, 'mean_word_length': 5.212534059945504, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3541096', 'n_tokens_mistral': 1953, 'n_tokens_neox': 1846, 'n_words': 380}