partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | StructureMatcher.get_supercell_matrix | Returns the matrix for transforming struct to supercell. This
can be used for very distorted 'supercells' where the primitive cell
is impossible to find | pymatgen/analysis/structure_matcher.py | def get_supercell_matrix(self, supercell, struct):
"""
Returns the matrix for transforming struct to supercell. This
can be used for very distorted 'supercells' where the primitive cell
is impossible to find
"""
if self._primitive_cell:
raise ValueError("get_s... | def get_supercell_matrix(self, supercell, struct):
"""
Returns the matrix for transforming struct to supercell. This
can be used for very distorted 'supercells' where the primitive cell
is impossible to find
"""
if self._primitive_cell:
raise ValueError("get_s... | [
"Returns",
"the",
"matrix",
"for",
"transforming",
"struct",
"to",
"supercell",
".",
"This",
"can",
"be",
"used",
"for",
"very",
"distorted",
"supercells",
"where",
"the",
"primitive",
"cell",
"is",
"impossible",
"to",
"find"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L956-L978 | [
"def",
"get_supercell_matrix",
"(",
"self",
",",
"supercell",
",",
"struct",
")",
":",
"if",
"self",
".",
"_primitive_cell",
":",
"raise",
"ValueError",
"(",
"\"get_supercell_matrix cannot be used with the \"",
"\"primitive cell option\"",
")",
"struct",
",",
"supercell... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureMatcher.get_transformation | Returns the supercell transformation, fractional translation vector,
and a mapping to transform struct2 to be similar to struct1.
Args:
struct1 (Structure): Reference structure
struct2 (Structure): Structure to transform.
Returns:
supercell (numpy.ndarray(3,... | pymatgen/analysis/structure_matcher.py | def get_transformation(self, struct1, struct2):
"""
Returns the supercell transformation, fractional translation vector,
and a mapping to transform struct2 to be similar to struct1.
Args:
struct1 (Structure): Reference structure
struct2 (Structure): Structure to ... | def get_transformation(self, struct1, struct2):
"""
Returns the supercell transformation, fractional translation vector,
and a mapping to transform struct2 to be similar to struct1.
Args:
struct1 (Structure): Reference structure
struct2 (Structure): Structure to ... | [
"Returns",
"the",
"supercell",
"transformation",
"fractional",
"translation",
"vector",
"and",
"a",
"mapping",
"to",
"transform",
"struct2",
"to",
"be",
"similar",
"to",
"struct1",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L980-L1031 | [
"def",
"get_transformation",
"(",
"self",
",",
"struct1",
",",
"struct2",
")",
":",
"if",
"self",
".",
"_primitive_cell",
":",
"raise",
"ValueError",
"(",
"\"get_transformation cannot be used with the \"",
"\"primitive cell option\"",
")",
"struct1",
",",
"struct2",
"... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureMatcher.get_s2_like_s1 | Performs transformations on struct2 to put it in a basis similar to
struct1 (without changing any of the inter-site distances)
Args:
struct1 (Structure): Reference structure
struct2 (Structure): Structure to transform.
include_ignored_species (bool): Defaults to True... | pymatgen/analysis/structure_matcher.py | def get_s2_like_s1(self, struct1, struct2, include_ignored_species=True):
"""
Performs transformations on struct2 to put it in a basis similar to
struct1 (without changing any of the inter-site distances)
Args:
struct1 (Structure): Reference structure
struct2 (St... | def get_s2_like_s1(self, struct1, struct2, include_ignored_species=True):
"""
Performs transformations on struct2 to put it in a basis similar to
struct1 (without changing any of the inter-site distances)
Args:
struct1 (Structure): Reference structure
struct2 (St... | [
"Performs",
"transformations",
"on",
"struct2",
"to",
"put",
"it",
"in",
"a",
"basis",
"similar",
"to",
"struct1",
"(",
"without",
"changing",
"any",
"of",
"the",
"inter",
"-",
"site",
"distances",
")"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L1033-L1074 | [
"def",
"get_s2_like_s1",
"(",
"self",
",",
"struct1",
",",
"struct2",
",",
"include_ignored_species",
"=",
"True",
")",
":",
"s1",
",",
"s2",
"=",
"self",
".",
"_process_species",
"(",
"[",
"struct1",
",",
"struct2",
"]",
")",
"trans",
"=",
"self",
".",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | StructureMatcher.get_mapping | Calculate the mapping from superset to subset.
Args:
superset (Structure): Structure containing at least the sites in
subset (within the structure matching tolerance)
subset (Structure): Structure containing some of the sites in
superset (within the struc... | pymatgen/analysis/structure_matcher.py | def get_mapping(self, superset, subset):
"""
Calculate the mapping from superset to subset.
Args:
superset (Structure): Structure containing at least the sites in
subset (within the structure matching tolerance)
subset (Structure): Structure containing so... | def get_mapping(self, superset, subset):
"""
Calculate the mapping from superset to subset.
Args:
superset (Structure): Structure containing at least the sites in
subset (within the structure matching tolerance)
subset (Structure): Structure containing so... | [
"Calculate",
"the",
"mapping",
"from",
"superset",
"to",
"subset",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L1076-L1104 | [
"def",
"get_mapping",
"(",
"self",
",",
"superset",
",",
"subset",
")",
":",
"if",
"self",
".",
"_supercell",
":",
"raise",
"ValueError",
"(",
"\"cannot compute mapping to supercell\"",
")",
"if",
"self",
".",
"_primitive_cell",
":",
"raise",
"ValueError",
"(",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | PointDefectComparator.are_equal | Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object.
Returns:
True if defects are identical in type and sublattice. | pymatgen/analysis/structure_matcher.py | def are_equal(self, d1, d2):
"""
Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object.
Returns:
True if defects are identical in type and sublattice.
"""
possible_defect_types = (Defect, Vacancy, Substi... | def are_equal(self, d1, d2):
"""
Args:
d1: First defect. A pymatgen Defect object.
d2: Second defect. A pymatgen Defect object.
Returns:
True if defects are identical in type and sublattice.
"""
possible_defect_types = (Defect, Vacancy, Substi... | [
"Args",
":",
"d1",
":",
"First",
"defect",
".",
"A",
"pymatgen",
"Defect",
"object",
".",
"d2",
":",
"Second",
"defect",
".",
"A",
"pymatgen",
"Defect",
"object",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/structure_matcher.py#L1134-L1186 | [
"def",
"are_equal",
"(",
"self",
",",
"d1",
",",
"d2",
")",
":",
"possible_defect_types",
"=",
"(",
"Defect",
",",
"Vacancy",
",",
"Substitution",
",",
"Interstitial",
")",
"if",
"not",
"isinstance",
"(",
"d1",
",",
"possible_defect_types",
")",
"or",
"not... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionElectrode.from_composition_and_pd | Convenience constructor to make a ConversionElectrode from a
composition and a phase diagram.
Args:
comp:
Starting composition for ConversionElectrode, e.g.,
Composition("FeF3")
pd:
A PhaseDiagram of the relevant system (e.g., Li-F... | pymatgen/apps/battery/conversion_battery.py | def from_composition_and_pd(comp, pd, working_ion_symbol="Li"):
"""
Convenience constructor to make a ConversionElectrode from a
composition and a phase diagram.
Args:
comp:
Starting composition for ConversionElectrode, e.g.,
Composition("FeF3... | def from_composition_and_pd(comp, pd, working_ion_symbol="Li"):
"""
Convenience constructor to make a ConversionElectrode from a
composition and a phase diagram.
Args:
comp:
Starting composition for ConversionElectrode, e.g.,
Composition("FeF3... | [
"Convenience",
"constructor",
"to",
"make",
"a",
"ConversionElectrode",
"from",
"a",
"composition",
"and",
"a",
"phase",
"diagram",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L56-L99 | [
"def",
"from_composition_and_pd",
"(",
"comp",
",",
"pd",
",",
"working_ion_symbol",
"=",
"\"Li\"",
")",
":",
"working_ion",
"=",
"Element",
"(",
"working_ion_symbol",
")",
"entry",
"=",
"None",
"working_ion_entry",
"=",
"None",
"for",
"e",
"in",
"pd",
".",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionElectrode.from_composition_and_entries | Convenience constructor to make a ConversionElectrode from a
composition and all entries in a chemical system.
Args:
comp: Starting composition for ConversionElectrode, e.g.,
Composition("FeF3")
entries_in_chemsys: Sequence containing all entries in a
... | pymatgen/apps/battery/conversion_battery.py | def from_composition_and_entries(comp, entries_in_chemsys,
working_ion_symbol="Li"):
"""
Convenience constructor to make a ConversionElectrode from a
composition and all entries in a chemical system.
Args:
comp: Starting composition for C... | def from_composition_and_entries(comp, entries_in_chemsys,
working_ion_symbol="Li"):
"""
Convenience constructor to make a ConversionElectrode from a
composition and all entries in a chemical system.
Args:
comp: Starting composition for C... | [
"Convenience",
"constructor",
"to",
"make",
"a",
"ConversionElectrode",
"from",
"a",
"composition",
"and",
"all",
"entries",
"in",
"a",
"chemical",
"system",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L102-L117 | [
"def",
"from_composition_and_entries",
"(",
"comp",
",",
"entries_in_chemsys",
",",
"working_ion_symbol",
"=",
"\"Li\"",
")",
":",
"pd",
"=",
"PhaseDiagram",
"(",
"entries_in_chemsys",
")",
"return",
"ConversionElectrode",
".",
"from_composition_and_pd",
"(",
"comp",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionElectrode.get_sub_electrodes | If this electrode contains multiple voltage steps, then it is possible
to use only a subset of the voltage steps to define other electrodes.
For example, an LiTiO2 electrode might contain three subelectrodes:
[LiTiO2 --> TiO2, LiTiO2 --> Li0.5TiO2, Li0.5TiO2 --> TiO2]
This method can be ... | pymatgen/apps/battery/conversion_battery.py | def get_sub_electrodes(self, adjacent_only=True):
"""
If this electrode contains multiple voltage steps, then it is possible
to use only a subset of the voltage steps to define other electrodes.
For example, an LiTiO2 electrode might contain three subelectrodes:
[LiTiO2 --> TiO2,... | def get_sub_electrodes(self, adjacent_only=True):
"""
If this electrode contains multiple voltage steps, then it is possible
to use only a subset of the voltage steps to define other electrodes.
For example, an LiTiO2 electrode might contain three subelectrodes:
[LiTiO2 --> TiO2,... | [
"If",
"this",
"electrode",
"contains",
"multiple",
"voltage",
"steps",
"then",
"it",
"is",
"possible",
"to",
"use",
"only",
"a",
"subset",
"of",
"the",
"voltage",
"steps",
"to",
"define",
"other",
"electrodes",
".",
"For",
"example",
"an",
"LiTiO2",
"electro... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L119-L147 | [
"def",
"get_sub_electrodes",
"(",
"self",
",",
"adjacent_only",
"=",
"True",
")",
":",
"if",
"adjacent_only",
":",
"return",
"[",
"self",
".",
"__class__",
"(",
"self",
".",
"_vpairs",
"[",
"i",
":",
"i",
"+",
"1",
"]",
",",
"self",
".",
"_working_ion_... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionElectrode.is_super_electrode | Checks if a particular conversion electrode is a sub electrode of the
current electrode. Starting from a more lithiated state may result in
a subelectrode that is essentially on the same path. For example, a
ConversionElectrode formed by starting from an FePO4 composition would
be a sup... | pymatgen/apps/battery/conversion_battery.py | def is_super_electrode(self, conversion_electrode):
"""
Checks if a particular conversion electrode is a sub electrode of the
current electrode. Starting from a more lithiated state may result in
a subelectrode that is essentially on the same path. For example, a
ConversionElect... | def is_super_electrode(self, conversion_electrode):
"""
Checks if a particular conversion electrode is a sub electrode of the
current electrode. Starting from a more lithiated state may result in
a subelectrode that is essentially on the same path. For example, a
ConversionElect... | [
"Checks",
"if",
"a",
"particular",
"conversion",
"electrode",
"is",
"a",
"sub",
"electrode",
"of",
"the",
"current",
"electrode",
".",
"Starting",
"from",
"a",
"more",
"lithiated",
"state",
"may",
"result",
"in",
"a",
"subelectrode",
"that",
"is",
"essentially... | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L168-L191 | [
"def",
"is_super_electrode",
"(",
"self",
",",
"conversion_electrode",
")",
":",
"for",
"pair1",
"in",
"conversion_electrode",
":",
"rxn1",
"=",
"pair1",
".",
"rxn",
"all_formulas1",
"=",
"set",
"(",
"[",
"rxn1",
".",
"all_comp",
"[",
"i",
"]",
".",
"reduc... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionElectrode.get_summary_dict | Args:
print_subelectrodes:
Also print data on all the possible subelectrodes
Returns:
a summary of this electrode"s properties in dictionary format | pymatgen/apps/battery/conversion_battery.py | def get_summary_dict(self, print_subelectrodes=True):
"""
Args:
print_subelectrodes:
Also print data on all the possible subelectrodes
Returns:
a summary of this electrode"s properties in dictionary format
"""
d = {}
framework_com... | def get_summary_dict(self, print_subelectrodes=True):
"""
Args:
print_subelectrodes:
Also print data on all the possible subelectrodes
Returns:
a summary of this electrode"s properties in dictionary format
"""
d = {}
framework_com... | [
"Args",
":",
"print_subelectrodes",
":",
"Also",
"print",
"data",
"on",
"all",
"the",
"possible",
"subelectrodes"
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L250-L305 | [
"def",
"get_summary_dict",
"(",
"self",
",",
"print_subelectrodes",
"=",
"True",
")",
":",
"d",
"=",
"{",
"}",
"framework_comp",
"=",
"Composition",
"(",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"self",
".",
"_composition",
".",
"items",
"(",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | ConversionVoltagePair.from_steps | Creates a ConversionVoltagePair from two steps in the element profile
from a PD analysis.
Args:
step1: Starting step
step2: Ending step
normalization_els: Elements to normalize the reaction by. To
ensure correct capacities. | pymatgen/apps/battery/conversion_battery.py | def from_steps(step1, step2, normalization_els):
"""
Creates a ConversionVoltagePair from two steps in the element profile
from a PD analysis.
Args:
step1: Starting step
step2: Ending step
normalization_els: Elements to normalize the reaction by. To
... | def from_steps(step1, step2, normalization_els):
"""
Creates a ConversionVoltagePair from two steps in the element profile
from a PD analysis.
Args:
step1: Starting step
step2: Ending step
normalization_els: Elements to normalize the reaction by. To
... | [
"Creates",
"a",
"ConversionVoltagePair",
"from",
"two",
"steps",
"in",
"the",
"element",
"profile",
"from",
"a",
"PD",
"analysis",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/conversion_battery.py#L348-L421 | [
"def",
"from_steps",
"(",
"step1",
",",
"step2",
",",
"normalization_els",
")",
":",
"working_ion_entry",
"=",
"step1",
"[",
"\"element_reference\"",
"]",
"working_ion",
"=",
"working_ion_entry",
".",
"composition",
".",
"elements",
"[",
"0",
"]",
".",
"symbol",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | Xr.from_string | Creates an Xr object from a string representation.
Args:
string (str): string representation of an Xr object.
use_cores (bool): use core positions and discard shell
positions if set to True (default). Otherwise,
use shell positions and discard co... | pymatgen/io/xr.py | def from_string(string, use_cores=True, thresh=1.e-4):
"""
Creates an Xr object from a string representation.
Args:
string (str): string representation of an Xr object.
use_cores (bool): use core positions and discard shell
positions if set to True (d... | def from_string(string, use_cores=True, thresh=1.e-4):
"""
Creates an Xr object from a string representation.
Args:
string (str): string representation of an Xr object.
use_cores (bool): use core positions and discard shell
positions if set to True (d... | [
"Creates",
"an",
"Xr",
"object",
"from",
"a",
"string",
"representation",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/xr.py#L78-L139 | [
"def",
"from_string",
"(",
"string",
",",
"use_cores",
"=",
"True",
",",
"thresh",
"=",
"1.e-4",
")",
":",
"lines",
"=",
"string",
".",
"split",
"(",
"\"\\n\"",
")",
"toks",
"=",
"lines",
"[",
"0",
"]",
".",
"split",
"(",
")",
"lengths",
"=",
"[",
... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | Xr.from_file | Reads an xr-formatted file to create an Xr object.
Args:
filename (str): name of file to read from.
use_cores (bool): use core positions and discard shell
positions if set to True (default). Otherwise,
use shell positions and discard core positio... | pymatgen/io/xr.py | def from_file(filename, use_cores=True, thresh=1.e-4):
"""
Reads an xr-formatted file to create an Xr object.
Args:
filename (str): name of file to read from.
use_cores (bool): use core positions and discard shell
positions if set to True (default). ... | def from_file(filename, use_cores=True, thresh=1.e-4):
"""
Reads an xr-formatted file to create an Xr object.
Args:
filename (str): name of file to read from.
use_cores (bool): use core positions and discard shell
positions if set to True (default). ... | [
"Reads",
"an",
"xr",
"-",
"formatted",
"file",
"to",
"create",
"an",
"Xr",
"object",
"."
] | materialsproject/pymatgen | python | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/io/xr.py#L142-L162 | [
"def",
"from_file",
"(",
"filename",
",",
"use_cores",
"=",
"True",
",",
"thresh",
"=",
"1.e-4",
")",
":",
"with",
"zopen",
"(",
"filename",
",",
"\"rt\"",
")",
"as",
"f",
":",
"return",
"Xr",
".",
"from_string",
"(",
"f",
".",
"read",
"(",
")",
",... | 4ca558cf72f8d5f8a1f21dfdfc0181a971c186da |
train | framesig | Frame a signal into overlapping frames.
:param sig: the audio signal to frame.
:param frame_len: length of each frame measured in samples.
:param frame_step: number of samples after the start of the previous frame that the next frame should begin.
:param winfunc: the analysis window to apply to each fr... | python_speech_features/sigproc.py | def framesig(sig, frame_len, frame_step, winfunc=lambda x: numpy.ones((x,)), stride_trick=True):
"""Frame a signal into overlapping frames.
:param sig: the audio signal to frame.
:param frame_len: length of each frame measured in samples.
:param frame_step: number of samples after the start of the prev... | def framesig(sig, frame_len, frame_step, winfunc=lambda x: numpy.ones((x,)), stride_trick=True):
"""Frame a signal into overlapping frames.
:param sig: the audio signal to frame.
:param frame_len: length of each frame measured in samples.
:param frame_step: number of samples after the start of the prev... | [
"Frame",
"a",
"signal",
"into",
"overlapping",
"frames",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/sigproc.py#L21-L53 | [
"def",
"framesig",
"(",
"sig",
",",
"frame_len",
",",
"frame_step",
",",
"winfunc",
"=",
"lambda",
"x",
":",
"numpy",
".",
"ones",
"(",
"(",
"x",
",",
")",
")",
",",
"stride_trick",
"=",
"True",
")",
":",
"slen",
"=",
"len",
"(",
"sig",
")",
"fra... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | deframesig | Does overlap-add procedure to undo the action of framesig.
:param frames: the array of frames.
:param siglen: the length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples.
:param frame_len: length of each frame measured in samples.
:param frame_step: number of samples ... | python_speech_features/sigproc.py | def deframesig(frames, siglen, frame_len, frame_step, winfunc=lambda x: numpy.ones((x,))):
"""Does overlap-add procedure to undo the action of framesig.
:param frames: the array of frames.
:param siglen: the length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples.
:pa... | def deframesig(frames, siglen, frame_len, frame_step, winfunc=lambda x: numpy.ones((x,))):
"""Does overlap-add procedure to undo the action of framesig.
:param frames: the array of frames.
:param siglen: the length of the desired signal, use 0 if unknown. Output will be truncated to siglen samples.
:pa... | [
"Does",
"overlap",
"-",
"add",
"procedure",
"to",
"undo",
"the",
"action",
"of",
"framesig",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/sigproc.py#L56-L88 | [
"def",
"deframesig",
"(",
"frames",
",",
"siglen",
",",
"frame_len",
",",
"frame_step",
",",
"winfunc",
"=",
"lambda",
"x",
":",
"numpy",
".",
"ones",
"(",
"(",
"x",
",",
")",
")",
")",
":",
"frame_len",
"=",
"round_half_up",
"(",
"frame_len",
")",
"... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | magspec | Compute the magnitude spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:returns: If frames is an NxD matrix, output will be... | python_speech_features/sigproc.py | def magspec(frames, NFFT):
"""Compute the magnitude spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:returns: If frame... | def magspec(frames, NFFT):
"""Compute the magnitude spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:returns: If frame... | [
"Compute",
"the",
"magnitude",
"spectrum",
"of",
"each",
"frame",
"in",
"frames",
".",
"If",
"frames",
"is",
"an",
"NxD",
"matrix",
"output",
"will",
"be",
"Nx",
"(",
"NFFT",
"/",
"2",
"+",
"1",
")",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/sigproc.py#L91-L103 | [
"def",
"magspec",
"(",
"frames",
",",
"NFFT",
")",
":",
"if",
"numpy",
".",
"shape",
"(",
"frames",
")",
"[",
"1",
"]",
">",
"NFFT",
":",
"logging",
".",
"warn",
"(",
"'frame length (%d) is greater than FFT size (%d), frame will be truncated. Increase NFFT to avoid.... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | logpowspec | Compute the log power spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:param norm: If norm=1, the log power spectrum is no... | python_speech_features/sigproc.py | def logpowspec(frames, NFFT, norm=1):
"""Compute the log power spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:param ... | def logpowspec(frames, NFFT, norm=1):
"""Compute the log power spectrum of each frame in frames. If frames is an NxD matrix, output will be Nx(NFFT/2+1).
:param frames: the array of frames. Each row is a frame.
:param NFFT: the FFT length to use. If NFFT > frame_len, the frames are zero-padded.
:param ... | [
"Compute",
"the",
"log",
"power",
"spectrum",
"of",
"each",
"frame",
"in",
"frames",
".",
"If",
"frames",
"is",
"an",
"NxD",
"matrix",
"output",
"will",
"be",
"Nx",
"(",
"NFFT",
"/",
"2",
"+",
"1",
")",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/sigproc.py#L116-L130 | [
"def",
"logpowspec",
"(",
"frames",
",",
"NFFT",
",",
"norm",
"=",
"1",
")",
":",
"ps",
"=",
"powspec",
"(",
"frames",
",",
"NFFT",
")",
"ps",
"[",
"ps",
"<=",
"1e-30",
"]",
"=",
"1e-30",
"lps",
"=",
"10",
"*",
"numpy",
".",
"log10",
"(",
"ps",... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | calculate_nfft | Calculates the FFT size as a power of two greater than or equal to
the number of samples in a single window length.
Having an FFT less than the window length loses precision by dropping
many of the samples; a longer FFT than the window allows zero-padding
of the FFT buffer which is neutral in terms... | python_speech_features/base.py | def calculate_nfft(samplerate, winlen):
"""Calculates the FFT size as a power of two greater than or equal to
the number of samples in a single window length.
Having an FFT less than the window length loses precision by dropping
many of the samples; a longer FFT than the window allows zero-padding
... | def calculate_nfft(samplerate, winlen):
"""Calculates the FFT size as a power of two greater than or equal to
the number of samples in a single window length.
Having an FFT less than the window length loses precision by dropping
many of the samples; a longer FFT than the window allows zero-padding
... | [
"Calculates",
"the",
"FFT",
"size",
"as",
"a",
"power",
"of",
"two",
"greater",
"than",
"or",
"equal",
"to",
"the",
"number",
"of",
"samples",
"in",
"a",
"single",
"window",
"length",
".",
"Having",
"an",
"FFT",
"less",
"than",
"the",
"window",
"length",... | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L8-L23 | [
"def",
"calculate_nfft",
"(",
"samplerate",
",",
"winlen",
")",
":",
"window_length_samples",
"=",
"winlen",
"*",
"samplerate",
"nfft",
"=",
"1",
"while",
"nfft",
"<",
"window_length_samples",
":",
"nfft",
"*=",
"2",
"return",
"nfft"
] | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | mfcc | Compute MFCC features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an N*1 array
:param samplerate: the sample rate of the signal we are working with, in Hz.
:param winlen: the length of the analysis window in seconds. Default is 0.025s (25 milliseconds)
... | python_speech_features/base.py | def mfcc(signal,samplerate=16000,winlen=0.025,winstep=0.01,numcep=13,
nfilt=26,nfft=None,lowfreq=0,highfreq=None,preemph=0.97,ceplifter=22,appendEnergy=True,
winfunc=lambda x:numpy.ones((x,))):
"""Compute MFCC features from an audio signal.
:param signal: the audio signal from which to comput... | def mfcc(signal,samplerate=16000,winlen=0.025,winstep=0.01,numcep=13,
nfilt=26,nfft=None,lowfreq=0,highfreq=None,preemph=0.97,ceplifter=22,appendEnergy=True,
winfunc=lambda x:numpy.ones((x,))):
"""Compute MFCC features from an audio signal.
:param signal: the audio signal from which to comput... | [
"Compute",
"MFCC",
"features",
"from",
"an",
"audio",
"signal",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L25-L51 | [
"def",
"mfcc",
"(",
"signal",
",",
"samplerate",
"=",
"16000",
",",
"winlen",
"=",
"0.025",
",",
"winstep",
"=",
"0.01",
",",
"numcep",
"=",
"13",
",",
"nfilt",
"=",
"26",
",",
"nfft",
"=",
"None",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | fbank | Compute Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an N*1 array
:param samplerate: the sample rate of the signal we are working with, in Hz.
:param winlen: the length of the analysis window in seconds. Default is 0.025s (25... | python_speech_features/base.py | def fbank(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute features. Should be ... | def fbank(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute features. Should be ... | [
"Compute",
"Mel",
"-",
"filterbank",
"energy",
"features",
"from",
"an",
"audio",
"signal",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L53-L82 | [
"def",
"fbank",
"(",
"signal",
",",
"samplerate",
"=",
"16000",
",",
"winlen",
"=",
"0.025",
",",
"winstep",
"=",
"0.01",
",",
"nfilt",
"=",
"26",
",",
"nfft",
"=",
"512",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
"None",
",",
"preemph",
"=",... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | logfbank | Compute log Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an N*1 array
:param samplerate: the sample rate of the signal we are working with, in Hz.
:param winlen: the length of the analysis window in seconds. Default is 0.025s... | python_speech_features/base.py | def logfbank(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute log Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute feature... | def logfbank(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute log Mel-filterbank energy features from an audio signal.
:param signal: the audio signal from which to compute feature... | [
"Compute",
"log",
"Mel",
"-",
"filterbank",
"energy",
"features",
"from",
"an",
"audio",
"signal",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L84-L102 | [
"def",
"logfbank",
"(",
"signal",
",",
"samplerate",
"=",
"16000",
",",
"winlen",
"=",
"0.025",
",",
"winstep",
"=",
"0.01",
",",
"nfilt",
"=",
"26",
",",
"nfft",
"=",
"512",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
"None",
",",
"preemph",
"... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | ssc | Compute Spectral Subband Centroid features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an N*1 array
:param samplerate: the sample rate of the signal we are working with, in Hz.
:param winlen: the length of the analysis window in seconds. Default is 0.025s... | python_speech_features/base.py | def ssc(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute Spectral Subband Centroid features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an... | def ssc(signal,samplerate=16000,winlen=0.025,winstep=0.01,
nfilt=26,nfft=512,lowfreq=0,highfreq=None,preemph=0.97,
winfunc=lambda x:numpy.ones((x,))):
"""Compute Spectral Subband Centroid features from an audio signal.
:param signal: the audio signal from which to compute features. Should be an... | [
"Compute",
"Spectral",
"Subband",
"Centroid",
"features",
"from",
"an",
"audio",
"signal",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L104-L131 | [
"def",
"ssc",
"(",
"signal",
",",
"samplerate",
"=",
"16000",
",",
"winlen",
"=",
"0.025",
",",
"winstep",
"=",
"0.01",
",",
"nfilt",
"=",
"26",
",",
"nfft",
"=",
"512",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
"None",
",",
"preemph",
"=",
... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | get_filterbanks | Compute a Mel-filterbank. The filters are stored in the rows, the columns correspond
to fft bins. The filters are returned as an array of size nfilt * (nfft/2 + 1)
:param nfilt: the number of filters in the filterbank, default 20.
:param nfft: the FFT size. Default is 512.
:param samplerate: the sample... | python_speech_features/base.py | def get_filterbanks(nfilt=20,nfft=512,samplerate=16000,lowfreq=0,highfreq=None):
"""Compute a Mel-filterbank. The filters are stored in the rows, the columns correspond
to fft bins. The filters are returned as an array of size nfilt * (nfft/2 + 1)
:param nfilt: the number of filters in the filterbank, defa... | def get_filterbanks(nfilt=20,nfft=512,samplerate=16000,lowfreq=0,highfreq=None):
"""Compute a Mel-filterbank. The filters are stored in the rows, the columns correspond
to fft bins. The filters are returned as an array of size nfilt * (nfft/2 + 1)
:param nfilt: the number of filters in the filterbank, defa... | [
"Compute",
"a",
"Mel",
"-",
"filterbank",
".",
"The",
"filters",
"are",
"stored",
"in",
"the",
"rows",
"the",
"columns",
"correspond",
"to",
"fft",
"bins",
".",
"The",
"filters",
"are",
"returned",
"as",
"an",
"array",
"of",
"size",
"nfilt",
"*",
"(",
... | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L149-L177 | [
"def",
"get_filterbanks",
"(",
"nfilt",
"=",
"20",
",",
"nfft",
"=",
"512",
",",
"samplerate",
"=",
"16000",
",",
"lowfreq",
"=",
"0",
",",
"highfreq",
"=",
"None",
")",
":",
"highfreq",
"=",
"highfreq",
"or",
"samplerate",
"/",
"2",
"assert",
"highfre... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | lifter | Apply a cepstral lifter the the matrix of cepstra. This has the effect of increasing the
magnitude of the high frequency DCT coeffs.
:param cepstra: the matrix of mel-cepstra, will be numframes * numcep in size.
:param L: the liftering coefficient to use. Default is 22. L <= 0 disables lifter. | python_speech_features/base.py | def lifter(cepstra, L=22):
"""Apply a cepstral lifter the the matrix of cepstra. This has the effect of increasing the
magnitude of the high frequency DCT coeffs.
:param cepstra: the matrix of mel-cepstra, will be numframes * numcep in size.
:param L: the liftering coefficient to use. Default is 22. L ... | def lifter(cepstra, L=22):
"""Apply a cepstral lifter the the matrix of cepstra. This has the effect of increasing the
magnitude of the high frequency DCT coeffs.
:param cepstra: the matrix of mel-cepstra, will be numframes * numcep in size.
:param L: the liftering coefficient to use. Default is 22. L ... | [
"Apply",
"a",
"cepstral",
"lifter",
"the",
"the",
"matrix",
"of",
"cepstra",
".",
"This",
"has",
"the",
"effect",
"of",
"increasing",
"the",
"magnitude",
"of",
"the",
"high",
"frequency",
"DCT",
"coeffs",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L179-L193 | [
"def",
"lifter",
"(",
"cepstra",
",",
"L",
"=",
"22",
")",
":",
"if",
"L",
">",
"0",
":",
"nframes",
",",
"ncoeff",
"=",
"numpy",
".",
"shape",
"(",
"cepstra",
")",
"n",
"=",
"numpy",
".",
"arange",
"(",
"ncoeff",
")",
"lift",
"=",
"1",
"+",
... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | delta | Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUM... | python_speech_features/base.py | def delta(feat, N):
"""Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns:... | def delta(feat, N):
"""Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns:... | [
"Compute",
"delta",
"features",
"from",
"a",
"feature",
"vector",
"sequence",
"."
] | jameslyons/python_speech_features | python | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L195-L210 | [
"def",
"delta",
"(",
"feat",
",",
"N",
")",
":",
"if",
"N",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'N must be an integer >= 1'",
")",
"NUMFRAMES",
"=",
"len",
"(",
"feat",
")",
"denominator",
"=",
"2",
"*",
"sum",
"(",
"[",
"i",
"**",
"2",
"fo... | 40c590269b57c64a8c1f1ddaaff2162008d1850c |
train | Usb2CanAbstractionLayer.open | Opens a CAN connection using `CanalOpen()`.
:param str configuration: the configuration: "device_id; baudrate"
:param int flags: the flags to be set
:raises can.CanError: if any error occurred
:returns: Valid handle for CANAL API functions on success | can/interfaces/usb2can/usb2canabstractionlayer.py | def open(self, configuration, flags):
"""
Opens a CAN connection using `CanalOpen()`.
:param str configuration: the configuration: "device_id; baudrate"
:param int flags: the flags to be set
:raises can.CanError: if any error occurred
:returns: Valid handle for CANAL AP... | def open(self, configuration, flags):
"""
Opens a CAN connection using `CanalOpen()`.
:param str configuration: the configuration: "device_id; baudrate"
:param int flags: the flags to be set
:raises can.CanError: if any error occurred
:returns: Valid handle for CANAL AP... | [
"Opens",
"a",
"CAN",
"connection",
"using",
"CanalOpen",
"()",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/usb2canabstractionlayer.py#L82-L109 | [
"def",
"open",
"(",
"self",
",",
"configuration",
",",
"flags",
")",
":",
"try",
":",
"# we need to convert this into bytes, since the underlying DLL cannot",
"# handle non-ASCII configuration strings",
"config_ascii",
"=",
"configuration",
".",
"encode",
"(",
"'ascii'",
",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SqliteReader.read_all | Fetches all messages in the database.
:rtype: Generator[can.Message] | can/io/sqlite.py | def read_all(self):
"""Fetches all messages in the database.
:rtype: Generator[can.Message]
"""
result = self._cursor.execute("SELECT * FROM {}".format(self.table_name)).fetchall()
return (SqliteReader._assemble_message(frame) for frame in result) | def read_all(self):
"""Fetches all messages in the database.
:rtype: Generator[can.Message]
"""
result = self._cursor.execute("SELECT * FROM {}".format(self.table_name)).fetchall()
return (SqliteReader._assemble_message(frame) for frame in result) | [
"Fetches",
"all",
"messages",
"in",
"the",
"database",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/sqlite.py#L79-L85 | [
"def",
"read_all",
"(",
"self",
")",
":",
"result",
"=",
"self",
".",
"_cursor",
".",
"execute",
"(",
"\"SELECT * FROM {}\"",
".",
"format",
"(",
"self",
".",
"table_name",
")",
")",
".",
"fetchall",
"(",
")",
"return",
"(",
"SqliteReader",
".",
"_assemb... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SqliteWriter._create_db | Creates a new databae or opens a connection to an existing one.
.. note::
You can't share sqlite3 connections between threads (by default)
hence we setup the db here. It has the upside of running async. | can/io/sqlite.py | def _create_db(self):
"""Creates a new databae or opens a connection to an existing one.
.. note::
You can't share sqlite3 connections between threads (by default)
hence we setup the db here. It has the upside of running async.
"""
log.debug("Creating sqlite data... | def _create_db(self):
"""Creates a new databae or opens a connection to an existing one.
.. note::
You can't share sqlite3 connections between threads (by default)
hence we setup the db here. It has the upside of running async.
"""
log.debug("Creating sqlite data... | [
"Creates",
"a",
"new",
"databae",
"or",
"opens",
"a",
"connection",
"to",
"an",
"existing",
"one",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/sqlite.py#L157-L182 | [
"def",
"_create_db",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Creating sqlite database\"",
")",
"self",
".",
"_conn",
"=",
"sqlite3",
".",
"connect",
"(",
"self",
".",
"_db_filename",
")",
"# create table structure",
"self",
".",
"_conn",
".",
"cu... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SqliteWriter.stop | Stops the reader an writes all remaining messages to the database. Thus, this
might take a while and block. | can/io/sqlite.py | def stop(self):
"""Stops the reader an writes all remaining messages to the database. Thus, this
might take a while and block.
"""
BufferedReader.stop(self)
self._stop_running_event.set()
self._writer_thread.join()
BaseIOHandler.stop(self) | def stop(self):
"""Stops the reader an writes all remaining messages to the database. Thus, this
might take a while and block.
"""
BufferedReader.stop(self)
self._stop_running_event.set()
self._writer_thread.join()
BaseIOHandler.stop(self) | [
"Stops",
"the",
"reader",
"an",
"writes",
"all",
"remaining",
"messages",
"to",
"the",
"database",
".",
"Thus",
"this",
"might",
"take",
"a",
"while",
"and",
"block",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/sqlite.py#L229-L236 | [
"def",
"stop",
"(",
"self",
")",
":",
"BufferedReader",
".",
"stop",
"(",
"self",
")",
"self",
".",
"_stop_running_event",
".",
"set",
"(",
")",
"self",
".",
"_writer_thread",
".",
"join",
"(",
")",
"BaseIOHandler",
".",
"stop",
"(",
"self",
")"
] | cdc5254d96072df7739263623f3e920628a7d214 |
train | Message._check | Checks if the message parameters are valid.
Assumes that the types are already correct.
:raises ValueError: iff one or more attributes are invalid | can/message.py | def _check(self):
"""Checks if the message parameters are valid.
Assumes that the types are already correct.
:raises ValueError: iff one or more attributes are invalid
"""
if self.timestamp < 0.0:
raise ValueError("the timestamp may not be negative")
if isin... | def _check(self):
"""Checks if the message parameters are valid.
Assumes that the types are already correct.
:raises ValueError: iff one or more attributes are invalid
"""
if self.timestamp < 0.0:
raise ValueError("the timestamp may not be negative")
if isin... | [
"Checks",
"if",
"the",
"message",
"parameters",
"are",
"valid",
".",
"Assumes",
"that",
"the",
"types",
"are",
"already",
"correct",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/message.py#L262-L306 | [
"def",
"_check",
"(",
"self",
")",
":",
"if",
"self",
".",
"timestamp",
"<",
"0.0",
":",
"raise",
"ValueError",
"(",
"\"the timestamp may not be negative\"",
")",
"if",
"isinf",
"(",
"self",
".",
"timestamp",
")",
":",
"raise",
"ValueError",
"(",
"\"the time... | cdc5254d96072df7739263623f3e920628a7d214 |
train | Message.equals | Compares a given message with this one.
:param can.Message other: the message to compare with
:type timestamp_delta: float or int or None
:param timestamp_delta: the maximum difference at which two timestamps are
still considered equal or None to not compare tim... | can/message.py | def equals(self, other, timestamp_delta=1.0e-6):
"""
Compares a given message with this one.
:param can.Message other: the message to compare with
:type timestamp_delta: float or int or None
:param timestamp_delta: the maximum difference at which two timestamps are
... | def equals(self, other, timestamp_delta=1.0e-6):
"""
Compares a given message with this one.
:param can.Message other: the message to compare with
:type timestamp_delta: float or int or None
:param timestamp_delta: the maximum difference at which two timestamps are
... | [
"Compares",
"a",
"given",
"message",
"with",
"this",
"one",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/message.py#L308-L343 | [
"def",
"equals",
"(",
"self",
",",
"other",
",",
"timestamp_delta",
"=",
"1.0e-6",
")",
":",
"# see https://github.com/hardbyte/python-can/pull/413 for a discussion",
"# on why a delta of 1.0e-6 was chosen",
"return",
"(",
"# check for identity first and finish fast",
"self",
"is... | cdc5254d96072df7739263623f3e920628a7d214 |
train | LibraryMixin.map_symbol | Map and return a symbol (function) from a C library. A reference to the
mapped symbol is also held in the instance
:param str func_name:
symbol_name
:param ctypes.c_* restype:
function result type (i.e. ctypes.c_ulong...), defaults to void
:param tuple(ctypes.c_*... | can/ctypesutil.py | def map_symbol(self, func_name, restype=None, argtypes=(), errcheck=None):
"""
Map and return a symbol (function) from a C library. A reference to the
mapped symbol is also held in the instance
:param str func_name:
symbol_name
:param ctypes.c_* restype:
... | def map_symbol(self, func_name, restype=None, argtypes=(), errcheck=None):
"""
Map and return a symbol (function) from a C library. A reference to the
mapped symbol is also held in the instance
:param str func_name:
symbol_name
:param ctypes.c_* restype:
... | [
"Map",
"and",
"return",
"a",
"symbol",
"(",
"function",
")",
"from",
"a",
"C",
"library",
".",
"A",
"reference",
"to",
"the",
"mapped",
"symbol",
"is",
"also",
"held",
"in",
"the",
"instance"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/ctypesutil.py#L23-L53 | [
"def",
"map_symbol",
"(",
"self",
",",
"func_name",
",",
"restype",
"=",
"None",
",",
"argtypes",
"=",
"(",
")",
",",
"errcheck",
"=",
"None",
")",
":",
"if",
"(",
"argtypes",
")",
":",
"prototype",
"=",
"self",
".",
"function_type",
"(",
"restype",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | NeoViBus.get_serial_number | Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str | can/interfaces/ics_neovi/neovi_bus.py | def get_serial_number(device):
"""Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
"""
a0000 = 604661760
if device.SerialNumber >= a0000:
return ics.base36enc(device.Ser... | def get_serial_number(device):
"""Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
"""
a0000 = 604661760
if device.SerialNumber >= a0000:
return ics.base36enc(device.Ser... | [
"Decode",
"(",
"if",
"needed",
")",
"and",
"return",
"the",
"ICS",
"device",
"serial",
"string"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ics_neovi/neovi_bus.py#L164-L174 | [
"def",
"get_serial_number",
"(",
"device",
")",
":",
"a0000",
"=",
"604661760",
"if",
"device",
".",
"SerialNumber",
">=",
"a0000",
":",
"return",
"ics",
".",
"base36enc",
"(",
"device",
".",
"SerialNumber",
")",
"return",
"str",
"(",
"device",
".",
"Seria... | cdc5254d96072df7739263623f3e920628a7d214 |
train | NeoViBus._detect_available_configs | Detect all configurations/channels that this interface could
currently connect with.
:rtype: Iterator[dict]
:return: an iterable of dicts, each being a configuration suitable
for usage in the interface's bus constructor. | can/interfaces/ics_neovi/neovi_bus.py | def _detect_available_configs():
"""Detect all configurations/channels that this interface could
currently connect with.
:rtype: Iterator[dict]
:return: an iterable of dicts, each being a configuration suitable
for usage in the interface's bus constructor.
"""
... | def _detect_available_configs():
"""Detect all configurations/channels that this interface could
currently connect with.
:rtype: Iterator[dict]
:return: an iterable of dicts, each being a configuration suitable
for usage in the interface's bus constructor.
"""
... | [
"Detect",
"all",
"configurations",
"/",
"channels",
"that",
"this",
"interface",
"could",
"currently",
"connect",
"with",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ics_neovi/neovi_bus.py#L181-L202 | [
"def",
"_detect_available_configs",
"(",
")",
":",
"if",
"ics",
"is",
"None",
":",
"return",
"[",
"]",
"try",
":",
"devices",
"=",
"ics",
".",
"find_devices",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"logger",
".",
"debug",
"(",
"\"Failed to dete... | cdc5254d96072df7739263623f3e920628a7d214 |
train | build_can_frame | CAN frame packing/unpacking (see 'struct can_frame' in <linux/can.h>)
/**
* struct can_frame - basic CAN frame structure
* @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above.
* @can_dlc: the data length field of the CAN frame
* @data: the CAN frame payload.
*/
struct c... | can/interfaces/socketcan/socketcan.py | def build_can_frame(msg):
""" CAN frame packing/unpacking (see 'struct can_frame' in <linux/can.h>)
/**
* struct can_frame - basic CAN frame structure
* @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above.
* @can_dlc: the data length field of the CAN frame
* @data: the CAN f... | def build_can_frame(msg):
""" CAN frame packing/unpacking (see 'struct can_frame' in <linux/can.h>)
/**
* struct can_frame - basic CAN frame structure
* @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above.
* @can_dlc: the data length field of the CAN frame
* @data: the CAN f... | [
"CAN",
"frame",
"packing",
"/",
"unpacking",
"(",
"see",
"struct",
"can_frame",
"in",
"<linux",
"/",
"can",
".",
"h",
">",
")",
"/",
"**",
"*",
"struct",
"can_frame",
"-",
"basic",
"CAN",
"frame",
"structure",
"*",
"@can_id",
":",
"the",
"CAN",
"ID",
... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L78-L118 | [
"def",
"build_can_frame",
"(",
"msg",
")",
":",
"can_id",
"=",
"_add_flags_to_can_id",
"(",
"msg",
")",
"flags",
"=",
"0",
"if",
"msg",
".",
"bitrate_switch",
":",
"flags",
"|=",
"CANFD_BRS",
"if",
"msg",
".",
"error_state_indicator",
":",
"flags",
"|=",
"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | create_bcm_socket | create a broadcast manager socket and connect to the given interface | can/interfaces/socketcan/socketcan.py | def create_bcm_socket(channel):
"""create a broadcast manager socket and connect to the given interface"""
s = socket.socket(PF_CAN, socket.SOCK_DGRAM, CAN_BCM)
if HAS_NATIVE_SUPPORT:
s.connect((channel,))
else:
addr = get_addr(s, channel)
libc.connect(s.fileno(), addr, len(addr)... | def create_bcm_socket(channel):
"""create a broadcast manager socket and connect to the given interface"""
s = socket.socket(PF_CAN, socket.SOCK_DGRAM, CAN_BCM)
if HAS_NATIVE_SUPPORT:
s.connect((channel,))
else:
addr = get_addr(s, channel)
libc.connect(s.fileno(), addr, len(addr)... | [
"create",
"a",
"broadcast",
"manager",
"socket",
"and",
"connect",
"to",
"the",
"given",
"interface"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L184-L192 | [
"def",
"create_bcm_socket",
"(",
"channel",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"PF_CAN",
",",
"socket",
".",
"SOCK_DGRAM",
",",
"CAN_BCM",
")",
"if",
"HAS_NATIVE_SUPPORT",
":",
"s",
".",
"connect",
"(",
"(",
"channel",
",",
")",
")",
"el... | cdc5254d96072df7739263623f3e920628a7d214 |
train | send_bcm | Send raw frame to a BCM socket and handle errors. | can/interfaces/socketcan/socketcan.py | def send_bcm(bcm_socket, data):
"""
Send raw frame to a BCM socket and handle errors.
"""
try:
return bcm_socket.send(data)
except OSError as e:
base = "Couldn't send CAN BCM frame. OS Error {}: {}\n".format(e.errno, e.strerror)
if e.errno == errno.EINVAL:
raise ... | def send_bcm(bcm_socket, data):
"""
Send raw frame to a BCM socket and handle errors.
"""
try:
return bcm_socket.send(data)
except OSError as e:
base = "Couldn't send CAN BCM frame. OS Error {}: {}\n".format(e.errno, e.strerror)
if e.errno == errno.EINVAL:
raise ... | [
"Send",
"raw",
"frame",
"to",
"a",
"BCM",
"socket",
"and",
"handle",
"errors",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L195-L214 | [
"def",
"send_bcm",
"(",
"bcm_socket",
",",
"data",
")",
":",
"try",
":",
"return",
"bcm_socket",
".",
"send",
"(",
"data",
")",
"except",
"OSError",
"as",
"e",
":",
"base",
"=",
"\"Couldn't send CAN BCM frame. OS Error {}: {}\\n\"",
".",
"format",
"(",
"e",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | create_socket | Creates a raw CAN socket. The socket will
be returned unbound to any interface. | can/interfaces/socketcan/socketcan.py | def create_socket():
"""Creates a raw CAN socket. The socket will
be returned unbound to any interface.
"""
sock = socket.socket(PF_CAN, socket.SOCK_RAW, CAN_RAW)
log.info('Created a socket')
return sock | def create_socket():
"""Creates a raw CAN socket. The socket will
be returned unbound to any interface.
"""
sock = socket.socket(PF_CAN, socket.SOCK_RAW, CAN_RAW)
log.info('Created a socket')
return sock | [
"Creates",
"a",
"raw",
"CAN",
"socket",
".",
"The",
"socket",
"will",
"be",
"returned",
"unbound",
"to",
"any",
"interface",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L325-L333 | [
"def",
"create_socket",
"(",
")",
":",
"sock",
"=",
"socket",
".",
"socket",
"(",
"PF_CAN",
",",
"socket",
".",
"SOCK_RAW",
",",
"CAN_RAW",
")",
"log",
".",
"info",
"(",
"'Created a socket'",
")",
"return",
"sock"
] | cdc5254d96072df7739263623f3e920628a7d214 |
train | bind_socket | Binds the given socket to the given interface.
:param socket.socket sock:
The socket to be bound
:raises OSError:
If the specified interface isn't found. | can/interfaces/socketcan/socketcan.py | def bind_socket(sock, channel='can0'):
"""
Binds the given socket to the given interface.
:param socket.socket sock:
The socket to be bound
:raises OSError:
If the specified interface isn't found.
"""
log.debug('Binding socket to channel=%s', channel)
if HAS_NATIVE_SUPPORT:
... | def bind_socket(sock, channel='can0'):
"""
Binds the given socket to the given interface.
:param socket.socket sock:
The socket to be bound
:raises OSError:
If the specified interface isn't found.
"""
log.debug('Binding socket to channel=%s', channel)
if HAS_NATIVE_SUPPORT:
... | [
"Binds",
"the",
"given",
"socket",
"to",
"the",
"given",
"interface",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L336-L352 | [
"def",
"bind_socket",
"(",
"sock",
",",
"channel",
"=",
"'can0'",
")",
":",
"log",
".",
"debug",
"(",
"'Binding socket to channel=%s'",
",",
"channel",
")",
"if",
"HAS_NATIVE_SUPPORT",
":",
"sock",
".",
"bind",
"(",
"(",
"channel",
",",
")",
")",
"else",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | capture_message | Captures a message from given socket.
:param socket.socket sock:
The socket to read a message from.
:param bool get_channel:
Find out which channel the message comes from.
:return: The received message, or None on failure. | can/interfaces/socketcan/socketcan.py | def capture_message(sock, get_channel=False):
"""
Captures a message from given socket.
:param socket.socket sock:
The socket to read a message from.
:param bool get_channel:
Find out which channel the message comes from.
:return: The received message, or None on failure.
"""
... | def capture_message(sock, get_channel=False):
"""
Captures a message from given socket.
:param socket.socket sock:
The socket to read a message from.
:param bool get_channel:
Find out which channel the message comes from.
:return: The received message, or None on failure.
"""
... | [
"Captures",
"a",
"message",
"from",
"given",
"socket",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L355-L435 | [
"def",
"capture_message",
"(",
"sock",
",",
"get_channel",
"=",
"False",
")",
":",
"# Fetching the Arb ID, DLC and Data",
"try",
":",
"if",
"get_channel",
":",
"if",
"HAS_NATIVE_SUPPORT",
":",
"cf",
",",
"addr",
"=",
"sock",
".",
"recvfrom",
"(",
"CANFD_MTU",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | CyclicSendTask.stop | Send a TX_DELETE message to cancel this task.
This will delete the entry for the transmission of the CAN-message
with the specified can_id CAN identifier. The message length for the command
TX_DELETE is {[bcm_msg_head]} (only the header). | can/interfaces/socketcan/socketcan.py | def stop(self):
"""Send a TX_DELETE message to cancel this task.
This will delete the entry for the transmission of the CAN-message
with the specified can_id CAN identifier. The message length for the command
TX_DELETE is {[bcm_msg_head]} (only the header).
"""
log.debug... | def stop(self):
"""Send a TX_DELETE message to cancel this task.
This will delete the entry for the transmission of the CAN-message
with the specified can_id CAN identifier. The message length for the command
TX_DELETE is {[bcm_msg_head]} (only the header).
"""
log.debug... | [
"Send",
"a",
"TX_DELETE",
"message",
"to",
"cancel",
"this",
"task",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L275-L285 | [
"def",
"stop",
"(",
"self",
")",
":",
"log",
".",
"debug",
"(",
"\"Stopping periodic task\"",
")",
"stopframe",
"=",
"build_bcm_tx_delete_header",
"(",
"self",
".",
"can_id_with_flags",
",",
"self",
".",
"flags",
")",
"send_bcm",
"(",
"self",
".",
"bcm_socket"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | CyclicSendTask.modify_data | Update the contents of this periodically sent message.
Note the Message must have the same :attr:`~can.Message.arbitration_id`
like the first message. | can/interfaces/socketcan/socketcan.py | def modify_data(self, message):
"""Update the contents of this periodically sent message.
Note the Message must have the same :attr:`~can.Message.arbitration_id`
like the first message.
"""
assert message.arbitration_id == self.can_id, "You cannot modify the can identifier"
... | def modify_data(self, message):
"""Update the contents of this periodically sent message.
Note the Message must have the same :attr:`~can.Message.arbitration_id`
like the first message.
"""
assert message.arbitration_id == self.can_id, "You cannot modify the can identifier"
... | [
"Update",
"the",
"contents",
"of",
"this",
"periodically",
"sent",
"message",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L287-L297 | [
"def",
"modify_data",
"(",
"self",
",",
"message",
")",
":",
"assert",
"message",
".",
"arbitration_id",
"==",
"self",
".",
"can_id",
",",
"\"You cannot modify the can identifier\"",
"self",
".",
"message",
"=",
"message",
"header",
"=",
"build_bcm_update_header",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SocketcanBus.shutdown | Stops all active periodic tasks and closes the socket. | can/interfaces/socketcan/socketcan.py | def shutdown(self):
"""Stops all active periodic tasks and closes the socket."""
self.stop_all_periodic_tasks()
for channel in self._bcm_sockets:
log.debug("Closing bcm socket for channel {}".format(channel))
bcm_socket = self._bcm_sockets[channel]
bcm_socket.... | def shutdown(self):
"""Stops all active periodic tasks and closes the socket."""
self.stop_all_periodic_tasks()
for channel in self._bcm_sockets:
log.debug("Closing bcm socket for channel {}".format(channel))
bcm_socket = self._bcm_sockets[channel]
bcm_socket.... | [
"Stops",
"all",
"active",
"periodic",
"tasks",
"and",
"closes",
"the",
"socket",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L486-L494 | [
"def",
"shutdown",
"(",
"self",
")",
":",
"self",
".",
"stop_all_periodic_tasks",
"(",
")",
"for",
"channel",
"in",
"self",
".",
"_bcm_sockets",
":",
"log",
".",
"debug",
"(",
"\"Closing bcm socket for channel {}\"",
".",
"format",
"(",
"channel",
")",
")",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SocketcanBus.send | Transmit a message to the CAN bus.
:param can.Message msg: A message object.
:param float timeout:
Wait up to this many seconds for the transmit queue to be ready.
If not given, the call may fail immediately.
:raises can.CanError:
if the message could not be... | can/interfaces/socketcan/socketcan.py | def send(self, msg, timeout=None):
"""Transmit a message to the CAN bus.
:param can.Message msg: A message object.
:param float timeout:
Wait up to this many seconds for the transmit queue to be ready.
If not given, the call may fail immediately.
:raises can.Can... | def send(self, msg, timeout=None):
"""Transmit a message to the CAN bus.
:param can.Message msg: A message object.
:param float timeout:
Wait up to this many seconds for the transmit queue to be ready.
If not given, the call may fail immediately.
:raises can.Can... | [
"Transmit",
"a",
"message",
"to",
"the",
"CAN",
"bus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L518-L553 | [
"def",
"send",
"(",
"self",
",",
"msg",
",",
"timeout",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"\"We've been asked to write a message to the bus\"",
")",
"logger_tx",
"=",
"log",
".",
"getChild",
"(",
"\"tx\"",
")",
"logger_tx",
".",
"debug",
"(",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SocketcanBus._send_periodic_internal | Start sending a message at a given period on this bus.
The kernel's broadcast manager will be used.
:param can.Message msg:
Message to transmit
:param float period:
Period in seconds between each message
:param float duration:
The duration to keep se... | can/interfaces/socketcan/socketcan.py | def _send_periodic_internal(self, msg, period, duration=None):
"""Start sending a message at a given period on this bus.
The kernel's broadcast manager will be used.
:param can.Message msg:
Message to transmit
:param float period:
Period in seconds between each ... | def _send_periodic_internal(self, msg, period, duration=None):
"""Start sending a message at a given period on this bus.
The kernel's broadcast manager will be used.
:param can.Message msg:
Message to transmit
:param float period:
Period in seconds between each ... | [
"Start",
"sending",
"a",
"message",
"at",
"a",
"given",
"period",
"on",
"this",
"bus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/socketcan.py#L572-L600 | [
"def",
"_send_periodic_internal",
"(",
"self",
",",
"msg",
",",
"period",
",",
"duration",
"=",
"None",
")",
":",
"bcm_socket",
"=",
"self",
".",
"_get_bcm_socket",
"(",
"msg",
".",
"channel",
"or",
"self",
".",
"channel",
")",
"task",
"=",
"CyclicSendTask... | cdc5254d96072df7739263623f3e920628a7d214 |
train | find_serial_devices | Finds a list of USB devices where the serial number (partially) matches the given string.
:param str serial_matcher (optional):
only device IDs starting with this string are returned
:rtype: List[str] | can/interfaces/usb2can/serial_selector.py | def find_serial_devices(serial_matcher="ED"):
"""
Finds a list of USB devices where the serial number (partially) matches the given string.
:param str serial_matcher (optional):
only device IDs starting with this string are returned
:rtype: List[str]
"""
objWMIService = win32com.client... | def find_serial_devices(serial_matcher="ED"):
"""
Finds a list of USB devices where the serial number (partially) matches the given string.
:param str serial_matcher (optional):
only device IDs starting with this string are returned
:rtype: List[str]
"""
objWMIService = win32com.client... | [
"Finds",
"a",
"list",
"of",
"USB",
"devices",
"where",
"the",
"serial",
"number",
"(",
"partially",
")",
"matches",
"the",
"given",
"string",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/serial_selector.py#L32-L45 | [
"def",
"find_serial_devices",
"(",
"serial_matcher",
"=",
"\"ED\"",
")",
":",
"objWMIService",
"=",
"win32com",
".",
"client",
".",
"Dispatch",
"(",
"\"WbemScripting.SWbemLocator\"",
")",
"objSWbemServices",
"=",
"objWMIService",
".",
"ConnectServer",
"(",
"\".\"",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | find_available_interfaces | Returns the names of all open can/vcan interfaces using
the ``ip link list`` command. If the lookup fails, an error
is logged to the console and an empty list is returned.
:rtype: an iterable of :class:`str` | can/interfaces/socketcan/utils.py | def find_available_interfaces():
"""Returns the names of all open can/vcan interfaces using
the ``ip link list`` command. If the lookup fails, an error
is logged to the console and an empty list is returned.
:rtype: an iterable of :class:`str`
"""
try:
# it might be good to add "type v... | def find_available_interfaces():
"""Returns the names of all open can/vcan interfaces using
the ``ip link list`` command. If the lookup fails, an error
is logged to the console and an empty list is returned.
:rtype: an iterable of :class:`str`
"""
try:
# it might be good to add "type v... | [
"Returns",
"the",
"names",
"of",
"all",
"open",
"can",
"/",
"vcan",
"interfaces",
"using",
"the",
"ip",
"link",
"list",
"command",
".",
"If",
"the",
"lookup",
"fails",
"an",
"error",
"is",
"logged",
"to",
"the",
"console",
"and",
"an",
"empty",
"list",
... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/utils.py#L45-L68 | [
"def",
"find_available_interfaces",
"(",
")",
":",
"try",
":",
"# it might be good to add \"type vcan\", but that might (?) exclude physical can devices",
"command",
"=",
"[",
"\"ip\"",
",",
"\"-o\"",
",",
"\"link\"",
",",
"\"list\"",
",",
"\"up\"",
"]",
"output",
"=",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | error_code_to_str | Converts a given error code (errno) to a useful and human readable string.
:param int code: a possibly invalid/unknown error code
:rtype: str
:returns: a string explaining and containing the given error code, or a string
explaining that the errorcode is unknown if that is the case | can/interfaces/socketcan/utils.py | def error_code_to_str(code):
"""
Converts a given error code (errno) to a useful and human readable string.
:param int code: a possibly invalid/unknown error code
:rtype: str
:returns: a string explaining and containing the given error code, or a string
explaining that the errorcode i... | def error_code_to_str(code):
"""
Converts a given error code (errno) to a useful and human readable string.
:param int code: a possibly invalid/unknown error code
:rtype: str
:returns: a string explaining and containing the given error code, or a string
explaining that the errorcode i... | [
"Converts",
"a",
"given",
"error",
"code",
"(",
"errno",
")",
"to",
"a",
"useful",
"and",
"human",
"readable",
"string",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/socketcan/utils.py#L70-L90 | [
"def",
"error_code_to_str",
"(",
"code",
")",
":",
"try",
":",
"name",
"=",
"errno",
".",
"errorcode",
"[",
"code",
"]",
"except",
"KeyError",
":",
"name",
"=",
"\"UNKNOWN\"",
"try",
":",
"description",
"=",
"os",
".",
"strerror",
"(",
"code",
")",
"ex... | cdc5254d96072df7739263623f3e920628a7d214 |
train | producer | Spam the bus with messages including the data id.
:param int id: the id of the thread/process | examples/virtual_can_demo.py | def producer(id, message_count=16):
"""Spam the bus with messages including the data id.
:param int id: the id of the thread/process
"""
with can.Bus(bustype='socketcan', channel='vcan0') as bus:
for i in range(message_count):
msg = can.Message(arbitration_id=0x0cf02200+id, data=[i... | def producer(id, message_count=16):
"""Spam the bus with messages including the data id.
:param int id: the id of the thread/process
"""
with can.Bus(bustype='socketcan', channel='vcan0') as bus:
for i in range(message_count):
msg = can.Message(arbitration_id=0x0cf02200+id, data=[i... | [
"Spam",
"the",
"bus",
"with",
"messages",
"including",
"the",
"data",
"id",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/examples/virtual_can_demo.py#L14-L26 | [
"def",
"producer",
"(",
"id",
",",
"message_count",
"=",
"16",
")",
":",
"with",
"can",
".",
"Bus",
"(",
"bustype",
"=",
"'socketcan'",
",",
"channel",
"=",
"'vcan0'",
")",
"as",
"bus",
":",
"for",
"i",
"in",
"range",
"(",
"message_count",
")",
":",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | BufferedReader.on_message_received | Append a message to the buffer.
:raises: BufferError
if the reader has already been stopped | can/listener.py | def on_message_received(self, msg):
"""Append a message to the buffer.
:raises: BufferError
if the reader has already been stopped
"""
if self.is_stopped:
raise RuntimeError("reader has already been stopped")
else:
self.buffer.put(msg) | def on_message_received(self, msg):
"""Append a message to the buffer.
:raises: BufferError
if the reader has already been stopped
"""
if self.is_stopped:
raise RuntimeError("reader has already been stopped")
else:
self.buffer.put(msg) | [
"Append",
"a",
"message",
"to",
"the",
"buffer",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/listener.py#L103-L112 | [
"def",
"on_message_received",
"(",
"self",
",",
"msg",
")",
":",
"if",
"self",
".",
"is_stopped",
":",
"raise",
"RuntimeError",
"(",
"\"reader has already been stopped\"",
")",
"else",
":",
"self",
".",
"buffer",
".",
"put",
"(",
"msg",
")"
] | cdc5254d96072df7739263623f3e920628a7d214 |
train | BufferedReader.get_message | Attempts to retrieve the latest message received by the instance. If no message is
available it blocks for given timeout or until a message is received, or else
returns None (whichever is shorter). This method does not block after
:meth:`can.BufferedReader.stop` has been called.
:param ... | can/listener.py | def get_message(self, timeout=0.5):
"""
Attempts to retrieve the latest message received by the instance. If no message is
available it blocks for given timeout or until a message is received, or else
returns None (whichever is shorter). This method does not block after
:meth:`ca... | def get_message(self, timeout=0.5):
"""
Attempts to retrieve the latest message received by the instance. If no message is
available it blocks for given timeout or until a message is received, or else
returns None (whichever is shorter). This method does not block after
:meth:`ca... | [
"Attempts",
"to",
"retrieve",
"the",
"latest",
"message",
"received",
"by",
"the",
"instance",
".",
"If",
"no",
"message",
"is",
"available",
"it",
"blocks",
"for",
"given",
"timeout",
"or",
"until",
"a",
"message",
"is",
"received",
"or",
"else",
"returns",... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/listener.py#L114-L128 | [
"def",
"get_message",
"(",
"self",
",",
"timeout",
"=",
"0.5",
")",
":",
"try",
":",
"return",
"self",
".",
"buffer",
".",
"get",
"(",
"block",
"=",
"not",
"self",
".",
"is_stopped",
",",
"timeout",
"=",
"timeout",
")",
"except",
"Empty",
":",
"retur... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PcanBus._get_formatted_error | Gets the text using the GetErrorText API function.
If the function call succeeds, the translated error is returned. If it fails,
a text describing the current error is returned. Multiple errors may
be present in which case their individual messages are included in the
return string, one ... | can/interfaces/pcan/pcan.py | def _get_formatted_error(self, error):
"""
Gets the text using the GetErrorText API function.
If the function call succeeds, the translated error is returned. If it fails,
a text describing the current error is returned. Multiple errors may
be present in which case their individu... | def _get_formatted_error(self, error):
"""
Gets the text using the GetErrorText API function.
If the function call succeeds, the translated error is returned. If it fails,
a text describing the current error is returned. Multiple errors may
be present in which case their individu... | [
"Gets",
"the",
"text",
"using",
"the",
"GetErrorText",
"API",
"function",
".",
"If",
"the",
"function",
"call",
"succeeds",
"the",
"translated",
"error",
"is",
"returned",
".",
"If",
"it",
"fails",
"a",
"text",
"describing",
"the",
"current",
"error",
"is",
... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/pcan.py#L209-L242 | [
"def",
"_get_formatted_error",
"(",
"self",
",",
"error",
")",
":",
"def",
"bits",
"(",
"n",
")",
":",
"\"\"\"TODO: document\"\"\"",
"while",
"n",
":",
"b",
"=",
"n",
"&",
"(",
"~",
"n",
"+",
"1",
")",
"yield",
"b",
"n",
"^=",
"b",
"stsReturn",
"="... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PcanBus.reset | Command the PCAN driver to reset the bus after an error. | can/interfaces/pcan/pcan.py | def reset(self):
"""
Command the PCAN driver to reset the bus after an error.
"""
status = self.m_objPCANBasic.Reset(self.m_PcanHandle)
return status == PCAN_ERROR_OK | def reset(self):
"""
Command the PCAN driver to reset the bus after an error.
"""
status = self.m_objPCANBasic.Reset(self.m_PcanHandle)
return status == PCAN_ERROR_OK | [
"Command",
"the",
"PCAN",
"driver",
"to",
"reset",
"the",
"bus",
"after",
"an",
"error",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/pcan.py#L260-L265 | [
"def",
"reset",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"m_objPCANBasic",
".",
"Reset",
"(",
"self",
".",
"m_PcanHandle",
")",
"return",
"status",
"==",
"PCAN_ERROR_OK"
] | cdc5254d96072df7739263623f3e920628a7d214 |
train | PcanBus.flash | Turn on or off flashing of the device's LED for physical
identification purposes. | can/interfaces/pcan/pcan.py | def flash(self, flash):
"""
Turn on or off flashing of the device's LED for physical
identification purposes.
"""
self.m_objPCANBasic.SetValue(self.m_PcanHandle, PCAN_CHANNEL_IDENTIFYING, bool(flash)) | def flash(self, flash):
"""
Turn on or off flashing of the device's LED for physical
identification purposes.
"""
self.m_objPCANBasic.SetValue(self.m_PcanHandle, PCAN_CHANNEL_IDENTIFYING, bool(flash)) | [
"Turn",
"on",
"or",
"off",
"flashing",
"of",
"the",
"device",
"s",
"LED",
"for",
"physical",
"identification",
"purposes",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/pcan.py#L397-L402 | [
"def",
"flash",
"(",
"self",
",",
"flash",
")",
":",
"self",
".",
"m_objPCANBasic",
".",
"SetValue",
"(",
"self",
".",
"m_PcanHandle",
",",
"PCAN_CHANNEL_IDENTIFYING",
",",
"bool",
"(",
"flash",
")",
")"
] | cdc5254d96072df7739263623f3e920628a7d214 |
train | get_error_message | Convert status code to descriptive string. | can/interfaces/nican.py | def get_error_message(status_code):
"""Convert status code to descriptive string."""
errmsg = ctypes.create_string_buffer(1024)
nican.ncStatusToString(status_code, len(errmsg), errmsg)
return errmsg.value.decode("ascii") | def get_error_message(status_code):
"""Convert status code to descriptive string."""
errmsg = ctypes.create_string_buffer(1024)
nican.ncStatusToString(status_code, len(errmsg), errmsg)
return errmsg.value.decode("ascii") | [
"Convert",
"status",
"code",
"to",
"descriptive",
"string",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/nican.py#L86-L90 | [
"def",
"get_error_message",
"(",
"status_code",
")",
":",
"errmsg",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"1024",
")",
"nican",
".",
"ncStatusToString",
"(",
"status_code",
",",
"len",
"(",
"errmsg",
")",
",",
"errmsg",
")",
"return",
"errmsg",
".... | cdc5254d96072df7739263623f3e920628a7d214 |
train | NicanBus._recv_internal | Read a message from a NI-CAN bus.
:param float timeout:
Max time to wait in seconds or None if infinite
:raises can.interfaces.nican.NicanError:
If reception fails | can/interfaces/nican.py | def _recv_internal(self, timeout):
"""
Read a message from a NI-CAN bus.
:param float timeout:
Max time to wait in seconds or None if infinite
:raises can.interfaces.nican.NicanError:
If reception fails
"""
if timeout is None:
timeout... | def _recv_internal(self, timeout):
"""
Read a message from a NI-CAN bus.
:param float timeout:
Max time to wait in seconds or None if infinite
:raises can.interfaces.nican.NicanError:
If reception fails
"""
if timeout is None:
timeout... | [
"Read",
"a",
"message",
"from",
"a",
"NI",
"-",
"CAN",
"bus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/nican.py#L208-L252 | [
"def",
"_recv_internal",
"(",
"self",
",",
"timeout",
")",
":",
"if",
"timeout",
"is",
"None",
":",
"timeout",
"=",
"NC_DURATION_INFINITE",
"else",
":",
"timeout",
"=",
"int",
"(",
"timeout",
"*",
"1000",
")",
"state",
"=",
"ctypes",
".",
"c_ulong",
"(",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | NicanBus.send | Send a message to NI-CAN.
:param can.Message msg:
Message to send
:raises can.interfaces.nican.NicanError:
If writing to transmit buffer fails.
It does not wait for message to be ACKed currently. | can/interfaces/nican.py | def send(self, msg, timeout=None):
"""
Send a message to NI-CAN.
:param can.Message msg:
Message to send
:raises can.interfaces.nican.NicanError:
If writing to transmit buffer fails.
It does not wait for message to be ACKed currently.
"""
... | def send(self, msg, timeout=None):
"""
Send a message to NI-CAN.
:param can.Message msg:
Message to send
:raises can.interfaces.nican.NicanError:
If writing to transmit buffer fails.
It does not wait for message to be ACKed currently.
"""
... | [
"Send",
"a",
"message",
"to",
"NI",
"-",
"CAN",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/nican.py#L254-L273 | [
"def",
"send",
"(",
"self",
",",
"msg",
",",
"timeout",
"=",
"None",
")",
":",
"arb_id",
"=",
"msg",
".",
"arbitration_id",
"if",
"msg",
".",
"is_extended_id",
":",
"arb_id",
"|=",
"NC_FL_CAN_ARBID_XTD",
"raw_msg",
"=",
"TxMessageStruct",
"(",
"arb_id",
",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | NicanBus.set_filters | Unsupported. See note on :class:`~can.interfaces.nican.NicanBus`. | can/interfaces/nican.py | def set_filters(self, can_filers=None):
"""Unsupported. See note on :class:`~can.interfaces.nican.NicanBus`.
"""
if self.__set_filters_has_been_called:
logger.warn("using filters is not supported like this, see note on NicanBus")
else:
# allow the constructor to c... | def set_filters(self, can_filers=None):
"""Unsupported. See note on :class:`~can.interfaces.nican.NicanBus`.
"""
if self.__set_filters_has_been_called:
logger.warn("using filters is not supported like this, see note on NicanBus")
else:
# allow the constructor to c... | [
"Unsupported",
".",
"See",
"note",
"on",
":",
"class",
":",
"~can",
".",
"interfaces",
".",
"nican",
".",
"NicanBus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/nican.py#L297-L304 | [
"def",
"set_filters",
"(",
"self",
",",
"can_filers",
"=",
"None",
")",
":",
"if",
"self",
".",
"__set_filters_has_been_called",
":",
"logger",
".",
"warn",
"(",
"\"using filters is not supported like this, see note on NicanBus\"",
")",
"else",
":",
"# allow the constru... | cdc5254d96072df7739263623f3e920628a7d214 |
train | send_periodic | Send a :class:`~can.Message` every `period` seconds on the given bus.
:param can.BusABC bus: A CAN bus which supports sending.
:param can.Message message: Message to send periodically.
:param float period: The minimum time between sending messages.
:return: A started task instance | can/broadcastmanager.py | def send_periodic(bus, message, period, *args, **kwargs):
"""
Send a :class:`~can.Message` every `period` seconds on the given bus.
:param can.BusABC bus: A CAN bus which supports sending.
:param can.Message message: Message to send periodically.
:param float period: The minimum time between sendin... | def send_periodic(bus, message, period, *args, **kwargs):
"""
Send a :class:`~can.Message` every `period` seconds on the given bus.
:param can.BusABC bus: A CAN bus which supports sending.
:param can.Message message: Message to send periodically.
:param float period: The minimum time between sendin... | [
"Send",
"a",
":",
"class",
":",
"~can",
".",
"Message",
"every",
"period",
"seconds",
"on",
"the",
"given",
"bus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/broadcastmanager.py#L147-L158 | [
"def",
"send_periodic",
"(",
"bus",
",",
"message",
",",
"period",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"warnings",
".",
"warn",
"(",
"\"The function `can.send_periodic` is deprecated and will \"",
"+",
"\"be removed in an upcoming version. Please use `c... | cdc5254d96072df7739263623f3e920628a7d214 |
train | KvaserBus._recv_internal | Read a message from kvaser device and return whether filtering has taken place. | can/interfaces/kvaser/canlib.py | def _recv_internal(self, timeout=None):
"""
Read a message from kvaser device and return whether filtering has taken place.
"""
arb_id = ctypes.c_long(0)
data = ctypes.create_string_buffer(64)
dlc = ctypes.c_uint(0)
flags = ctypes.c_uint(0)
timestamp = cty... | def _recv_internal(self, timeout=None):
"""
Read a message from kvaser device and return whether filtering has taken place.
"""
arb_id = ctypes.c_long(0)
data = ctypes.create_string_buffer(64)
dlc = ctypes.c_uint(0)
flags = ctypes.c_uint(0)
timestamp = cty... | [
"Read",
"a",
"message",
"from",
"kvaser",
"device",
"and",
"return",
"whether",
"filtering",
"has",
"taken",
"place",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/kvaser/canlib.py#L482-L536 | [
"def",
"_recv_internal",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"arb_id",
"=",
"ctypes",
".",
"c_long",
"(",
"0",
")",
"data",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"64",
")",
"dlc",
"=",
"ctypes",
".",
"c_uint",
"(",
"0",
")"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | KvaserBus.flash | Turn on or off flashing of the device's LED for physical
identification purposes. | can/interfaces/kvaser/canlib.py | def flash(self, flash=True):
"""
Turn on or off flashing of the device's LED for physical
identification purposes.
"""
if flash:
action = canstat.kvLED_ACTION_ALL_LEDS_ON
else:
action = canstat.kvLED_ACTION_ALL_LEDS_OFF
try:
kv... | def flash(self, flash=True):
"""
Turn on or off flashing of the device's LED for physical
identification purposes.
"""
if flash:
action = canstat.kvLED_ACTION_ALL_LEDS_ON
else:
action = canstat.kvLED_ACTION_ALL_LEDS_OFF
try:
kv... | [
"Turn",
"on",
"or",
"off",
"flashing",
"of",
"the",
"device",
"s",
"LED",
"for",
"physical",
"identification",
"purposes",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/kvaser/canlib.py#L559-L572 | [
"def",
"flash",
"(",
"self",
",",
"flash",
"=",
"True",
")",
":",
"if",
"flash",
":",
"action",
"=",
"canstat",
".",
"kvLED_ACTION_ALL_LEDS_ON",
"else",
":",
"action",
"=",
"canstat",
".",
"kvLED_ACTION_ALL_LEDS_OFF",
"try",
":",
"kvFlashLeds",
"(",
"self",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | KvaserBus.get_stats | Retrieves the bus statistics.
Use like so:
>>> stats = bus.get_stats()
>>> print(stats)
std_data: 0, std_remote: 0, ext_data: 0, ext_remote: 0, err_frame: 0, bus_load: 0.0%, overruns: 0
:returns: bus statistics.
:rtype: can.interfaces.kvaser.structures.BusStatistics | can/interfaces/kvaser/canlib.py | def get_stats(self):
"""Retrieves the bus statistics.
Use like so:
>>> stats = bus.get_stats()
>>> print(stats)
std_data: 0, std_remote: 0, ext_data: 0, ext_remote: 0, err_frame: 0, bus_load: 0.0%, overruns: 0
:returns: bus statistics.
:rtype: can.interfaces.kv... | def get_stats(self):
"""Retrieves the bus statistics.
Use like so:
>>> stats = bus.get_stats()
>>> print(stats)
std_data: 0, std_remote: 0, ext_data: 0, ext_remote: 0, err_frame: 0, bus_load: 0.0%, overruns: 0
:returns: bus statistics.
:rtype: can.interfaces.kv... | [
"Retrieves",
"the",
"bus",
"statistics",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/kvaser/canlib.py#L588-L605 | [
"def",
"get_stats",
"(",
"self",
")",
":",
"canRequestBusStatistics",
"(",
"self",
".",
"_write_handle",
")",
"stats",
"=",
"structures",
".",
"BusStatistics",
"(",
")",
"canGetBusStatistics",
"(",
"self",
".",
"_write_handle",
",",
"ctypes",
".",
"pointer",
"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | __vciFormatErrorExtended | Format a VCI error and attach failed function, decoded HRESULT and arguments
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
:param HRESULT HRESULT:
HRESULT returned by vcinpl call
:pa... | can/interfaces/ixxat/canlib.py | def __vciFormatErrorExtended(library_instance, function, HRESULT, arguments):
""" Format a VCI error and attach failed function, decoded HRESULT and arguments
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
... | def __vciFormatErrorExtended(library_instance, function, HRESULT, arguments):
""" Format a VCI error and attach failed function, decoded HRESULT and arguments
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
... | [
"Format",
"a",
"VCI",
"error",
"and",
"attach",
"failed",
"function",
"decoded",
"HRESULT",
"and",
"arguments",
":",
"param",
"CLibrary",
"library_instance",
":",
"Mapped",
"instance",
"of",
"IXXAT",
"vcinpl",
"library",
":",
"param",
"callable",
"function",
":"... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L62-L79 | [
"def",
"__vciFormatErrorExtended",
"(",
"library_instance",
",",
"function",
",",
"HRESULT",
",",
"arguments",
")",
":",
"#TODO: make sure we don't generate another exception",
"return",
"\"{} - arguments were {}\"",
".",
"format",
"(",
"__vciFormatError",
"(",
"library_insta... | cdc5254d96072df7739263623f3e920628a7d214 |
train | __vciFormatError | Format a VCI error and attach failed function and decoded HRESULT
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
:param HRESULT HRESULT:
HRESULT returned by vcinpl call
:return:
... | can/interfaces/ixxat/canlib.py | def __vciFormatError(library_instance, function, HRESULT):
""" Format a VCI error and attach failed function and decoded HRESULT
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
:param HRESULT HRESULT:... | def __vciFormatError(library_instance, function, HRESULT):
""" Format a VCI error and attach failed function and decoded HRESULT
:param CLibrary library_instance:
Mapped instance of IXXAT vcinpl library
:param callable function:
Failed function
:param HRESULT HRESULT:... | [
"Format",
"a",
"VCI",
"error",
"and",
"attach",
"failed",
"function",
"and",
"decoded",
"HRESULT",
":",
"param",
"CLibrary",
"library_instance",
":",
"Mapped",
"instance",
"of",
"IXXAT",
"vcinpl",
"library",
":",
"param",
"callable",
"function",
":",
"Failed",
... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L82-L96 | [
"def",
"__vciFormatError",
"(",
"library_instance",
",",
"function",
",",
"HRESULT",
")",
":",
"buf",
"=",
"ctypes",
".",
"create_string_buffer",
"(",
"constants",
".",
"VCI_MAX_ERRSTRLEN",
")",
"ctypes",
".",
"memset",
"(",
"buf",
",",
"0",
",",
"constants",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | __check_status | Check the result of a vcinpl function call and raise appropriate exception
in case of an error. Used as errcheck function when mapping C functions
with ctypes.
:param result:
Function call numeric result
:param callable function:
Called function
:param arguments:
... | can/interfaces/ixxat/canlib.py | def __check_status(result, function, arguments):
"""
Check the result of a vcinpl function call and raise appropriate exception
in case of an error. Used as errcheck function when mapping C functions
with ctypes.
:param result:
Function call numeric result
:param callable fun... | def __check_status(result, function, arguments):
"""
Check the result of a vcinpl function call and raise appropriate exception
in case of an error. Used as errcheck function when mapping C functions
with ctypes.
:param result:
Function call numeric result
:param callable fun... | [
"Check",
"the",
"result",
"of",
"a",
"vcinpl",
"function",
"call",
"and",
"raise",
"appropriate",
"exception",
"in",
"case",
"of",
"an",
"error",
".",
"Used",
"as",
"errcheck",
"function",
"when",
"mapping",
"C",
"functions",
"with",
"ctypes",
".",
":",
"p... | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L99-L131 | [
"def",
"__check_status",
"(",
"result",
",",
"function",
",",
"arguments",
")",
":",
"if",
"isinstance",
"(",
"result",
",",
"int",
")",
":",
"# Real return value is an unsigned long",
"result",
"=",
"ctypes",
".",
"c_ulong",
"(",
"result",
")",
".",
"value",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | IXXATBus._recv_internal | Read a message from IXXAT device. | can/interfaces/ixxat/canlib.py | def _recv_internal(self, timeout):
""" Read a message from IXXAT device. """
# TODO: handling CAN error messages?
data_received = False
if timeout == 0:
# Peek without waiting
try:
_canlib.canChannelPeekMessage(self._channel_handle, ctypes.byref(... | def _recv_internal(self, timeout):
""" Read a message from IXXAT device. """
# TODO: handling CAN error messages?
data_received = False
if timeout == 0:
# Peek without waiting
try:
_canlib.canChannelPeekMessage(self._channel_handle, ctypes.byref(... | [
"Read",
"a",
"message",
"from",
"IXXAT",
"device",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L413-L482 | [
"def",
"_recv_internal",
"(",
"self",
",",
"timeout",
")",
":",
"# TODO: handling CAN error messages?",
"data_received",
"=",
"False",
"if",
"timeout",
"==",
"0",
":",
"# Peek without waiting",
"try",
":",
"_canlib",
".",
"canChannelPeekMessage",
"(",
"self",
".",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | IXXATBus._send_periodic_internal | Send a message using built-in cyclic transmit list functionality. | can/interfaces/ixxat/canlib.py | def _send_periodic_internal(self, msg, period, duration=None):
"""Send a message using built-in cyclic transmit list functionality."""
if self._scheduler is None:
self._scheduler = HANDLE()
_canlib.canSchedulerOpen(self._device_handle, self.channel,
... | def _send_periodic_internal(self, msg, period, duration=None):
"""Send a message using built-in cyclic transmit list functionality."""
if self._scheduler is None:
self._scheduler = HANDLE()
_canlib.canSchedulerOpen(self._device_handle, self.channel,
... | [
"Send",
"a",
"message",
"using",
"built",
"-",
"in",
"cyclic",
"transmit",
"list",
"functionality",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L504-L515 | [
"def",
"_send_periodic_internal",
"(",
"self",
",",
"msg",
",",
"period",
",",
"duration",
"=",
"None",
")",
":",
"if",
"self",
".",
"_scheduler",
"is",
"None",
":",
"self",
".",
"_scheduler",
"=",
"HANDLE",
"(",
")",
"_canlib",
".",
"canSchedulerOpen",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | IXXATBus.set_filters | Unsupported. See note on :class:`~can.interfaces.ixxat.IXXATBus`. | can/interfaces/ixxat/canlib.py | def set_filters(self, can_filers=None):
"""Unsupported. See note on :class:`~can.interfaces.ixxat.IXXATBus`.
"""
if self.__set_filters_has_been_called:
log.warn("using filters is not supported like this, see note on IXXATBus")
else:
# allow the constructor to call... | def set_filters(self, can_filers=None):
"""Unsupported. See note on :class:`~can.interfaces.ixxat.IXXATBus`.
"""
if self.__set_filters_has_been_called:
log.warn("using filters is not supported like this, see note on IXXATBus")
else:
# allow the constructor to call... | [
"Unsupported",
".",
"See",
"note",
"on",
":",
"class",
":",
"~can",
".",
"interfaces",
".",
"ixxat",
".",
"IXXATBus",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L526-L533 | [
"def",
"set_filters",
"(",
"self",
",",
"can_filers",
"=",
"None",
")",
":",
"if",
"self",
".",
"__set_filters_has_been_called",
":",
"log",
".",
"warn",
"(",
"\"using filters is not supported like this, see note on IXXATBus\"",
")",
"else",
":",
"# allow the constructo... | cdc5254d96072df7739263623f3e920628a7d214 |
train | CyclicSendTask.start | Start transmitting message (add to list if needed). | can/interfaces/ixxat/canlib.py | def start(self):
"""Start transmitting message (add to list if needed)."""
if self._index is None:
self._index = ctypes.c_uint32()
_canlib.canSchedulerAddMessage(self._scheduler,
self._msg,
self... | def start(self):
"""Start transmitting message (add to list if needed)."""
if self._index is None:
self._index = ctypes.c_uint32()
_canlib.canSchedulerAddMessage(self._scheduler,
self._msg,
self... | [
"Start",
"transmitting",
"message",
"(",
"add",
"to",
"list",
"if",
"needed",
")",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L557-L566 | [
"def",
"start",
"(",
"self",
")",
":",
"if",
"self",
".",
"_index",
"is",
"None",
":",
"self",
".",
"_index",
"=",
"ctypes",
".",
"c_uint32",
"(",
")",
"_canlib",
".",
"canSchedulerAddMessage",
"(",
"self",
".",
"_scheduler",
",",
"self",
".",
"_msg",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | CyclicSendTask.stop | Stop transmitting message (remove from list). | can/interfaces/ixxat/canlib.py | def stop(self):
"""Stop transmitting message (remove from list)."""
# Remove it completely instead of just stopping it to avoid filling up
# the list with permanently stopped messages
_canlib.canSchedulerRemMessage(self._scheduler, self._index)
self._index = None | def stop(self):
"""Stop transmitting message (remove from list)."""
# Remove it completely instead of just stopping it to avoid filling up
# the list with permanently stopped messages
_canlib.canSchedulerRemMessage(self._scheduler, self._index)
self._index = None | [
"Stop",
"transmitting",
"message",
"(",
"remove",
"from",
"list",
")",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ixxat/canlib.py#L572-L577 | [
"def",
"stop",
"(",
"self",
")",
":",
"# Remove it completely instead of just stopping it to avoid filling up",
"# the list with permanently stopped messages",
"_canlib",
".",
"canSchedulerRemMessage",
"(",
"self",
".",
"_scheduler",
",",
"self",
".",
"_index",
")",
"self",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | BLFWriter.log_event | Add an arbitrary message to the log file as a global marker.
:param str text:
The group name of the marker.
:param float timestamp:
Absolute timestamp in Unix timestamp format. If not given, the
marker will be placed along the last message. | can/io/blf.py | def log_event(self, text, timestamp=None):
"""Add an arbitrary message to the log file as a global marker.
:param str text:
The group name of the marker.
:param float timestamp:
Absolute timestamp in Unix timestamp format. If not given, the
marker will be pla... | def log_event(self, text, timestamp=None):
"""Add an arbitrary message to the log file as a global marker.
:param str text:
The group name of the marker.
:param float timestamp:
Absolute timestamp in Unix timestamp format. If not given, the
marker will be pla... | [
"Add",
"an",
"arbitrary",
"message",
"to",
"the",
"log",
"file",
"as",
"a",
"global",
"marker",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/blf.py#L326-L344 | [
"def",
"log_event",
"(",
"self",
",",
"text",
",",
"timestamp",
"=",
"None",
")",
":",
"try",
":",
"# Only works on Windows",
"text",
"=",
"text",
".",
"encode",
"(",
"\"mbcs\"",
")",
"except",
"LookupError",
":",
"text",
"=",
"text",
".",
"encode",
"(",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | BLFWriter._flush | Compresses and writes data in the cache to file. | can/io/blf.py | def _flush(self):
"""Compresses and writes data in the cache to file."""
if self.file.closed:
return
cache = b"".join(self.cache)
if not cache:
# Nothing to write
return
uncompressed_data = cache[:self.MAX_CACHE_SIZE]
# Save data that c... | def _flush(self):
"""Compresses and writes data in the cache to file."""
if self.file.closed:
return
cache = b"".join(self.cache)
if not cache:
# Nothing to write
return
uncompressed_data = cache[:self.MAX_CACHE_SIZE]
# Save data that c... | [
"Compresses",
"and",
"writes",
"data",
"in",
"the",
"cache",
"to",
"file",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/blf.py#L371-L398 | [
"def",
"_flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"file",
".",
"closed",
":",
"return",
"cache",
"=",
"b\"\"",
".",
"join",
"(",
"self",
".",
"cache",
")",
"if",
"not",
"cache",
":",
"# Nothing to write",
"return",
"uncompressed_data",
"=",
"c... | cdc5254d96072df7739263623f3e920628a7d214 |
train | BLFWriter.stop | Stops logging and closes the file. | can/io/blf.py | def stop(self):
"""Stops logging and closes the file."""
self._flush()
filesize = self.file.tell()
super(BLFWriter, self).stop()
# Write header in the beginning of the file
header = [b"LOGG", FILE_HEADER_SIZE,
APPLICATION_ID, 0, 0, 0, 2, 6, 8, 1]
... | def stop(self):
"""Stops logging and closes the file."""
self._flush()
filesize = self.file.tell()
super(BLFWriter, self).stop()
# Write header in the beginning of the file
header = [b"LOGG", FILE_HEADER_SIZE,
APPLICATION_ID, 0, 0, 0, 2, 6, 8, 1]
... | [
"Stops",
"logging",
"and",
"closes",
"the",
"file",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/blf.py#L400-L415 | [
"def",
"stop",
"(",
"self",
")",
":",
"self",
".",
"_flush",
"(",
")",
"filesize",
"=",
"self",
".",
"file",
".",
"tell",
"(",
")",
"super",
"(",
"BLFWriter",
",",
"self",
")",
".",
"stop",
"(",
")",
"# Write header in the beginning of the file",
"header... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.Initialize | Initializes a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Btr0Btr1 : The speed for the communication (BTR0BTR1 code)
HwType : NON PLUG&PLAY: The type of hardware and operation mode
IOPort : NON PLUG&PLAY: The I/O address for the para... | can/interfaces/pcan/basic.py | def Initialize(
self,
Channel,
Btr0Btr1,
HwType = TPCANType(0),
IOPort = c_uint(0),
Interrupt = c_ushort(0)):
"""
Initializes a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Btr0Btr1 : The spe... | def Initialize(
self,
Channel,
Btr0Btr1,
HwType = TPCANType(0),
IOPort = c_uint(0),
Interrupt = c_ushort(0)):
"""
Initializes a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Btr0Btr1 : The spe... | [
"Initializes",
"a",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L367-L393 | [
"def",
"Initialize",
"(",
"self",
",",
"Channel",
",",
"Btr0Btr1",
",",
"HwType",
"=",
"TPCANType",
"(",
"0",
")",
",",
"IOPort",
"=",
"c_uint",
"(",
"0",
")",
",",
"Interrupt",
"=",
"c_ushort",
"(",
"0",
")",
")",
":",
"try",
":",
"res",
"=",
"s... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.InitializeFD | Initializes a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
BitrateFD : The speed for the communication (FD bit rate string)
Remarks:
See PCAN_BR_* values.
* parameter and values must be separated by '='
* Couples of Pa... | can/interfaces/pcan/basic.py | def InitializeFD(
self,
Channel,
BitrateFD):
"""
Initializes a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
BitrateFD : The speed for the communication (FD bit rate string)
Remarks:
See PCAN_BR_*... | def InitializeFD(
self,
Channel,
BitrateFD):
"""
Initializes a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
BitrateFD : The speed for the communication (FD bit rate string)
Remarks:
See PCAN_BR_*... | [
"Initializes",
"a",
"FD",
"capable",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L395-L426 | [
"def",
"InitializeFD",
"(",
"self",
",",
"Channel",
",",
"BitrateFD",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_InitializeFD",
"(",
"Channel",
",",
"BitrateFD",
")",
"return",
"TPCANStatus",
"(",
"res",
")",
"except",
":",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.Uninitialize | Uninitializes one or all PCAN Channels initialized by CAN_Initialize
Remarks:
Giving the TPCANHandle value "PCAN_NONEBUS", uninitialize all initialized channels
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANStatus error code | can/interfaces/pcan/basic.py | def Uninitialize(
self,
Channel):
"""
Uninitializes one or all PCAN Channels initialized by CAN_Initialize
Remarks:
Giving the TPCANHandle value "PCAN_NONEBUS", uninitialize all initialized channels
Parameters:
Channel : A TPCANHandle representin... | def Uninitialize(
self,
Channel):
"""
Uninitializes one or all PCAN Channels initialized by CAN_Initialize
Remarks:
Giving the TPCANHandle value "PCAN_NONEBUS", uninitialize all initialized channels
Parameters:
Channel : A TPCANHandle representin... | [
"Uninitializes",
"one",
"or",
"all",
"PCAN",
"Channels",
"initialized",
"by",
"CAN_Initialize"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L428-L449 | [
"def",
"Uninitialize",
"(",
"self",
",",
"Channel",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_Uninitialize",
"(",
"Channel",
")",
"return",
"TPCANStatus",
"(",
"res",
")",
"except",
":",
"logger",
".",
"error",
"(",
"\"Exce... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.Reset | Resets the receive and transmit queues of the PCAN Channel
Remarks:
A reset of the CAN controller is not performed
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANStatus error code | can/interfaces/pcan/basic.py | def Reset(
self,
Channel):
"""
Resets the receive and transmit queues of the PCAN Channel
Remarks:
A reset of the CAN controller is not performed
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANS... | def Reset(
self,
Channel):
"""
Resets the receive and transmit queues of the PCAN Channel
Remarks:
A reset of the CAN controller is not performed
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANS... | [
"Resets",
"the",
"receive",
"and",
"transmit",
"queues",
"of",
"the",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L451-L472 | [
"def",
"Reset",
"(",
"self",
",",
"Channel",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_Reset",
"(",
"Channel",
")",
"return",
"TPCANStatus",
"(",
"res",
")",
"except",
":",
"logger",
".",
"error",
"(",
"\"Exception on PCANB... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.GetStatus | Gets the current status of a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANStatus error code | can/interfaces/pcan/basic.py | def GetStatus(
self,
Channel):
"""
Gets the current status of a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANStatus error code
"""
try:
res = self.__m_dllBasic.CAN_GetSta... | def GetStatus(
self,
Channel):
"""
Gets the current status of a PCAN Channel
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
Returns:
A TPCANStatus error code
"""
try:
res = self.__m_dllBasic.CAN_GetSta... | [
"Gets",
"the",
"current",
"status",
"of",
"a",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L474-L492 | [
"def",
"GetStatus",
"(",
"self",
",",
"Channel",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_GetStatus",
"(",
"Channel",
")",
"return",
"TPCANStatus",
"(",
"res",
")",
"except",
":",
"logger",
".",
"error",
"(",
"\"Exception ... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.Read | Reads a CAN message from the receive queue of a PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the values are:
[0]: A TPCANStatus error code
[1]: A TPCANMsg stru... | can/interfaces/pcan/basic.py | def Read(
self,
Channel):
"""
Reads a CAN message from the receive queue of a PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the values are:
... | def Read(
self,
Channel):
"""
Reads a CAN message from the receive queue of a PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the values are:
... | [
"Reads",
"a",
"CAN",
"message",
"from",
"the",
"receive",
"queue",
"of",
"a",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L494-L526 | [
"def",
"Read",
"(",
"self",
",",
"Channel",
")",
":",
"try",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Darwin'",
":",
"msg",
"=",
"TPCANMsgMac",
"(",
")",
"timestamp",
"=",
"TPCANTimestampMac",
"(",
")",
"else",
":",
"msg",
"=",
"TPCANM... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.ReadFD | Reads a CAN message from the receive queue of a FD capable PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the values are:
[0]: A TPCANStatus error code
[1]: A TP... | can/interfaces/pcan/basic.py | def ReadFD(
self,
Channel):
"""
Reads a CAN message from the receive queue of a FD capable PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the valu... | def ReadFD(
self,
Channel):
"""
Reads a CAN message from the receive queue of a FD capable PCAN Channel
Remarks:
The return value of this method is a 3-touple, where
the first value is the result (TPCANStatus) of the method.
The order of the valu... | [
"Reads",
"a",
"CAN",
"message",
"from",
"the",
"receive",
"queue",
"of",
"a",
"FD",
"capable",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L528-L559 | [
"def",
"ReadFD",
"(",
"self",
",",
"Channel",
")",
":",
"try",
":",
"if",
"platform",
".",
"system",
"(",
")",
"==",
"'Darwin'",
":",
"msg",
"=",
"TPCANMsgFDMac",
"(",
")",
"else",
":",
"msg",
"=",
"TPCANMsgFD",
"(",
")",
"timestamp",
"=",
"TPCANTime... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.Write | Transmits a CAN message
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
MessageBuffer: A TPCANMsg representing the CAN message to be sent
Returns:
A TPCANStatus error code | can/interfaces/pcan/basic.py | def Write(
self,
Channel,
MessageBuffer):
"""
Transmits a CAN message
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
MessageBuffer: A TPCANMsg representing the CAN message to be sent
Returns:
A TPCANStatus e... | def Write(
self,
Channel,
MessageBuffer):
"""
Transmits a CAN message
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
MessageBuffer: A TPCANMsg representing the CAN message to be sent
Returns:
A TPCANStatus e... | [
"Transmits",
"a",
"CAN",
"message"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L561-L581 | [
"def",
"Write",
"(",
"self",
",",
"Channel",
",",
"MessageBuffer",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_Write",
"(",
"Channel",
",",
"byref",
"(",
"MessageBuffer",
")",
")",
"return",
"TPCANStatus",
"(",
"res",
")",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.WriteFD | Transmits a CAN message over a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
MessageBuffer: A TPCANMsgFD buffer with the message to be sent
Returns:
A TPCANStatus error code | can/interfaces/pcan/basic.py | def WriteFD(
self,
Channel,
MessageBuffer):
"""
Transmits a CAN message over a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
MessageBuffer: A TPCANMsgFD buffer with the message to be sent
Return... | def WriteFD(
self,
Channel,
MessageBuffer):
"""
Transmits a CAN message over a FD capable PCAN Channel
Parameters:
Channel : The handle of a FD capable PCAN Channel
MessageBuffer: A TPCANMsgFD buffer with the message to be sent
Return... | [
"Transmits",
"a",
"CAN",
"message",
"over",
"a",
"FD",
"capable",
"PCAN",
"Channel"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L583-L603 | [
"def",
"WriteFD",
"(",
"self",
",",
"Channel",
",",
"MessageBuffer",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_WriteFD",
"(",
"Channel",
",",
"byref",
"(",
"MessageBuffer",
")",
")",
"return",
"TPCANStatus",
"(",
"res",
")"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.FilterMessages | Configures the reception filter
Remarks:
The message filter will be expanded with every call to this function.
If it is desired to reset the filter, please use the 'SetValue' function.
Parameters:
Channel : A TPCANHandle representing a PCAN Channel
FromID : A c... | can/interfaces/pcan/basic.py | def FilterMessages(
self,
Channel,
FromID,
ToID,
Mode):
"""
Configures the reception filter
Remarks:
The message filter will be expanded with every call to this function.
If it is desired to reset the filter, please use the 'SetValu... | def FilterMessages(
self,
Channel,
FromID,
ToID,
Mode):
"""
Configures the reception filter
Remarks:
The message filter will be expanded with every call to this function.
If it is desired to reset the filter, please use the 'SetValu... | [
"Configures",
"the",
"reception",
"filter"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L605-L634 | [
"def",
"FilterMessages",
"(",
"self",
",",
"Channel",
",",
"FromID",
",",
"ToID",
",",
"Mode",
")",
":",
"try",
":",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_FilterMessages",
"(",
"Channel",
",",
"FromID",
",",
"ToID",
",",
"Mode",
")",
"retu... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.GetValue | Retrieves a PCAN Channel value
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel) being used. If a parameter is not available,
a PCAN_ERROR_ILLPARAMTYPE error will be returned.
The return value of this method is a 2-touple, wher... | can/interfaces/pcan/basic.py | def GetValue(
self,
Channel,
Parameter):
"""
Retrieves a PCAN Channel value
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel) being used. If a parameter is not available,
a PCAN_ERROR_ILLPARAMTYP... | def GetValue(
self,
Channel,
Parameter):
"""
Retrieves a PCAN Channel value
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel) being used. If a parameter is not available,
a PCAN_ERROR_ILLPARAMTYP... | [
"Retrieves",
"a",
"PCAN",
"Channel",
"value"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L636-L670 | [
"def",
"GetValue",
"(",
"self",
",",
"Channel",
",",
"Parameter",
")",
":",
"try",
":",
"if",
"Parameter",
"==",
"PCAN_API_VERSION",
"or",
"Parameter",
"==",
"PCAN_HARDWARE_NAME",
"or",
"Parameter",
"==",
"PCAN_CHANNEL_VERSION",
"or",
"Parameter",
"==",
"PCAN_LO... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.SetValue | Returns a descriptive text of a given TPCANStatus error
code, in any desired language
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel) being used. If a parameter is not available,
a PCAN_ERROR_ILLPARAMTYPE error will be returne... | can/interfaces/pcan/basic.py | def SetValue(
self,
Channel,
Parameter,
Buffer):
"""
Returns a descriptive text of a given TPCANStatus error
code, in any desired language
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel... | def SetValue(
self,
Channel,
Parameter,
Buffer):
"""
Returns a descriptive text of a given TPCANStatus error
code, in any desired language
Remarks:
Parameters can be present or not according with the kind
of Hardware (PCAN Channel... | [
"Returns",
"a",
"descriptive",
"text",
"of",
"a",
"given",
"TPCANStatus",
"error",
"code",
"in",
"any",
"desired",
"language"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L672-L707 | [
"def",
"SetValue",
"(",
"self",
",",
"Channel",
",",
"Parameter",
",",
"Buffer",
")",
":",
"try",
":",
"if",
"Parameter",
"==",
"PCAN_LOG_LOCATION",
"or",
"Parameter",
"==",
"PCAN_LOG_TEXT",
"or",
"Parameter",
"==",
"PCAN_TRACE_LOCATION",
":",
"mybuffer",
"=",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | PCANBasic.GetErrorText | Configures or sets a PCAN Channel value
Remarks:
The current languages available for translation are:
Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A),
Italian (0x10) and French (0x0C)
The return value of this method is a 2-touple, where
the firs... | can/interfaces/pcan/basic.py | def GetErrorText(
self,
Error,
Language = 0):
"""
Configures or sets a PCAN Channel value
Remarks:
The current languages available for translation are:
Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A),
Italian (0x10) and Fre... | def GetErrorText(
self,
Error,
Language = 0):
"""
Configures or sets a PCAN Channel value
Remarks:
The current languages available for translation are:
Neutral (0x00), German (0x07), English (0x09), Spanish (0x0A),
Italian (0x10) and Fre... | [
"Configures",
"or",
"sets",
"a",
"PCAN",
"Channel",
"value"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/pcan/basic.py#L709-L740 | [
"def",
"GetErrorText",
"(",
"self",
",",
"Error",
",",
"Language",
"=",
"0",
")",
":",
"try",
":",
"mybuffer",
"=",
"create_string_buffer",
"(",
"256",
")",
"res",
"=",
"self",
".",
"__m_dllBasic",
".",
"CAN_GetErrorText",
"(",
"Error",
",",
"Language",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | ASCWriter.log_event | Add a message to the log file.
:param str message: an arbitrary message
:param float timestamp: the absolute timestamp of the event | can/io/asc.py | def log_event(self, message, timestamp=None):
"""Add a message to the log file.
:param str message: an arbitrary message
:param float timestamp: the absolute timestamp of the event
"""
if not message: # if empty or None
logger.debug("ASCWriter: ignoring empty messag... | def log_event(self, message, timestamp=None):
"""Add a message to the log file.
:param str message: an arbitrary message
:param float timestamp: the absolute timestamp of the event
"""
if not message: # if empty or None
logger.debug("ASCWriter: ignoring empty messag... | [
"Add",
"a",
"message",
"to",
"the",
"log",
"file",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/io/asc.py#L164-L194 | [
"def",
"log_event",
"(",
"self",
",",
"message",
",",
"timestamp",
"=",
"None",
")",
":",
"if",
"not",
"message",
":",
"# if empty or None",
"logger",
".",
"debug",
"(",
"\"ASCWriter: ignoring empty message\"",
")",
"return",
"# this is the case for the very first mes... | cdc5254d96072df7739263623f3e920628a7d214 |
train | VirtualBus._detect_available_configs | Returns all currently used channels as well as
one other currently unused channel.
.. note::
This method will run into problems if thousands of
autodetected busses are used at once. | can/interfaces/virtual.py | def _detect_available_configs():
"""
Returns all currently used channels as well as
one other currently unused channel.
.. note::
This method will run into problems if thousands of
autodetected busses are used at once.
"""
with channels_lock:
... | def _detect_available_configs():
"""
Returns all currently used channels as well as
one other currently unused channel.
.. note::
This method will run into problems if thousands of
autodetected busses are used at once.
"""
with channels_lock:
... | [
"Returns",
"all",
"currently",
"used",
"channels",
"as",
"well",
"as",
"one",
"other",
"currently",
"unused",
"channel",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/virtual.py#L116-L141 | [
"def",
"_detect_available_configs",
"(",
")",
":",
"with",
"channels_lock",
":",
"available_channels",
"=",
"list",
"(",
"channels",
".",
"keys",
"(",
")",
")",
"# find a currently unused channel",
"get_extra",
"=",
"lambda",
":",
"\"channel-{}\"",
".",
"format",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | message_convert_rx | convert the message from the CANAL type to pythoncan type | can/interfaces/usb2can/usb2canInterface.py | def message_convert_rx(message_rx):
"""convert the message from the CANAL type to pythoncan type"""
is_extended_id = bool(message_rx.flags & IS_ID_TYPE)
is_remote_frame = bool(message_rx.flags & IS_REMOTE_FRAME)
is_error_frame = bool(message_rx.flags & IS_ERROR_FRAME)
return Message(timestamp=messa... | def message_convert_rx(message_rx):
"""convert the message from the CANAL type to pythoncan type"""
is_extended_id = bool(message_rx.flags & IS_ID_TYPE)
is_remote_frame = bool(message_rx.flags & IS_REMOTE_FRAME)
is_error_frame = bool(message_rx.flags & IS_ERROR_FRAME)
return Message(timestamp=messa... | [
"convert",
"the",
"message",
"from",
"the",
"CANAL",
"type",
"to",
"pythoncan",
"type"
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/usb2canInterface.py#L45-L57 | [
"def",
"message_convert_rx",
"(",
"message_rx",
")",
":",
"is_extended_id",
"=",
"bool",
"(",
"message_rx",
".",
"flags",
"&",
"IS_ID_TYPE",
")",
"is_remote_frame",
"=",
"bool",
"(",
"message_rx",
".",
"flags",
"&",
"IS_REMOTE_FRAME",
")",
"is_error_frame",
"=",... | cdc5254d96072df7739263623f3e920628a7d214 |
train | Usb2canBus.shutdown | Shuts down connection to the device safely.
:raise cam.CanError: is closing the connection did not work | can/interfaces/usb2can/usb2canInterface.py | def shutdown(self):
"""
Shuts down connection to the device safely.
:raise cam.CanError: is closing the connection did not work
"""
status = self.can.close(self.handle)
if status != CANAL_ERROR_SUCCESS:
raise CanError("could not shut down bus: status == {}".... | def shutdown(self):
"""
Shuts down connection to the device safely.
:raise cam.CanError: is closing the connection did not work
"""
status = self.can.close(self.handle)
if status != CANAL_ERROR_SUCCESS:
raise CanError("could not shut down bus: status == {}".... | [
"Shuts",
"down",
"connection",
"to",
"the",
"device",
"safely",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/usb2canInterface.py#L150-L159 | [
"def",
"shutdown",
"(",
"self",
")",
":",
"status",
"=",
"self",
".",
"can",
".",
"close",
"(",
"self",
".",
"handle",
")",
"if",
"status",
"!=",
"CANAL_ERROR_SUCCESS",
":",
"raise",
"CanError",
"(",
"\"could not shut down bus: status == {}\"",
".",
"format",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | Usb2canBus._detect_available_configs | Uses the Windows Management Instrumentation to identify serial devices.
:param str serial_matcher (optional):
search string for automatic detection of the device serial | can/interfaces/usb2can/usb2canInterface.py | def _detect_available_configs(serial_matcher=None):
"""
Uses the Windows Management Instrumentation to identify serial devices.
:param str serial_matcher (optional):
search string for automatic detection of the device serial
"""
if serial_matcher:
channel... | def _detect_available_configs(serial_matcher=None):
"""
Uses the Windows Management Instrumentation to identify serial devices.
:param str serial_matcher (optional):
search string for automatic detection of the device serial
"""
if serial_matcher:
channel... | [
"Uses",
"the",
"Windows",
"Management",
"Instrumentation",
"to",
"identify",
"serial",
"devices",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/usb2can/usb2canInterface.py#L162-L174 | [
"def",
"_detect_available_configs",
"(",
"serial_matcher",
"=",
"None",
")",
":",
"if",
"serial_matcher",
":",
"channels",
"=",
"find_serial_devices",
"(",
"serial_matcher",
")",
"else",
":",
"channels",
"=",
"find_serial_devices",
"(",
")",
"return",
"[",
"{",
... | cdc5254d96072df7739263623f3e920628a7d214 |
train | _get_class_for_interface | Returns the main bus class for the given interface.
:raises:
NotImplementedError if the interface is not known
:raises:
ImportError if there was a problem while importing the
interface or the bus class within that | can/interface.py | def _get_class_for_interface(interface):
"""
Returns the main bus class for the given interface.
:raises:
NotImplementedError if the interface is not known
:raises:
ImportError if there was a problem while importing the
interface or the bus class within that
... | def _get_class_for_interface(interface):
"""
Returns the main bus class for the given interface.
:raises:
NotImplementedError if the interface is not known
:raises:
ImportError if there was a problem while importing the
interface or the bus class within that
... | [
"Returns",
"the",
"main",
"bus",
"class",
"for",
"the",
"given",
"interface",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interface.py#L34-L67 | [
"def",
"_get_class_for_interface",
"(",
"interface",
")",
":",
"# Find the correct backend",
"try",
":",
"module_name",
",",
"class_name",
"=",
"BACKENDS",
"[",
"interface",
"]",
"except",
"KeyError",
":",
"raise",
"NotImplementedError",
"(",
"\"CAN interface '{}' not s... | cdc5254d96072df7739263623f3e920628a7d214 |
train | detect_available_configs | Detect all configurations/channels that the interfaces could
currently connect with.
This might be quite time consuming.
Automated configuration detection may not be implemented by
every interface on every platform. This method will not raise
an error in that case, but with rather return an empty ... | can/interface.py | def detect_available_configs(interfaces=None):
"""Detect all configurations/channels that the interfaces could
currently connect with.
This might be quite time consuming.
Automated configuration detection may not be implemented by
every interface on every platform. This method will not raise
a... | def detect_available_configs(interfaces=None):
"""Detect all configurations/channels that the interfaces could
currently connect with.
This might be quite time consuming.
Automated configuration detection may not be implemented by
every interface on every platform. This method will not raise
a... | [
"Detect",
"all",
"configurations",
"/",
"channels",
"that",
"the",
"interfaces",
"could",
"currently",
"connect",
"with",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interface.py#L130-L183 | [
"def",
"detect_available_configs",
"(",
"interfaces",
"=",
"None",
")",
":",
"# Figure out where to search",
"if",
"interfaces",
"is",
"None",
":",
"# use an iterator over the keys so we do not have to copy it",
"interfaces",
"=",
"BACKENDS",
".",
"keys",
"(",
")",
"elif"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | Notifier.add_bus | Add a bus for notification.
:param can.BusABC bus:
CAN bus instance. | can/notifier.py | def add_bus(self, bus):
"""Add a bus for notification.
:param can.BusABC bus:
CAN bus instance.
"""
if self._loop is not None and hasattr(bus, 'fileno') and bus.fileno() >= 0:
# Use file descriptor to watch for messages
reader = bus.fileno()
... | def add_bus(self, bus):
"""Add a bus for notification.
:param can.BusABC bus:
CAN bus instance.
"""
if self._loop is not None and hasattr(bus, 'fileno') and bus.fileno() >= 0:
# Use file descriptor to watch for messages
reader = bus.fileno()
... | [
"Add",
"a",
"bus",
"for",
"notification",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/notifier.py#L53-L68 | [
"def",
"add_bus",
"(",
"self",
",",
"bus",
")",
":",
"if",
"self",
".",
"_loop",
"is",
"not",
"None",
"and",
"hasattr",
"(",
"bus",
",",
"'fileno'",
")",
"and",
"bus",
".",
"fileno",
"(",
")",
">=",
"0",
":",
"# Use file descriptor to watch for messages"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | Notifier.stop | Stop notifying Listeners when new :class:`~can.Message` objects arrive
and call :meth:`~can.Listener.stop` on each Listener.
:param float timeout:
Max time in seconds to wait for receive threads to finish.
Should be longer than timeout given at instantiation. | can/notifier.py | def stop(self, timeout=5):
"""Stop notifying Listeners when new :class:`~can.Message` objects arrive
and call :meth:`~can.Listener.stop` on each Listener.
:param float timeout:
Max time in seconds to wait for receive threads to finish.
Should be longer than timeout given... | def stop(self, timeout=5):
"""Stop notifying Listeners when new :class:`~can.Message` objects arrive
and call :meth:`~can.Listener.stop` on each Listener.
:param float timeout:
Max time in seconds to wait for receive threads to finish.
Should be longer than timeout given... | [
"Stop",
"notifying",
"Listeners",
"when",
"new",
":",
"class",
":",
"~can",
".",
"Message",
"objects",
"arrive",
"and",
"call",
":",
"meth",
":",
"~can",
".",
"Listener",
".",
"stop",
"on",
"each",
"Listener",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/notifier.py#L70-L90 | [
"def",
"stop",
"(",
"self",
",",
"timeout",
"=",
"5",
")",
":",
"self",
".",
"_running",
"=",
"False",
"end_time",
"=",
"time",
".",
"time",
"(",
")",
"+",
"timeout",
"for",
"reader",
"in",
"self",
".",
"_readers",
":",
"if",
"isinstance",
"(",
"re... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SerialBus.send | Send a message over the serial device.
:param can.Message msg:
Message to send.
.. note:: Flags like ``extended_id``, ``is_remote_frame`` and
``is_error_frame`` will be ignored.
.. note:: If the timestamp is a float value it will be converted
... | can/interfaces/serial/serial_can.py | def send(self, msg, timeout=None):
"""
Send a message over the serial device.
:param can.Message msg:
Message to send.
.. note:: Flags like ``extended_id``, ``is_remote_frame`` and
``is_error_frame`` will be ignored.
.. note:: If the t... | def send(self, msg, timeout=None):
"""
Send a message over the serial device.
:param can.Message msg:
Message to send.
.. note:: Flags like ``extended_id``, ``is_remote_frame`` and
``is_error_frame`` will be ignored.
.. note:: If the t... | [
"Send",
"a",
"message",
"over",
"the",
"serial",
"device",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/serial/serial_can.py#L71-L107 | [
"def",
"send",
"(",
"self",
",",
"msg",
",",
"timeout",
"=",
"None",
")",
":",
"try",
":",
"timestamp",
"=",
"struct",
".",
"pack",
"(",
"'<I'",
",",
"int",
"(",
"msg",
".",
"timestamp",
"*",
"1000",
")",
")",
"except",
"struct",
".",
"error",
":... | cdc5254d96072df7739263623f3e920628a7d214 |
train | SerialBus._recv_internal | Read a message from the serial device.
:param timeout:
.. warning::
This parameter will be ignored. The timeout value of the channel is used.
:returns:
Received message and False (because not filtering as taken place).
.. warning::
... | can/interfaces/serial/serial_can.py | def _recv_internal(self, timeout):
"""
Read a message from the serial device.
:param timeout:
.. warning::
This parameter will be ignored. The timeout value of the channel is used.
:returns:
Received message and False (because not filtering as t... | def _recv_internal(self, timeout):
"""
Read a message from the serial device.
:param timeout:
.. warning::
This parameter will be ignored. The timeout value of the channel is used.
:returns:
Received message and False (because not filtering as t... | [
"Read",
"a",
"message",
"from",
"the",
"serial",
"device",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/serial/serial_can.py#L109-L156 | [
"def",
"_recv_internal",
"(",
"self",
",",
"timeout",
")",
":",
"try",
":",
"# ser.read can return an empty string",
"# or raise a SerialException",
"rx_byte",
"=",
"self",
".",
"ser",
".",
"read",
"(",
")",
"except",
"serial",
".",
"SerialException",
":",
"return... | cdc5254d96072df7739263623f3e920628a7d214 |
train | simple_periodic_send | Sends a message every 20ms with no explicit timeout
Sleeps for 2 seconds then stops the task. | examples/cyclic.py | def simple_periodic_send(bus):
"""
Sends a message every 20ms with no explicit timeout
Sleeps for 2 seconds then stops the task.
"""
print("Starting to send a message every 200ms for 2s")
msg = can.Message(arbitration_id=0x123, data=[1, 2, 3, 4, 5, 6], is_extended_id=False)
task = bus.send_p... | def simple_periodic_send(bus):
"""
Sends a message every 20ms with no explicit timeout
Sleeps for 2 seconds then stops the task.
"""
print("Starting to send a message every 200ms for 2s")
msg = can.Message(arbitration_id=0x123, data=[1, 2, 3, 4, 5, 6], is_extended_id=False)
task = bus.send_p... | [
"Sends",
"a",
"message",
"every",
"20ms",
"with",
"no",
"explicit",
"timeout",
"Sleeps",
"for",
"2",
"seconds",
"then",
"stops",
"the",
"task",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/examples/cyclic.py#L23-L34 | [
"def",
"simple_periodic_send",
"(",
"bus",
")",
":",
"print",
"(",
"\"Starting to send a message every 200ms for 2s\"",
")",
"msg",
"=",
"can",
".",
"Message",
"(",
"arbitration_id",
"=",
"0x123",
",",
"data",
"=",
"[",
"1",
",",
"2",
",",
"3",
",",
"4",
"... | cdc5254d96072df7739263623f3e920628a7d214 |
train | UcanBus.send | Sends one CAN message.
When a transmission timeout is set the firmware tries to send
a message within this timeout. If it could not be sent the firmware sets
the "auto delete" state. Within this state all transmit CAN messages for
this channel will be deleted automatically for not block... | can/interfaces/systec/ucanbus.py | def send(self, msg, timeout=None):
"""
Sends one CAN message.
When a transmission timeout is set the firmware tries to send
a message within this timeout. If it could not be sent the firmware sets
the "auto delete" state. Within this state all transmit CAN messages for
t... | def send(self, msg, timeout=None):
"""
Sends one CAN message.
When a transmission timeout is set the firmware tries to send
a message within this timeout. If it could not be sent the firmware sets
the "auto delete" state. Within this state all transmit CAN messages for
t... | [
"Sends",
"one",
"CAN",
"message",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucanbus.py#L149-L176 | [
"def",
"send",
"(",
"self",
",",
"msg",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"timeout",
"is",
"not",
"None",
"and",
"timeout",
">=",
"0",
":",
"self",
".",
"_ucan",
".",
"set_tx_timeout",
"(",
"self",
".",
"channel",
",",
"int",
"(",
"timeo... | cdc5254d96072df7739263623f3e920628a7d214 |
train | UcanBus.flush_tx_buffer | Flushes the transmit buffer.
:raises can.CanError:
If flushing of the transmit buffer failed. | can/interfaces/systec/ucanbus.py | def flush_tx_buffer(self):
"""
Flushes the transmit buffer.
:raises can.CanError:
If flushing of the transmit buffer failed.
"""
log.info('Flushing transmit buffer')
self._ucan.reset_can(self.channel, ResetFlags.RESET_ONLY_TX_BUFF) | def flush_tx_buffer(self):
"""
Flushes the transmit buffer.
:raises can.CanError:
If flushing of the transmit buffer failed.
"""
log.info('Flushing transmit buffer')
self._ucan.reset_can(self.channel, ResetFlags.RESET_ONLY_TX_BUFF) | [
"Flushes",
"the",
"transmit",
"buffer",
"."
] | hardbyte/python-can | python | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/systec/ucanbus.py#L206-L214 | [
"def",
"flush_tx_buffer",
"(",
"self",
")",
":",
"log",
".",
"info",
"(",
"'Flushing transmit buffer'",
")",
"self",
".",
"_ucan",
".",
"reset_can",
"(",
"self",
".",
"channel",
",",
"ResetFlags",
".",
"RESET_ONLY_TX_BUFF",
")"
] | cdc5254d96072df7739263623f3e920628a7d214 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.