init
uhd tool to send gmsk/8psk bursts while synchronously toggling the first gpio pin of a b2xx. sends one burst per second. example usage: cd burst-sender mkdir build cd build cmake .. make -j cd .. build/burstelchen -burstpath ./gmsk_tsc0/ -extref -txgain 50 requires uhd to build.
This commit is contained in:
commit
ff872c64ae
|
@ -0,0 +1,521 @@
|
|||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# clang-format configuration file. Intended for clang-format >= 4.
|
||||
#
|
||||
# For more information, see:
|
||||
#
|
||||
# Documentation/process/clang-format.rst
|
||||
# https://clang.llvm.org/docs/ClangFormat.html
|
||||
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
#
|
||||
---
|
||||
AccessModifierOffset: -4
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignConsecutiveAssignments: false
|
||||
AlignConsecutiveDeclarations: false
|
||||
#AlignEscapedNewlines: Left # Unknown to clang-format-4.0
|
||||
AlignOperands: true
|
||||
AlignTrailingComments: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortCaseLabelsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: false
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AlwaysBreakAfterDefinitionReturnType: None
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
AlwaysBreakTemplateDeclarations: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: true
|
||||
BraceWrapping:
|
||||
AfterClass: false
|
||||
AfterControlStatement: false
|
||||
AfterEnum: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: true
|
||||
AfterObjCDeclaration: false
|
||||
AfterStruct: false
|
||||
AfterUnion: false
|
||||
#AfterExternBlock: false # Unknown to clang-format-5.0
|
||||
BeforeCatch: false
|
||||
BeforeElse: false
|
||||
IndentBraces: false
|
||||
#SplitEmptyFunction: true # Unknown to clang-format-4.0
|
||||
#SplitEmptyRecord: true # Unknown to clang-format-4.0
|
||||
#SplitEmptyNamespace: true # Unknown to clang-format-4.0
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Custom
|
||||
#BreakBeforeInheritanceComma: false # Unknown to clang-format-4.0
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakConstructorInitializersBeforeComma: false
|
||||
#BreakConstructorInitializers: BeforeComma # Unknown to clang-format-4.0
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakStringLiterals: false
|
||||
ColumnLimit: 120
|
||||
CommentPragmas: '^ IWYU pragma:'
|
||||
#CompactNamespaces: false # Unknown to clang-format-4.0
|
||||
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||
ConstructorInitializerIndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
Cpp11BracedListStyle: false
|
||||
DerivePointerAlignment: false
|
||||
DisableFormat: false
|
||||
ExperimentalAutoDetectBinPacking: false
|
||||
#FixNamespaceComments: false # Unknown to clang-format-4.0
|
||||
|
||||
# Taken from:
|
||||
# git grep -h '^#define [^[:space:]]*for_each[^[:space:]]*(' include/ \
|
||||
# | sed "s,^#define \([^[:space:]]*for_each[^[:space:]]*\)(.*$, - '\1'," \
|
||||
# | sort | uniq
|
||||
ForEachMacros:
|
||||
- 'apei_estatus_for_each_section'
|
||||
- 'ata_for_each_dev'
|
||||
- 'ata_for_each_link'
|
||||
- '__ata_qc_for_each'
|
||||
- 'ata_qc_for_each'
|
||||
- 'ata_qc_for_each_raw'
|
||||
- 'ata_qc_for_each_with_internal'
|
||||
- 'ax25_for_each'
|
||||
- 'ax25_uid_for_each'
|
||||
- '__bio_for_each_bvec'
|
||||
- 'bio_for_each_bvec'
|
||||
- 'bio_for_each_integrity_vec'
|
||||
- '__bio_for_each_segment'
|
||||
- 'bio_for_each_segment'
|
||||
- 'bio_for_each_segment_all'
|
||||
- 'bio_list_for_each'
|
||||
- 'bip_for_each_vec'
|
||||
- 'bitmap_for_each_clear_region'
|
||||
- 'bitmap_for_each_set_region'
|
||||
- 'blkg_for_each_descendant_post'
|
||||
- 'blkg_for_each_descendant_pre'
|
||||
- 'blk_queue_for_each_rl'
|
||||
- 'bond_for_each_slave'
|
||||
- 'bond_for_each_slave_rcu'
|
||||
- 'bpf_for_each_spilled_reg'
|
||||
- 'btree_for_each_safe128'
|
||||
- 'btree_for_each_safe32'
|
||||
- 'btree_for_each_safe64'
|
||||
- 'btree_for_each_safel'
|
||||
- 'card_for_each_dev'
|
||||
- 'cgroup_taskset_for_each'
|
||||
- 'cgroup_taskset_for_each_leader'
|
||||
- 'cpufreq_for_each_entry'
|
||||
- 'cpufreq_for_each_entry_idx'
|
||||
- 'cpufreq_for_each_valid_entry'
|
||||
- 'cpufreq_for_each_valid_entry_idx'
|
||||
- 'css_for_each_child'
|
||||
- 'css_for_each_descendant_post'
|
||||
- 'css_for_each_descendant_pre'
|
||||
- 'device_for_each_child_node'
|
||||
- 'dma_fence_chain_for_each'
|
||||
- 'drm_atomic_crtc_for_each_plane'
|
||||
- 'drm_atomic_crtc_state_for_each_plane'
|
||||
- 'drm_atomic_crtc_state_for_each_plane_state'
|
||||
- 'drm_atomic_for_each_plane_damage'
|
||||
- 'drm_client_for_each_connector_iter'
|
||||
- 'drm_client_for_each_modeset'
|
||||
- 'drm_connector_for_each_possible_encoder'
|
||||
- 'drm_for_each_bridge_in_chain'
|
||||
- 'drm_for_each_connector_iter'
|
||||
- 'drm_for_each_crtc'
|
||||
- 'drm_for_each_encoder'
|
||||
- 'drm_for_each_encoder_mask'
|
||||
- 'drm_for_each_fb'
|
||||
- 'drm_for_each_legacy_plane'
|
||||
- 'drm_for_each_plane'
|
||||
- 'drm_for_each_plane_mask'
|
||||
- 'drm_for_each_privobj'
|
||||
- 'drm_mm_for_each_hole'
|
||||
- 'drm_mm_for_each_node'
|
||||
- 'drm_mm_for_each_node_in_range'
|
||||
- 'drm_mm_for_each_node_safe'
|
||||
- 'flow_action_for_each'
|
||||
- 'for_each_active_dev_scope'
|
||||
- 'for_each_active_drhd_unit'
|
||||
- 'for_each_active_iommu'
|
||||
- 'for_each_available_child_of_node'
|
||||
- 'for_each_bio'
|
||||
- 'for_each_board_func_rsrc'
|
||||
- 'for_each_bvec'
|
||||
- 'for_each_card_auxs'
|
||||
- 'for_each_card_auxs_safe'
|
||||
- 'for_each_card_components'
|
||||
- 'for_each_card_pre_auxs'
|
||||
- 'for_each_card_prelinks'
|
||||
- 'for_each_card_rtds'
|
||||
- 'for_each_card_rtds_safe'
|
||||
- 'for_each_cgroup_storage_type'
|
||||
- 'for_each_child_of_node'
|
||||
- 'for_each_clear_bit'
|
||||
- 'for_each_clear_bit_from'
|
||||
- 'for_each_cmsghdr'
|
||||
- 'for_each_compatible_node'
|
||||
- 'for_each_component_dais'
|
||||
- 'for_each_component_dais_safe'
|
||||
- 'for_each_comp_order'
|
||||
- 'for_each_console'
|
||||
- 'for_each_cpu'
|
||||
- 'for_each_cpu_and'
|
||||
- 'for_each_cpu_not'
|
||||
- 'for_each_cpu_wrap'
|
||||
- 'for_each_dev_addr'
|
||||
- 'for_each_dev_scope'
|
||||
- 'for_each_displayid_db'
|
||||
- 'for_each_dma_cap_mask'
|
||||
- 'for_each_dpcm_be'
|
||||
- 'for_each_dpcm_be_rollback'
|
||||
- 'for_each_dpcm_be_safe'
|
||||
- 'for_each_dpcm_fe'
|
||||
- 'for_each_drhd_unit'
|
||||
- 'for_each_dss_dev'
|
||||
- 'for_each_efi_handle'
|
||||
- 'for_each_efi_memory_desc'
|
||||
- 'for_each_efi_memory_desc_in_map'
|
||||
- 'for_each_element'
|
||||
- 'for_each_element_extid'
|
||||
- 'for_each_element_id'
|
||||
- 'for_each_endpoint_of_node'
|
||||
- 'for_each_evictable_lru'
|
||||
- 'for_each_fib6_node_rt_rcu'
|
||||
- 'for_each_fib6_walker_rt'
|
||||
- 'for_each_free_mem_pfn_range_in_zone'
|
||||
- 'for_each_free_mem_pfn_range_in_zone_from'
|
||||
- 'for_each_free_mem_range'
|
||||
- 'for_each_free_mem_range_reverse'
|
||||
- 'for_each_func_rsrc'
|
||||
- 'for_each_hstate'
|
||||
- 'for_each_if'
|
||||
- 'for_each_iommu'
|
||||
- 'for_each_ip_tunnel_rcu'
|
||||
- 'for_each_irq_nr'
|
||||
- 'for_each_link_codecs'
|
||||
- 'for_each_link_platforms'
|
||||
- 'for_each_lru'
|
||||
- 'for_each_matching_node'
|
||||
- 'for_each_matching_node_and_match'
|
||||
- 'for_each_member'
|
||||
- 'for_each_memblock'
|
||||
- 'for_each_memblock_type'
|
||||
- 'for_each_memcg_cache_index'
|
||||
- 'for_each_mem_pfn_range'
|
||||
- 'for_each_mem_range'
|
||||
- 'for_each_mem_range_rev'
|
||||
- 'for_each_migratetype_order'
|
||||
- 'for_each_msi_entry'
|
||||
- 'for_each_msi_entry_safe'
|
||||
- 'for_each_net'
|
||||
- 'for_each_net_continue_reverse'
|
||||
- 'for_each_netdev'
|
||||
- 'for_each_netdev_continue'
|
||||
- 'for_each_netdev_continue_rcu'
|
||||
- 'for_each_netdev_continue_reverse'
|
||||
- 'for_each_netdev_feature'
|
||||
- 'for_each_netdev_in_bond_rcu'
|
||||
- 'for_each_netdev_rcu'
|
||||
- 'for_each_netdev_reverse'
|
||||
- 'for_each_netdev_safe'
|
||||
- 'for_each_net_rcu'
|
||||
- 'for_each_new_connector_in_state'
|
||||
- 'for_each_new_crtc_in_state'
|
||||
- 'for_each_new_mst_mgr_in_state'
|
||||
- 'for_each_new_plane_in_state'
|
||||
- 'for_each_new_private_obj_in_state'
|
||||
- 'for_each_node'
|
||||
- 'for_each_node_by_name'
|
||||
- 'for_each_node_by_type'
|
||||
- 'for_each_node_mask'
|
||||
- 'for_each_node_state'
|
||||
- 'for_each_node_with_cpus'
|
||||
- 'for_each_node_with_property'
|
||||
- 'for_each_of_allnodes'
|
||||
- 'for_each_of_allnodes_from'
|
||||
- 'for_each_of_cpu_node'
|
||||
- 'for_each_of_pci_range'
|
||||
- 'for_each_old_connector_in_state'
|
||||
- 'for_each_old_crtc_in_state'
|
||||
- 'for_each_old_mst_mgr_in_state'
|
||||
- 'for_each_oldnew_connector_in_state'
|
||||
- 'for_each_oldnew_crtc_in_state'
|
||||
- 'for_each_oldnew_mst_mgr_in_state'
|
||||
- 'for_each_oldnew_plane_in_state'
|
||||
- 'for_each_oldnew_plane_in_state_reverse'
|
||||
- 'for_each_oldnew_private_obj_in_state'
|
||||
- 'for_each_old_plane_in_state'
|
||||
- 'for_each_old_private_obj_in_state'
|
||||
- 'for_each_online_cpu'
|
||||
- 'for_each_online_node'
|
||||
- 'for_each_online_pgdat'
|
||||
- 'for_each_pci_bridge'
|
||||
- 'for_each_pci_dev'
|
||||
- 'for_each_pci_msi_entry'
|
||||
- 'for_each_populated_zone'
|
||||
- 'for_each_possible_cpu'
|
||||
- 'for_each_present_cpu'
|
||||
- 'for_each_prime_number'
|
||||
- 'for_each_prime_number_from'
|
||||
- 'for_each_process'
|
||||
- 'for_each_process_thread'
|
||||
- 'for_each_property_of_node'
|
||||
- 'for_each_registered_fb'
|
||||
- 'for_each_reserved_mem_region'
|
||||
- 'for_each_rtd_codec_dai'
|
||||
- 'for_each_rtd_codec_dai_rollback'
|
||||
- 'for_each_rtd_components'
|
||||
- 'for_each_set_bit'
|
||||
- 'for_each_set_bit_from'
|
||||
- 'for_each_set_clump8'
|
||||
- 'for_each_sg'
|
||||
- 'for_each_sg_dma_page'
|
||||
- 'for_each_sg_page'
|
||||
- 'for_each_sibling_event'
|
||||
- 'for_each_subelement'
|
||||
- 'for_each_subelement_extid'
|
||||
- 'for_each_subelement_id'
|
||||
- '__for_each_thread'
|
||||
- 'for_each_thread'
|
||||
- 'for_each_wakeup_source'
|
||||
- 'for_each_zone'
|
||||
- 'for_each_zone_zonelist'
|
||||
- 'for_each_zone_zonelist_nodemask'
|
||||
- 'fwnode_for_each_available_child_node'
|
||||
- 'fwnode_for_each_child_node'
|
||||
- 'fwnode_graph_for_each_endpoint'
|
||||
- 'gadget_for_each_ep'
|
||||
- 'genradix_for_each'
|
||||
- 'genradix_for_each_from'
|
||||
- 'hash_for_each'
|
||||
- 'hash_for_each_possible'
|
||||
- 'hash_for_each_possible_rcu'
|
||||
- 'hash_for_each_possible_rcu_notrace'
|
||||
- 'hash_for_each_possible_safe'
|
||||
- 'hash_for_each_rcu'
|
||||
- 'hash_for_each_safe'
|
||||
- 'hctx_for_each_ctx'
|
||||
- 'hlist_bl_for_each_entry'
|
||||
- 'hlist_bl_for_each_entry_rcu'
|
||||
- 'hlist_bl_for_each_entry_safe'
|
||||
- 'hlist_for_each'
|
||||
- 'hlist_for_each_entry'
|
||||
- 'hlist_for_each_entry_continue'
|
||||
- 'hlist_for_each_entry_continue_rcu'
|
||||
- 'hlist_for_each_entry_continue_rcu_bh'
|
||||
- 'hlist_for_each_entry_from'
|
||||
- 'hlist_for_each_entry_from_rcu'
|
||||
- 'hlist_for_each_entry_rcu'
|
||||
- 'hlist_for_each_entry_rcu_bh'
|
||||
- 'hlist_for_each_entry_rcu_notrace'
|
||||
- 'hlist_for_each_entry_safe'
|
||||
- '__hlist_for_each_rcu'
|
||||
- 'hlist_for_each_safe'
|
||||
- 'hlist_nulls_for_each_entry'
|
||||
- 'hlist_nulls_for_each_entry_from'
|
||||
- 'hlist_nulls_for_each_entry_rcu'
|
||||
- 'hlist_nulls_for_each_entry_safe'
|
||||
- 'i3c_bus_for_each_i2cdev'
|
||||
- 'i3c_bus_for_each_i3cdev'
|
||||
- 'ide_host_for_each_port'
|
||||
- 'ide_port_for_each_dev'
|
||||
- 'ide_port_for_each_present_dev'
|
||||
- 'idr_for_each_entry'
|
||||
- 'idr_for_each_entry_continue'
|
||||
- 'idr_for_each_entry_continue_ul'
|
||||
- 'idr_for_each_entry_ul'
|
||||
- 'in_dev_for_each_ifa_rcu'
|
||||
- 'in_dev_for_each_ifa_rtnl'
|
||||
- 'inet_bind_bucket_for_each'
|
||||
- 'inet_lhash2_for_each_icsk_rcu'
|
||||
- 'key_for_each'
|
||||
- 'key_for_each_safe'
|
||||
- 'klp_for_each_func'
|
||||
- 'klp_for_each_func_safe'
|
||||
- 'klp_for_each_func_static'
|
||||
- 'klp_for_each_object'
|
||||
- 'klp_for_each_object_safe'
|
||||
- 'klp_for_each_object_static'
|
||||
- 'kvm_for_each_memslot'
|
||||
- 'kvm_for_each_vcpu'
|
||||
- 'list_for_each'
|
||||
- 'list_for_each_codec'
|
||||
- 'list_for_each_codec_safe'
|
||||
- 'list_for_each_continue'
|
||||
- 'list_for_each_entry'
|
||||
- 'list_for_each_entry_continue'
|
||||
- 'list_for_each_entry_continue_rcu'
|
||||
- 'list_for_each_entry_continue_reverse'
|
||||
- 'list_for_each_entry_from'
|
||||
- 'list_for_each_entry_from_rcu'
|
||||
- 'list_for_each_entry_from_reverse'
|
||||
- 'list_for_each_entry_lockless'
|
||||
- 'list_for_each_entry_rcu'
|
||||
- 'list_for_each_entry_reverse'
|
||||
- 'list_for_each_entry_safe'
|
||||
- 'list_for_each_entry_safe_continue'
|
||||
- 'list_for_each_entry_safe_from'
|
||||
- 'list_for_each_entry_safe_reverse'
|
||||
- 'list_for_each_prev'
|
||||
- 'list_for_each_prev_safe'
|
||||
- 'list_for_each_safe'
|
||||
- 'llist_for_each'
|
||||
- 'llist_for_each_entry'
|
||||
- 'llist_for_each_entry_safe'
|
||||
- 'llist_for_each_safe'
|
||||
- 'mci_for_each_dimm'
|
||||
- 'media_device_for_each_entity'
|
||||
- 'media_device_for_each_intf'
|
||||
- 'media_device_for_each_link'
|
||||
- 'media_device_for_each_pad'
|
||||
- 'nanddev_io_for_each_page'
|
||||
- 'netdev_for_each_lower_dev'
|
||||
- 'netdev_for_each_lower_private'
|
||||
- 'netdev_for_each_lower_private_rcu'
|
||||
- 'netdev_for_each_mc_addr'
|
||||
- 'netdev_for_each_uc_addr'
|
||||
- 'netdev_for_each_upper_dev_rcu'
|
||||
- 'netdev_hw_addr_list_for_each'
|
||||
- 'nft_rule_for_each_expr'
|
||||
- 'nla_for_each_attr'
|
||||
- 'nla_for_each_nested'
|
||||
- 'nlmsg_for_each_attr'
|
||||
- 'nlmsg_for_each_msg'
|
||||
- 'nr_neigh_for_each'
|
||||
- 'nr_neigh_for_each_safe'
|
||||
- 'nr_node_for_each'
|
||||
- 'nr_node_for_each_safe'
|
||||
- 'of_for_each_phandle'
|
||||
- 'of_property_for_each_string'
|
||||
- 'of_property_for_each_u32'
|
||||
- 'pci_bus_for_each_resource'
|
||||
- 'ping_portaddr_for_each_entry'
|
||||
- 'plist_for_each'
|
||||
- 'plist_for_each_continue'
|
||||
- 'plist_for_each_entry'
|
||||
- 'plist_for_each_entry_continue'
|
||||
- 'plist_for_each_entry_safe'
|
||||
- 'plist_for_each_safe'
|
||||
- 'pnp_for_each_card'
|
||||
- 'pnp_for_each_dev'
|
||||
- 'protocol_for_each_card'
|
||||
- 'protocol_for_each_dev'
|
||||
- 'queue_for_each_hw_ctx'
|
||||
- 'radix_tree_for_each_slot'
|
||||
- 'radix_tree_for_each_tagged'
|
||||
- 'rbtree_postorder_for_each_entry_safe'
|
||||
- 'rdma_for_each_block'
|
||||
- 'rdma_for_each_port'
|
||||
- 'resource_list_for_each_entry'
|
||||
- 'resource_list_for_each_entry_safe'
|
||||
- 'rhl_for_each_entry_rcu'
|
||||
- 'rhl_for_each_rcu'
|
||||
- 'rht_for_each'
|
||||
- 'rht_for_each_entry'
|
||||
- 'rht_for_each_entry_from'
|
||||
- 'rht_for_each_entry_rcu'
|
||||
- 'rht_for_each_entry_rcu_from'
|
||||
- 'rht_for_each_entry_safe'
|
||||
- 'rht_for_each_from'
|
||||
- 'rht_for_each_rcu'
|
||||
- 'rht_for_each_rcu_from'
|
||||
- '__rq_for_each_bio'
|
||||
- 'rq_for_each_bvec'
|
||||
- 'rq_for_each_segment'
|
||||
- 'scsi_for_each_prot_sg'
|
||||
- 'scsi_for_each_sg'
|
||||
- 'sctp_for_each_hentry'
|
||||
- 'sctp_skb_for_each'
|
||||
- 'shdma_for_each_chan'
|
||||
- '__shost_for_each_device'
|
||||
- 'shost_for_each_device'
|
||||
- 'sk_for_each'
|
||||
- 'sk_for_each_bound'
|
||||
- 'sk_for_each_entry_offset_rcu'
|
||||
- 'sk_for_each_from'
|
||||
- 'sk_for_each_rcu'
|
||||
- 'sk_for_each_safe'
|
||||
- 'sk_nulls_for_each'
|
||||
- 'sk_nulls_for_each_from'
|
||||
- 'sk_nulls_for_each_rcu'
|
||||
- 'snd_array_for_each'
|
||||
- 'snd_pcm_group_for_each_entry'
|
||||
- 'snd_soc_dapm_widget_for_each_path'
|
||||
- 'snd_soc_dapm_widget_for_each_path_safe'
|
||||
- 'snd_soc_dapm_widget_for_each_sink_path'
|
||||
- 'snd_soc_dapm_widget_for_each_source_path'
|
||||
- 'tb_property_for_each'
|
||||
- 'tcf_exts_for_each_action'
|
||||
- 'udp_portaddr_for_each_entry'
|
||||
- 'udp_portaddr_for_each_entry_rcu'
|
||||
- 'usb_hub_for_each_child'
|
||||
- 'v4l2_device_for_each_subdev'
|
||||
- 'v4l2_m2m_for_each_dst_buf'
|
||||
- 'v4l2_m2m_for_each_dst_buf_safe'
|
||||
- 'v4l2_m2m_for_each_src_buf'
|
||||
- 'v4l2_m2m_for_each_src_buf_safe'
|
||||
- 'virtio_device_for_each_vq'
|
||||
- 'xa_for_each'
|
||||
- 'xa_for_each_marked'
|
||||
- 'xa_for_each_range'
|
||||
- 'xa_for_each_start'
|
||||
- 'xas_for_each'
|
||||
- 'xas_for_each_conflict'
|
||||
- 'xas_for_each_marked'
|
||||
- 'xbc_array_for_each_value'
|
||||
- 'xbc_for_each_key_value'
|
||||
- 'xbc_node_for_each_array_value'
|
||||
- 'xbc_node_for_each_child'
|
||||
- 'xbc_node_for_each_key_value'
|
||||
- 'zorro_for_each_dev'
|
||||
|
||||
#IncludeBlocks: Preserve # Unknown to clang-format-5.0
|
||||
IncludeCategories:
|
||||
- Regex: '.*'
|
||||
Priority: 1
|
||||
IncludeIsMainRegex: '(Test)?$'
|
||||
IndentCaseLabels: false
|
||||
#IndentPPDirectives: None # Unknown to clang-format-5.0
|
||||
IndentWidth: 8
|
||||
IndentWrappedFunctionNames: false
|
||||
JavaScriptQuotes: Leave
|
||||
JavaScriptWrapImports: true
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
MacroBlockBegin: ''
|
||||
MacroBlockEnd: ''
|
||||
MaxEmptyLinesToKeep: 1
|
||||
NamespaceIndentation: Inner
|
||||
#ObjCBinPackProtocolList: Auto # Unknown to clang-format-5.0
|
||||
ObjCBlockIndentWidth: 8
|
||||
ObjCSpaceAfterProperty: true
|
||||
ObjCSpaceBeforeProtocolList: true
|
||||
|
||||
# Taken from git's rules
|
||||
#PenaltyBreakAssignment: 10 # Unknown to clang-format-4.0
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
|
||||
PointerAlignment: Right
|
||||
ReflowComments: false
|
||||
SortIncludes: false
|
||||
#SortUsingDeclarations: false # Unknown to clang-format-4.0
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
#SpaceBeforeCtorInitializerColon: true # Unknown to clang-format-5.0
|
||||
#SpaceBeforeInheritanceColon: true # Unknown to clang-format-5.0
|
||||
SpaceBeforeParens: ControlStatements
|
||||
#SpaceBeforeRangeBasedForLoopColon: true # Unknown to clang-format-5.0
|
||||
SpaceInEmptyParentheses: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: false
|
||||
SpacesInContainerLiterals: false
|
||||
SpacesInCStyleCastParentheses: false
|
||||
SpacesInParentheses: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Cpp11
|
||||
TabWidth: 8
|
||||
UseTab: Always
|
||||
...
|
|
@ -0,0 +1,15 @@
|
|||
Checks: "clang-diagnostic-*,clang-analyzer-*,llvm-*,modernize-*,cppcoreguidelines-*,-modernize-use-trailing-return-type,-cppcoreguidelines-owning-memory,-cppcoreguidelines-avoid-magic-numbers,-cppcoreguidelines-pro-bounds-array-to-pointer-decay,-bugprone-shared-ptr-array-mismatch,-cppcoreguidelines-avoid-non-const-global-variables,-cppcoreguidelines-avoid-c-arrays,-modernize-avoid-c-arrays"
|
||||
WarningsAsErrors: ""
|
||||
HeaderFilterRegex: ""
|
||||
AnalyzeTemporaryDtors: false
|
||||
CheckOptions:
|
||||
- key: cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted
|
||||
value: true
|
||||
- key: google-readability-braces-around-statements.ShortStatementLines
|
||||
value: "1"
|
||||
- key: modernize-loop-convert.MaxCopySize
|
||||
value: "16"
|
||||
- key: modernize-loop-convert.NamingStyle
|
||||
value: CamelCase
|
||||
- key: modernize-use-nullptr.NullMacros
|
||||
value: "NULL"
|
|
@ -0,0 +1 @@
|
|||
build
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,22 @@
|
|||
cmake_minimum_required(VERSION 3.0.0)
|
||||
project(burstelchen VERSION 0.1.0)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
|
||||
find_package(PkgConfig)
|
||||
pkg_search_module(uhd REQUIRED uhd)
|
||||
link_directories(${uhd_LIBRARY_DIRS})
|
||||
|
||||
add_compile_options(
|
||||
"-Wall" "-Wpedantic" "-Wextra" "-fexceptions"
|
||||
"$<$<CONFIG:DEBUG>:-O0;-g3;-ggdb;-fstandalone-debug;-fsanitize=address,undefined>"
|
||||
)
|
||||
|
||||
add_link_options("$<$<CONFIG:DEBUG>:-fsanitize=address,undefined>")
|
||||
|
||||
add_executable(burstelchen burstelchen.cpp)
|
||||
target_include_directories(burstelchen SYSTEM PUBLIC ${uhd_INCLUDE_DIRS})
|
||||
target_link_libraries(burstelchen ${uhd_LIBRARIES})
|
||||
|
||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||
include(CPack)
|
|
@ -0,0 +1,16 @@
|
|||
uhd tool to send gmsk/8psk bursts while synchronously toggling the first gpio pin of a b2xx.
|
||||
|
||||
sends one burst per second.
|
||||
|
||||
example usage:
|
||||
```shell
|
||||
cd burst-sender
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j
|
||||
cd ..
|
||||
build/burstelchen -burstpath ./gmsk_tsc0/ -extref -txgain 50
|
||||
```
|
||||
|
||||
requires uhd to build.
|
|
@ -0,0 +1,74 @@
|
|||
#pragma once
|
||||
/*
|
||||
* Copyright 2022 sysmocom - s.f.m.c. GmbH
|
||||
*
|
||||
* Author: Eric Wild <ewild@sysmocom.de>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0+
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#include <cstdint>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, bool *rv)
|
||||
{
|
||||
if (*itr == arg) {
|
||||
*rv = true;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename A, typename B, typename C>
|
||||
bool parsec(std::vector<std::string> &v, A &itr, std::string arg, B f, C *rv)
|
||||
{
|
||||
if (*itr == arg) {
|
||||
itr++;
|
||||
if (itr != v.end()) {
|
||||
*rv = f(itr->c_str());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, int64_t scale, int64_t *rv)
|
||||
{
|
||||
return parsec(
|
||||
v, itr, arg, [scale](const char *v) -> decltype(scale) { return atoll(v) * scale; }, rv);
|
||||
}
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, int scale, int *rv)
|
||||
{
|
||||
return parsec(
|
||||
v, itr, arg, [scale](const char *v) -> decltype(scale) { return atoi(v) * scale; }, rv);
|
||||
}
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, int scale, unsigned int *rv)
|
||||
{
|
||||
return parsec(
|
||||
v, itr, arg, [scale](const char *v) -> decltype(scale) { return atoi(v) * scale; }, rv);
|
||||
}
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, float scale, float *rv)
|
||||
{
|
||||
return parsec(
|
||||
v, itr, arg, [scale](const char *v) -> decltype(scale) { return decltype(scale)(atof(v) * scale); },
|
||||
rv);
|
||||
}
|
||||
template <typename A> bool parsec(std::vector<std::string> &v, A &itr, std::string arg, std::string *rv)
|
||||
{
|
||||
return parsec(
|
||||
v, itr, arg, [](const char *v) -> std::string { return { v }; }, rv);
|
||||
}
|
|
@ -0,0 +1,283 @@
|
|||
/*
|
||||
* Copyright 2022 sysmocom - s.f.m.c. GmbH
|
||||
*
|
||||
* Author: Eric Wild <ewild@sysmocom.de>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0+
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <complex>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
#include <uhd/types/time_spec.hpp>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <csignal>
|
||||
#include <dirent.h>
|
||||
|
||||
#include <uhd/stream.hpp>
|
||||
#include <uhd/types/metadata.hpp>
|
||||
#include <uhd/usrp/multi_usrp.hpp>
|
||||
#include <uhd/version.hpp>
|
||||
|
||||
#include "argvhelper.h"
|
||||
#include "filehelper.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
const auto txFullScale = int(32767 * 0.3); // scale like osmotrx
|
||||
const auto gsmrate = (1625e3 / 6) * 4;
|
||||
uhd::usrp::multi_usrp::sptr uhd_dev;
|
||||
uhd::tx_streamer::sptr tx_stream;
|
||||
uhd::rx_streamer::sptr rx_stream;
|
||||
double rxtickrate, txtickrate;
|
||||
int p_ts_begin_offset, p_ts_end_offset;
|
||||
|
||||
unsigned int p_txfreq(881000 * 1000);
|
||||
unsigned int p_txgain = 20;
|
||||
float p_bandwidth = 0.5e6;
|
||||
bool p_use_ext_ref = false;
|
||||
|
||||
static volatile bool g_exit_flag = false;
|
||||
|
||||
/* see https://kb.ettus.com/B200/B210/B200mini/B205mini#GPIO
|
||||
"..initial state for the front-panel GPIOs is high-Z.."
|
||||
no external pull-ups/pull-downs BUT FPGA config: pull-up!
|
||||
*/
|
||||
void gpio_setup()
|
||||
{
|
||||
auto gpio_bank = uhd_dev->get_gpio_banks(0).front();
|
||||
std::cout << "using gpio bank: " << gpio_bank << std::endl;
|
||||
std::cout << "available gpio banks: " << std::endl;
|
||||
auto banks = uhd_dev->get_gpio_banks(0);
|
||||
for (auto &bank : banks) {
|
||||
std::cout << bank << std::endl;
|
||||
}
|
||||
|
||||
// set all to manual
|
||||
uhd_dev->set_gpio_attr("FP0", "CTRL", 0x00, 0xff);
|
||||
uhd_dev->set_gpio_attr("FP0", "DDR", 0xff, 0xff);
|
||||
uhd_dev->set_gpio_attr("FP0", "OUT", 0, 0xff);
|
||||
}
|
||||
|
||||
void gpio_cmd(long long ts_begin, long long ts_end)
|
||||
{
|
||||
auto start = uhd::time_spec_t::from_ticks(ts_begin, txtickrate);
|
||||
auto end = uhd::time_spec_t::from_ticks(ts_end, txtickrate);
|
||||
|
||||
uhd_dev->set_command_time(start);
|
||||
uhd_dev->set_gpio_attr("FP0", "OUT", 1, 0xff);
|
||||
uhd_dev->set_command_time(end);
|
||||
uhd_dev->set_gpio_attr("FP0", "OUT", 0, 0xff);
|
||||
}
|
||||
|
||||
uhd::usrp::multi_usrp::sptr init_device()
|
||||
{
|
||||
auto const lock_delay_ms = 500;
|
||||
auto const mcr = 26e6;
|
||||
|
||||
auto const channel = 0;
|
||||
|
||||
// aligned to blade: 1020 samples per transfer
|
||||
// std::string args = { "recv_frame_size=4092,send_frame_size=4092" };
|
||||
uhd::tune_request_t tune_request(p_txfreq, 0);
|
||||
|
||||
try {
|
||||
uhd_dev = uhd::usrp::multi_usrp::make(std::string(""));
|
||||
} catch (const std::exception &e) {
|
||||
std::cerr << e.what();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
std::cout << "Using Device: " << uhd_dev->get_pp_string() << std::endl;
|
||||
|
||||
gpio_setup();
|
||||
|
||||
if (p_use_ext_ref) {
|
||||
std::cout << "using EXTERNAL clock reference.." << std::endl;
|
||||
uhd_dev->set_clock_source("external");
|
||||
} else {
|
||||
std::cout << "using internal clock reference.." << std::endl;
|
||||
uhd_dev->set_clock_source("internal");
|
||||
}
|
||||
|
||||
uhd_dev->set_master_clock_rate(mcr);
|
||||
|
||||
uhd_dev->set_tx_rate(gsmrate, channel);
|
||||
uhd_dev->set_tx_freq(tune_request, channel);
|
||||
uhd_dev->set_tx_gain(p_txgain, channel);
|
||||
uhd_dev->set_tx_bandwidth(p_bandwidth, channel);
|
||||
|
||||
uhd_dev->set_rx_rate(gsmrate, channel);
|
||||
uhd_dev->set_rx_freq(tune_request, channel);
|
||||
uhd_dev->set_rx_gain(30, channel);
|
||||
// uhd_dev->set_rx_bandwidth(bw, channel);
|
||||
|
||||
std::cerr << "waiting for internal/external clock source lock.." << std::endl;
|
||||
|
||||
auto is_ref_locked = []() {
|
||||
return (uhd_dev->get_rx_sensor("lo_locked", channel).to_bool() &&
|
||||
(p_use_ext_ref ? uhd_dev->get_mboard_sensor("ref_locked").to_bool() : 1));
|
||||
};
|
||||
|
||||
while (!is_ref_locked())
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(lock_delay_ms));
|
||||
std::cerr << "clock locked!" << std::endl;
|
||||
|
||||
uhd::stream_args_t stream_args("sc16", "sc16");
|
||||
rx_stream = uhd_dev->get_rx_stream(stream_args);
|
||||
uhd::stream_args_t stream_args2("sc16", "sc16");
|
||||
tx_stream = uhd_dev->get_tx_stream(stream_args2);
|
||||
|
||||
rxtickrate = uhd_dev->get_rx_rate();
|
||||
txtickrate = uhd_dev->get_tx_rate();
|
||||
assert(rxtickrate == txtickrate);
|
||||
|
||||
std::cerr << "RX samples per packet: " << rx_stream->get_max_num_samps() << std::endl;
|
||||
|
||||
return uhd_dev;
|
||||
}
|
||||
|
||||
void sighandler(int sig)
|
||||
{
|
||||
g_exit_flag = true;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
std::string p_burstspath;
|
||||
std::vector<std::string> args(argv + 1, argv + argc);
|
||||
signal(SIGINT, sighandler);
|
||||
signal(SIGTERM, sighandler);
|
||||
|
||||
for (auto i = args.begin(); i != args.end(); ++i) {
|
||||
parsec(args, i, "-txfreq", 1000, &p_txfreq);
|
||||
parsec(args, i, "-txgain", 1, &p_txgain);
|
||||
parsec(args, i, "-bandwidth", 1.f, &p_bandwidth);
|
||||
parsec(args, i, "-extref", &p_use_ext_ref);
|
||||
parsec(args, i, "-burstpath", &p_burstspath);
|
||||
parsec(args, i, "-ts_begin_offset", 1, &p_ts_begin_offset);
|
||||
parsec(args, i, "-ts_end_offset", 1, &p_ts_end_offset);
|
||||
}
|
||||
|
||||
if (p_burstspath.empty()) {
|
||||
std::cerr << "parameters:" << std::endl
|
||||
<< "-txfreq 881000 [khz]" << std::endl
|
||||
<< "-txgain 5 [dB]" << std::endl
|
||||
<< "-bandwidth 500000 [hz]" << std::endl
|
||||
<< "-extref [use external gpsdo as ref]" << std::endl
|
||||
<< "-burstpath ./foo/bar [path to bursts]" << std::endl
|
||||
<< "-ts_begin_offset [shifts begin ts, in samples]" << std::endl
|
||||
<< "-ts_end_offset [shifts end ts, in samples]" << std::endl;
|
||||
}
|
||||
std::cerr << "txfreq " << p_txfreq << std::endl;
|
||||
std::cerr << "txgain " << p_txgain << std::endl;
|
||||
std::cerr << "bandwidth " << p_bandwidth << std::endl;
|
||||
std::cerr << "using ext clock ref: " << (p_use_ext_ref ? "yes " : "no") << std::endl;
|
||||
|
||||
auto fl = list_dir(p_burstspath);
|
||||
auto fl2 = filter_entries(fl, ".cfile");
|
||||
|
||||
if (fl2.empty()) {
|
||||
std::cerr << "file list empty, bursts missing? quitting.." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
std::cerr << "got " << fl2.size() << " burst files.." << std::endl;
|
||||
|
||||
using fdatat = decltype(readf<std::complex<float>>("dummy"));
|
||||
|
||||
std::vector<fdatat> burstvec;
|
||||
for (auto i : fl2) {
|
||||
auto *f = readf<std::complex<float>>(i.c_str());
|
||||
burstvec.push_back(f);
|
||||
// std::cerr << i << ":" << f->num_samp << std::endl;
|
||||
}
|
||||
|
||||
auto usrp = init_device();
|
||||
|
||||
auto now_in_ticks = usrp->get_time_now().to_ticks(txtickrate);
|
||||
auto rep_in_ticks = uhd::time_spec_t(1.).to_ticks(txtickrate);
|
||||
auto tx_start = now_in_ticks + rep_in_ticks;
|
||||
|
||||
std::cerr << "start ts: " << tx_start << std::endl;
|
||||
|
||||
auto rx_dummy_thread = std::thread([tx_start]() {
|
||||
std::complex<uint16_t> rx_dummy_buffer[5000];
|
||||
const std::vector<void *> recv_buf(1, rx_dummy_buffer);
|
||||
uhd::rx_metadata_t rx_md;
|
||||
|
||||
uhd::stream_cmd_t rx_cmd{ uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS };
|
||||
rx_cmd.time_spec = rx_cmd.time_spec.from_ticks(tx_start, txtickrate);
|
||||
rx_stream->issue_stream_cmd(rx_cmd);
|
||||
|
||||
while (!g_exit_flag) {
|
||||
rx_stream->recv(recv_buf, 5000, rx_md, 0.2, true);
|
||||
}
|
||||
|
||||
uhd::stream_cmd_t stop_cmd{ uhd::stream_cmd_t::STREAM_MODE_STOP_CONTINUOUS };
|
||||
rx_stream->issue_stream_cmd(stop_cmd);
|
||||
});
|
||||
|
||||
// std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||
|
||||
while (!g_exit_flag) {
|
||||
for (auto *f : burstvec) {
|
||||
std::vector<int16_t> burst_buf(f->num_samp * 2);
|
||||
// auto RSSI = 10;
|
||||
auto scalefac = txFullScale; //txFullScale * pow(10, -RSSI / 10);
|
||||
convert_and_scale(burst_buf.data(), f->buf.get(), f->num_samp * 2, scalefac);
|
||||
|
||||
if (g_exit_flag)
|
||||
break;
|
||||
|
||||
gpio_cmd(tx_start + p_ts_begin_offset, tx_start + f->num_samp + p_ts_end_offset);
|
||||
|
||||
uhd::tx_metadata_t m = {};
|
||||
m.end_of_burst = true;
|
||||
m.start_of_burst = true;
|
||||
m.has_time_spec = true;
|
||||
m.time_spec = m.time_spec.from_ticks(tx_start, txtickrate);
|
||||
std::vector<void *> ptrs(1, burst_buf.data());
|
||||
tx_stream->send(ptrs, f->num_samp, m, 1.0);
|
||||
|
||||
uhd::async_metadata_t async_md;
|
||||
bool tx_ack = false;
|
||||
while (!tx_ack && tx_stream->recv_async_msg(async_md, 1.5)) {
|
||||
tx_ack = (async_md.event_code == uhd::async_metadata_t::EVENT_CODE_BURST_ACK);
|
||||
}
|
||||
std::cout << tx_start << " -> " << (tx_ack ? "tx ack @" : "tx NAK @") << " "
|
||||
<< async_md.time_spec.to_ticks(txtickrate) << std::endl;
|
||||
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(500));
|
||||
|
||||
tx_start += rep_in_ticks;
|
||||
}
|
||||
}
|
||||
|
||||
g_exit_flag = true;
|
||||
rx_dummy_thread.join();
|
||||
|
||||
for (auto *f : burstvec) {
|
||||
delete f;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,160 @@
|
|||
#pragma once
|
||||
/*
|
||||
* Copyright 2022 sysmocom - s.f.m.c. GmbH
|
||||
*
|
||||
* Author: Eric Wild <ewild@sysmocom.de>
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0+
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* See the COPYING file in the main directory for details.
|
||||
*/
|
||||
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
#include <complex>
|
||||
#include <filesystem>
|
||||
#include <fstream>
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <complex>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
const int SAMPLE_SCALE_FACTOR = 1;
|
||||
template <typename T> struct readf_res {
|
||||
using value_type = T;
|
||||
const unsigned int num_samp;
|
||||
std::shared_ptr<T> buf;
|
||||
explicit readf_res(unsigned int num_samples)
|
||||
: num_samp(num_samples), buf(std::shared_ptr<T>(new T[num_samples], [](const T *ptr) { delete[] ptr; }))
|
||||
{
|
||||
}
|
||||
explicit readf_res(unsigned int num_samples, std::shared_ptr<T> ptr)
|
||||
: num_samp(num_samples), buf(std::move(ptr), [](const T *ptr) { delete[] ptr; })
|
||||
{
|
||||
}
|
||||
explicit readf_res(unsigned int num_samples, T *ptr)
|
||||
: num_samp(num_samples), buf(ptr, [](const T *ptr) { delete[] ptr; })
|
||||
{
|
||||
}
|
||||
readf_res() = delete;
|
||||
readf_res(const readf_res &) = delete;
|
||||
readf_res &operator=(const readf_res &) = delete;
|
||||
~readf_res() = default;
|
||||
unsigned int size_in_byte()
|
||||
{
|
||||
return num_samp * sizeof(T);
|
||||
}
|
||||
const char *getbytes()
|
||||
{
|
||||
return (char *)buf.get();
|
||||
}
|
||||
};
|
||||
template <typename T> readf_res<T> *readf(const char *path)
|
||||
{
|
||||
streampos begin, end;
|
||||
ifstream myfile(path, ios::binary);
|
||||
begin = myfile.tellg();
|
||||
myfile.seekg(0, ios::end);
|
||||
end = myfile.tellg();
|
||||
auto len_in_byte = end - begin;
|
||||
auto len_in_sps = len_in_byte / sizeof(T);
|
||||
T *T_buf = new T[len_in_sps];
|
||||
|
||||
myfile.seekg(0, ios::beg);
|
||||
myfile.read((char *)T_buf, len_in_byte);
|
||||
myfile.close();
|
||||
// cout << "size is: " << (len_in_byte) << " bytes, " << len_in_sps << " samples.\n";
|
||||
return new readf_res<T>{ (unsigned int)len_in_sps, T_buf };
|
||||
}
|
||||
|
||||
std::vector<std::string> list_dir(std::string path)
|
||||
{
|
||||
std::vector<std::string> files;
|
||||
struct dirent *entry = nullptr;
|
||||
char resolved[PATH_MAX];
|
||||
realpath(path.c_str(), resolved);
|
||||
DIR *dir = opendir(path.c_str());
|
||||
if (dir == nullptr) {
|
||||
return {};
|
||||
}
|
||||
|
||||
while ((entry = readdir(dir)) != nullptr) {
|
||||
if (entry->d_type == DT_REG) {
|
||||
files.emplace_back(std::string(resolved) + "/" + entry->d_name);
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return files;
|
||||
}
|
||||
|
||||
std::vector<std::string> filter_entries(std::vector<std::string> e, std::string file_ending)
|
||||
{
|
||||
std::vector<std::string> filtered = {};
|
||||
for (auto s : e) {
|
||||
auto mm = mismatch(file_ending.rbegin(), file_ending.rend(), s.rbegin()).first != file_ending.rend();
|
||||
if (!mm)
|
||||
filtered.emplace_back(s);
|
||||
}
|
||||
return filtered;
|
||||
}
|
||||
|
||||
namespace cvt_internal
|
||||
{
|
||||
|
||||
template <typename SRC_T, typename ST>
|
||||
void convert_and_scale_i(float *dst, const SRC_T *src, unsigned int src_len, ST scale)
|
||||
{
|
||||
for (unsigned int i = 0; i < src_len; i++)
|
||||
dst[i] = static_cast<float>(src[i]) * scale;
|
||||
}
|
||||
|
||||
template <typename DST_T, typename ST>
|
||||
void convert_and_scale_i(DST_T *dst, const float *src, unsigned int src_len, ST scale)
|
||||
{
|
||||
for (unsigned int i = 0; i < src_len; i++)
|
||||
dst[i] = static_cast<DST_T>(src[i] * scale);
|
||||
}
|
||||
|
||||
template <typename ST> void convert_and_scale_i(float *dst, const float *src, unsigned int src_len, ST scale)
|
||||
{
|
||||
for (unsigned int i = 0; i < src_len; i++)
|
||||
dst[i] = src[i] * scale;
|
||||
}
|
||||
|
||||
template <typename T> struct is_complex : std::false_type {
|
||||
using baset = T;
|
||||
};
|
||||
|
||||
template <typename T> struct is_complex<std::complex<T>> : std::true_type {
|
||||
using baset = typename std::complex<T>::value_type;
|
||||
};
|
||||
|
||||
|
||||
} // namespace cvt_internal
|
||||
|
||||
template <typename DST_T, typename SRC_T, typename ST>
|
||||
void convert_and_scale(DST_T *dst, const SRC_T *src, unsigned int src_len, ST scale)
|
||||
{
|
||||
using vd = typename cvt_internal::is_complex<DST_T>::baset;
|
||||
using vs = typename cvt_internal::is_complex<SRC_T>::baset;
|
||||
return cvt_internal::convert_and_scale_i((vd *)dst, (vs *)src, src_len, scale);
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue