##// END OF EJS Templates
imanay -
r117:118
parent child
Show More
@@ -1,224 +1,227
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <?fileVersion 4.0.0?>
2 <?fileVersion 4.0.0?>
3
3
4 <cproject>
4 <cproject>
5 <storageModule moduleId="org.eclipse.cdt.core.settings">
5 <storageModule moduleId="org.eclipse.cdt.core.settings">
6 <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1568263498">
6 <cconfiguration id="cdt.managedbuild.config.gnu.exe.release.1568263498">
7 <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1568263498" moduleId="org.eclipse.cdt.core.settings" name="Release">
7 <storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="cdt.managedbuild.config.gnu.exe.release.1568263498" moduleId="org.eclipse.cdt.core.settings" name="Release">
8 <externalSettings/>
8 <externalSettings/>
9 <extensions>
9 <extensions>
10 <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
10 <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
11 <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
11 <extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12 <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
12 <extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
13 <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
13 <extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
14 <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
14 <extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
15 </extensions>
15 </extensions>
16 </storageModule>
16 </storageModule>
17 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
17 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
18 <configuration artifactName="Control_Module_v1_debug" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1568263498" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
18 <configuration artifactName="tcp_Control_Module" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release,org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe" cleanCommand="rm -rf" description="" id="cdt.managedbuild.config.gnu.exe.release.1568263498" name="Release" parent="cdt.managedbuild.config.gnu.exe.release">
19 <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1568263498." name="/" resourcePath="">
19 <folderInfo id="cdt.managedbuild.config.gnu.exe.release.1568263498." name="/" resourcePath="">
20 <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.785297601" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
20 <toolChain id="cdt.managedbuild.toolchain.gnu.exe.release.785297601" name="Linux GCC" superClass="cdt.managedbuild.toolchain.gnu.exe.release">
21 <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1008424557" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
21 <targetPlatform id="cdt.managedbuild.target.gnu.platform.exe.release.1008424557" name="Debug Platform" superClass="cdt.managedbuild.target.gnu.platform.exe.release"/>
22 <builder buildPath="${workspace_loc:/Control_Module/Release}" id="cdt.managedbuild.target.gnu.builder.exe.release.365458410" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
22 <builder buildPath="${workspace_loc:/Control_Module}" id="cdt.managedbuild.target.gnu.builder.exe.release.365458410" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.exe.release"/>
23 <tool id="cdt.managedbuild.tool.gnu.archiver.base.1343949145" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
23 <tool id="cdt.managedbuild.tool.gnu.archiver.base.1343949145" name="GCC Archiver" superClass="cdt.managedbuild.tool.gnu.archiver.base"/>
24 <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.57926565" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
24 <tool id="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release.57926565" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.exe.release">
25 <option id="gnu.cpp.compiler.exe.release.option.optimization.level.35312113" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
25 <option id="gnu.cpp.compiler.exe.release.option.optimization.level.35312113" name="Optimization Level" superClass="gnu.cpp.compiler.exe.release.option.optimization.level" value="gnu.cpp.compiler.optimization.level.most" valueType="enumerated"/>
26 <option id="gnu.cpp.compiler.exe.release.option.debugging.level.936269591" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
26 <option id="gnu.cpp.compiler.exe.release.option.debugging.level.936269591" name="Debug Level" superClass="gnu.cpp.compiler.exe.release.option.debugging.level" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/>
27 </tool>
27 </tool>
28 <tool command="arm-unknown-linux-gnu-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1796829929" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
28 <tool command="arm-unknown-linux-gnu-gcc" id="cdt.managedbuild.tool.gnu.c.compiler.exe.release.1796829929" name="GCC C Compiler" superClass="cdt.managedbuild.tool.gnu.c.compiler.exe.release">
29 <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.499243164" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
29 <option defaultValue="gnu.c.optimization.level.most" id="gnu.c.compiler.exe.release.option.optimization.level.499243164" name="Optimization Level" superClass="gnu.c.compiler.exe.release.option.optimization.level" valueType="enumerated"/>
30 <option id="gnu.c.compiler.exe.release.option.debugging.level.1960011250" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
30 <option id="gnu.c.compiler.exe.release.option.debugging.level.1960011250" name="Debug Level" superClass="gnu.c.compiler.exe.release.option.debugging.level" value="gnu.c.debugging.level.none" valueType="enumerated"/>
31 <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1347535566" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
31 <inputType id="cdt.managedbuild.tool.gnu.c.compiler.input.1347535566" superClass="cdt.managedbuild.tool.gnu.c.compiler.input"/>
32 </tool>
32 </tool>
33 <tool command="arm-unknown-linux-gnu-gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1288648685" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
33 <tool command="arm-unknown-linux-gnu-gcc" id="cdt.managedbuild.tool.gnu.c.linker.exe.release.1288648685" name="GCC C Linker" superClass="cdt.managedbuild.tool.gnu.c.linker.exe.release">
34 <option id="gnu.c.link.option.libs.1983512541" superClass="gnu.c.link.option.libs" valueType="libs">
35 <listOptionValue builtIn="false" value="m"/>
36 </option>
34 <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.2046701530" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
37 <inputType id="cdt.managedbuild.tool.gnu.c.linker.input.2046701530" superClass="cdt.managedbuild.tool.gnu.c.linker.input">
35 <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
38 <additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
36 <additionalInput kind="additionalinput" paths="$(LIBS)"/>
39 <additionalInput kind="additionalinput" paths="$(LIBS)"/>
37 </inputType>
40 </inputType>
38 <outputType id="cdt.managedbuild.tool.gnu.c.linker.output.439510446" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.output"/>
41 <outputType id="cdt.managedbuild.tool.gnu.c.linker.output.439510446" outputPrefix="" superClass="cdt.managedbuild.tool.gnu.c.linker.output"/>
39 </tool>
42 </tool>
40 <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1068281678" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"/>
43 <tool id="cdt.managedbuild.tool.gnu.cpp.linker.exe.release.1068281678" name="GCC C++ Linker" superClass="cdt.managedbuild.tool.gnu.cpp.linker.exe.release"/>
41 <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.796779267" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
44 <tool id="cdt.managedbuild.tool.gnu.assembler.exe.release.796779267" name="GCC Assembler" superClass="cdt.managedbuild.tool.gnu.assembler.exe.release">
42 <inputType id="cdt.managedbuild.tool.gnu.assembler.input.690094510" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
45 <inputType id="cdt.managedbuild.tool.gnu.assembler.input.690094510" superClass="cdt.managedbuild.tool.gnu.assembler.input"/>
43 </tool>
46 </tool>
44 </toolChain>
47 </toolChain>
45 </folderInfo>
48 </folderInfo>
46 </configuration>
49 </configuration>
47 </storageModule>
50 </storageModule>
48
51
49 <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
52 <storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
50 <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
53 <storageModule moduleId="org.eclipse.cdt.core.language.mapping"/>
51 <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
54 <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
52 <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
55 <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
53 <storageModule moduleId="scannerConfiguration">
56 <storageModule moduleId="scannerConfiguration">
54 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
57 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
55 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
58 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
56 <buildOutputProvider>
59 <buildOutputProvider>
57 <openAction enabled="true" filePath=""/>
60 <openAction enabled="true" filePath=""/>
58 <parser enabled="true"/>
61 <parser enabled="true"/>
59 </buildOutputProvider>
62 </buildOutputProvider>
60 <scannerInfoProvider id="specsFile">
63 <scannerInfoProvider id="specsFile">
61 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
64 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
62 <parser enabled="true"/>
65 <parser enabled="true"/>
63 </scannerInfoProvider>
66 </scannerInfoProvider>
64 </profile>
67 </profile>
65 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
68 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
66 <buildOutputProvider>
69 <buildOutputProvider>
67 <openAction enabled="true" filePath=""/>
70 <openAction enabled="true" filePath=""/>
68 <parser enabled="true"/>
71 <parser enabled="true"/>
69 </buildOutputProvider>
72 </buildOutputProvider>
70 <scannerInfoProvider id="makefileGenerator">
73 <scannerInfoProvider id="makefileGenerator">
71 <runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
74 <runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
72 <parser enabled="true"/>
75 <parser enabled="true"/>
73 </scannerInfoProvider>
76 </scannerInfoProvider>
74 </profile>
77 </profile>
75 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
78 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
76 <buildOutputProvider>
79 <buildOutputProvider>
77 <openAction enabled="true" filePath=""/>
80 <openAction enabled="true" filePath=""/>
78 <parser enabled="true"/>
81 <parser enabled="true"/>
79 </buildOutputProvider>
82 </buildOutputProvider>
80 <scannerInfoProvider id="specsFile">
83 <scannerInfoProvider id="specsFile">
81 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
84 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
82 <parser enabled="true"/>
85 <parser enabled="true"/>
83 </scannerInfoProvider>
86 </scannerInfoProvider>
84 </profile>
87 </profile>
85 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
88 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
86 <buildOutputProvider>
89 <buildOutputProvider>
87 <openAction enabled="true" filePath=""/>
90 <openAction enabled="true" filePath=""/>
88 <parser enabled="true"/>
91 <parser enabled="true"/>
89 </buildOutputProvider>
92 </buildOutputProvider>
90 <scannerInfoProvider id="specsFile">
93 <scannerInfoProvider id="specsFile">
91 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
94 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
92 <parser enabled="true"/>
95 <parser enabled="true"/>
93 </scannerInfoProvider>
96 </scannerInfoProvider>
94 </profile>
97 </profile>
95 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
98 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
96 <buildOutputProvider>
99 <buildOutputProvider>
97 <openAction enabled="true" filePath=""/>
100 <openAction enabled="true" filePath=""/>
98 <parser enabled="true"/>
101 <parser enabled="true"/>
99 </buildOutputProvider>
102 </buildOutputProvider>
100 <scannerInfoProvider id="specsFile">
103 <scannerInfoProvider id="specsFile">
101 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
104 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
102 <parser enabled="true"/>
105 <parser enabled="true"/>
103 </scannerInfoProvider>
106 </scannerInfoProvider>
104 </profile>
107 </profile>
105 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
108 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
106 <buildOutputProvider>
109 <buildOutputProvider>
107 <openAction enabled="true" filePath=""/>
110 <openAction enabled="true" filePath=""/>
108 <parser enabled="true"/>
111 <parser enabled="true"/>
109 </buildOutputProvider>
112 </buildOutputProvider>
110 <scannerInfoProvider id="specsFile">
113 <scannerInfoProvider id="specsFile">
111 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
114 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
112 <parser enabled="true"/>
115 <parser enabled="true"/>
113 </scannerInfoProvider>
116 </scannerInfoProvider>
114 </profile>
117 </profile>
115 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
118 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
116 <buildOutputProvider>
119 <buildOutputProvider>
117 <openAction enabled="true" filePath=""/>
120 <openAction enabled="true" filePath=""/>
118 <parser enabled="true"/>
121 <parser enabled="true"/>
119 </buildOutputProvider>
122 </buildOutputProvider>
120 <scannerInfoProvider id="specsFile">
123 <scannerInfoProvider id="specsFile">
121 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
124 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
122 <parser enabled="true"/>
125 <parser enabled="true"/>
123 </scannerInfoProvider>
126 </scannerInfoProvider>
124 </profile>
127 </profile>
125 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
128 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
126 <buildOutputProvider>
129 <buildOutputProvider>
127 <openAction enabled="true" filePath=""/>
130 <openAction enabled="true" filePath=""/>
128 <parser enabled="true"/>
131 <parser enabled="true"/>
129 </buildOutputProvider>
132 </buildOutputProvider>
130 <scannerInfoProvider id="specsFile">
133 <scannerInfoProvider id="specsFile">
131 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
134 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
132 <parser enabled="true"/>
135 <parser enabled="true"/>
133 </scannerInfoProvider>
136 </scannerInfoProvider>
134 </profile>
137 </profile>
135 <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1568263498;cdt.managedbuild.config.gnu.exe.release.1568263498.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1796829929;cdt.managedbuild.tool.gnu.c.compiler.input.1347535566">
138 <scannerConfigBuildInfo instanceId="cdt.managedbuild.config.gnu.exe.release.1568263498;cdt.managedbuild.config.gnu.exe.release.1568263498.;cdt.managedbuild.tool.gnu.c.compiler.exe.release.1796829929;cdt.managedbuild.tool.gnu.c.compiler.input.1347535566">
136 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
139 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC"/>
137 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
140 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
138 <buildOutputProvider>
141 <buildOutputProvider>
139 <openAction enabled="true" filePath=""/>
142 <openAction enabled="true" filePath=""/>
140 <parser enabled="true"/>
143 <parser enabled="true"/>
141 </buildOutputProvider>
144 </buildOutputProvider>
142 <scannerInfoProvider id="specsFile">
145 <scannerInfoProvider id="specsFile">
143 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
146 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
144 <parser enabled="true"/>
147 <parser enabled="true"/>
145 </scannerInfoProvider>
148 </scannerInfoProvider>
146 </profile>
149 </profile>
147 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
150 <profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
148 <buildOutputProvider>
151 <buildOutputProvider>
149 <openAction enabled="true" filePath=""/>
152 <openAction enabled="true" filePath=""/>
150 <parser enabled="true"/>
153 <parser enabled="true"/>
151 </buildOutputProvider>
154 </buildOutputProvider>
152 <scannerInfoProvider id="makefileGenerator">
155 <scannerInfoProvider id="makefileGenerator">
153 <runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
156 <runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
154 <parser enabled="true"/>
157 <parser enabled="true"/>
155 </scannerInfoProvider>
158 </scannerInfoProvider>
156 </profile>
159 </profile>
157 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
160 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
158 <buildOutputProvider>
161 <buildOutputProvider>
159 <openAction enabled="true" filePath=""/>
162 <openAction enabled="true" filePath=""/>
160 <parser enabled="true"/>
163 <parser enabled="true"/>
161 </buildOutputProvider>
164 </buildOutputProvider>
162 <scannerInfoProvider id="specsFile">
165 <scannerInfoProvider id="specsFile">
163 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
166 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
164 <parser enabled="true"/>
167 <parser enabled="true"/>
165 </scannerInfoProvider>
168 </scannerInfoProvider>
166 </profile>
169 </profile>
167 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
170 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileCPP">
168 <buildOutputProvider>
171 <buildOutputProvider>
169 <openAction enabled="true" filePath=""/>
172 <openAction enabled="true" filePath=""/>
170 <parser enabled="true"/>
173 <parser enabled="true"/>
171 </buildOutputProvider>
174 </buildOutputProvider>
172 <scannerInfoProvider id="specsFile">
175 <scannerInfoProvider id="specsFile">
173 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
176 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
174 <parser enabled="true"/>
177 <parser enabled="true"/>
175 </scannerInfoProvider>
178 </scannerInfoProvider>
176 </profile>
179 </profile>
177 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
180 <profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfileC">
178 <buildOutputProvider>
181 <buildOutputProvider>
179 <openAction enabled="true" filePath=""/>
182 <openAction enabled="true" filePath=""/>
180 <parser enabled="true"/>
183 <parser enabled="true"/>
181 </buildOutputProvider>
184 </buildOutputProvider>
182 <scannerInfoProvider id="specsFile">
185 <scannerInfoProvider id="specsFile">
183 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
186 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
184 <parser enabled="true"/>
187 <parser enabled="true"/>
185 </scannerInfoProvider>
188 </scannerInfoProvider>
186 </profile>
189 </profile>
187 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
190 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
188 <buildOutputProvider>
191 <buildOutputProvider>
189 <openAction enabled="true" filePath=""/>
192 <openAction enabled="true" filePath=""/>
190 <parser enabled="true"/>
193 <parser enabled="true"/>
191 </buildOutputProvider>
194 </buildOutputProvider>
192 <scannerInfoProvider id="specsFile">
195 <scannerInfoProvider id="specsFile">
193 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
196 <runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
194 <parser enabled="true"/>
197 <parser enabled="true"/>
195 </scannerInfoProvider>
198 </scannerInfoProvider>
196 </profile>
199 </profile>
197 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
200 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileCPP">
198 <buildOutputProvider>
201 <buildOutputProvider>
199 <openAction enabled="true" filePath=""/>
202 <openAction enabled="true" filePath=""/>
200 <parser enabled="true"/>
203 <parser enabled="true"/>
201 </buildOutputProvider>
204 </buildOutputProvider>
202 <scannerInfoProvider id="specsFile">
205 <scannerInfoProvider id="specsFile">
203 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
206 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.cpp" command="g++" useDefault="true"/>
204 <parser enabled="true"/>
207 <parser enabled="true"/>
205 </scannerInfoProvider>
208 </scannerInfoProvider>
206 </profile>
209 </profile>
207 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
210 <profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfileC">
208 <buildOutputProvider>
211 <buildOutputProvider>
209 <openAction enabled="true" filePath=""/>
212 <openAction enabled="true" filePath=""/>
210 <parser enabled="true"/>
213 <parser enabled="true"/>
211 </buildOutputProvider>
214 </buildOutputProvider>
212 <scannerInfoProvider id="specsFile">
215 <scannerInfoProvider id="specsFile">
213 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
216 <runAction arguments="-E -P -v -dD ${plugin_state_location}/specs.c" command="gcc" useDefault="true"/>
214 <parser enabled="true"/>
217 <parser enabled="true"/>
215 </scannerInfoProvider>
218 </scannerInfoProvider>
216 </profile>
219 </profile>
217 </scannerConfigBuildInfo>
220 </scannerConfigBuildInfo>
218 </storageModule>
221 </storageModule>
219 </cconfiguration>
222 </cconfiguration>
220 </storageModule>
223 </storageModule>
221 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
224 <storageModule moduleId="cdtBuildSystem" version="4.0.0">
222 <project id="Control_Module.cdt.managedbuild.target.gnu.exe.1941602615" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
225 <project id="Control_Module.cdt.managedbuild.target.gnu.exe.1941602615" name="Executable" projectType="cdt.managedbuild.target.gnu.exe"/>
223 </storageModule>
226 </storageModule>
224 </cproject>
227 </cproject>
@@ -1,81 +1,81
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <projectDescription>
2 <projectDescription>
3 <name>Control_Module</name>
3 <name>Control_Module</name>
4 <comment></comment>
4 <comment></comment>
5 <projects>
5 <projects>
6 </projects>
6 </projects>
7 <buildSpec>
7 <buildSpec>
8 <buildCommand>
8 <buildCommand>
9 <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
9 <name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
10 <triggers>clean,full,incremental,</triggers>
10 <triggers>clean,full,incremental,</triggers>
11 <arguments>
11 <arguments>
12 <dictionary>
12 <dictionary>
13 <key>?name?</key>
13 <key>?name?</key>
14 <value></value>
14 <value></value>
15 </dictionary>
15 </dictionary>
16 <dictionary>
16 <dictionary>
17 <key>org.eclipse.cdt.make.core.append_environment</key>
17 <key>org.eclipse.cdt.make.core.append_environment</key>
18 <value>true</value>
18 <value>true</value>
19 </dictionary>
19 </dictionary>
20 <dictionary>
20 <dictionary>
21 <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
21 <key>org.eclipse.cdt.make.core.autoBuildTarget</key>
22 <value>all</value>
22 <value>all</value>
23 </dictionary>
23 </dictionary>
24 <dictionary>
24 <dictionary>
25 <key>org.eclipse.cdt.make.core.buildArguments</key>
25 <key>org.eclipse.cdt.make.core.buildArguments</key>
26 <value></value>
26 <value></value>
27 </dictionary>
27 </dictionary>
28 <dictionary>
28 <dictionary>
29 <key>org.eclipse.cdt.make.core.buildCommand</key>
29 <key>org.eclipse.cdt.make.core.buildCommand</key>
30 <value>make</value>
30 <value>make</value>
31 </dictionary>
31 </dictionary>
32 <dictionary>
32 <dictionary>
33 <key>org.eclipse.cdt.make.core.buildLocation</key>
33 <key>org.eclipse.cdt.make.core.buildLocation</key>
34 <value>${workspace_loc:/Control_Module/Release}</value>
34 <value>${workspace_loc:/Control_Module}</value>
35 </dictionary>
35 </dictionary>
36 <dictionary>
36 <dictionary>
37 <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
37 <key>org.eclipse.cdt.make.core.cleanBuildTarget</key>
38 <value>clean</value>
38 <value>clean</value>
39 </dictionary>
39 </dictionary>
40 <dictionary>
40 <dictionary>
41 <key>org.eclipse.cdt.make.core.contents</key>
41 <key>org.eclipse.cdt.make.core.contents</key>
42 <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
42 <value>org.eclipse.cdt.make.core.activeConfigSettings</value>
43 </dictionary>
43 </dictionary>
44 <dictionary>
44 <dictionary>
45 <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
45 <key>org.eclipse.cdt.make.core.enableAutoBuild</key>
46 <value>false</value>
46 <value>false</value>
47 </dictionary>
47 </dictionary>
48 <dictionary>
48 <dictionary>
49 <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
49 <key>org.eclipse.cdt.make.core.enableCleanBuild</key>
50 <value>true</value>
50 <value>true</value>
51 </dictionary>
51 </dictionary>
52 <dictionary>
52 <dictionary>
53 <key>org.eclipse.cdt.make.core.enableFullBuild</key>
53 <key>org.eclipse.cdt.make.core.enableFullBuild</key>
54 <value>true</value>
54 <value>true</value>
55 </dictionary>
55 </dictionary>
56 <dictionary>
56 <dictionary>
57 <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
57 <key>org.eclipse.cdt.make.core.fullBuildTarget</key>
58 <value>all</value>
58 <value>all</value>
59 </dictionary>
59 </dictionary>
60 <dictionary>
60 <dictionary>
61 <key>org.eclipse.cdt.make.core.stopOnError</key>
61 <key>org.eclipse.cdt.make.core.stopOnError</key>
62 <value>true</value>
62 <value>true</value>
63 </dictionary>
63 </dictionary>
64 <dictionary>
64 <dictionary>
65 <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
65 <key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
66 <value>true</value>
66 <value>true</value>
67 </dictionary>
67 </dictionary>
68 </arguments>
68 </arguments>
69 </buildCommand>
69 </buildCommand>
70 <buildCommand>
70 <buildCommand>
71 <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
71 <name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
72 <arguments>
72 <arguments>
73 </arguments>
73 </arguments>
74 </buildCommand>
74 </buildCommand>
75 </buildSpec>
75 </buildSpec>
76 <natures>
76 <natures>
77 <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
77 <nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
78 <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
78 <nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
79 <nature>org.eclipse.cdt.core.cnature</nature>
79 <nature>org.eclipse.cdt.core.cnature</nature>
80 </natures>
80 </natures>
81 </projectDescription>
81 </projectDescription>
@@ -1,1023 +1,1030
1 /*
1 /*
2 * Servidor.c
2 * Servidor.c
3 *
3 *
4 * Created on: Nov 3, 2009
4 * Created on: Nov 3, 2009
5 * Author: Jose Francisco Quenta
5 * Author: Jose Francisco Quenta
6 *
6 *
7 * Se implementa:
7 * Se implementa:
8 * -Carga en memoria los apuntes contenidos en un archivo de experimentos: apunte0 -> GPIO
8 * -Carga en memoria los apuntes contenidos en un archivo de experimentos: apunte0 -> GPIO
9 * -Cambio de apunte.
9 * -Cambio de apunte.
10 * -Lectura del estado actual del apunte y grabado del mismo en un archivo
10 * -Lectura del estado actual del apunte y grabado del mismo en un archivo
11 *
11 *
12 * Modified by Iván Manay since Nov 2012
12 * Modified by Iván Manay since Nov 2012
13 * -From UDP to TCP.
13 * -From UDP to TCP.
14 * -Use of a frame for TCP communications with the central control module.
14 * -Use of a frame for TCP communications with the central control module.
15 */
15 */
16
16
17 #include <stdio.h>
17 #include <stdio.h>
18 #include <stdlib.h>
18 #include <stdlib.h>
19 #include <string.h>
19 #include <string.h>
20 #include <unistd.h>
20 #include <unistd.h>
21 #include <errno.h>
21 #include <errno.h>
22
22
23 #include <sys/types.h>
23 #include <sys/types.h>
24 #include <sys/socket.h>
24 #include <sys/socket.h>
25 #include <netinet/in.h>
25 #include <netinet/in.h>
26 #include <arpa/inet.h>
26 #include <arpa/inet.h>
27 #include <netdb.h>
27 #include <netdb.h>
28 #include <time.h>
28 #include <time.h>
29 #include <math.h>
29 #include <math.h>
30
30
31 #include "./Librerias/at91gpio.h"
31 #include "./Librerias/at91gpio.h"
32 //#include "./Librerias/Mensajes.h"
32 //#include "./Librerias/Mensajes.h"
33 #include "./Librerias/at91adc.h"
33 #include "./Librerias/at91adc.h"
34 //clock
34 //clock
35 #include "./Librerias/at91sysclock.h"
35 #include "./Librerias/at91sysclock.h"
36
36
37 #define PUERTO_SERVIDOR 5500
37 #define PUERTO_SERVIDOR 5500
38 #define TAM_BUFFER 1024
38 #define TAM_BUFFER 1024
39
39
40 #define maskc_out PC30+PC28+PC26+PC24+PC22+PC20 //MSB-UP-LSB MSB-DOWN-LSB //APUNTE
40 #define maskc_out PC30+PC28+PC26+PC24+PC22+PC20 //MSB-UP-LSB MSB-DOWN-LSB //APUNTE
41
41
42 #define maskb_in PB16+PB18+PB20+PB30+PB24+PB22 //MSB-UP-LSB MSB-DOWN-LSB //VERIFICACION
42 #define maskb_in PB16+PB18+PB20+PB30+PB24+PB22 //MSB-UP-LSB MSB-DOWN-LSB //VERIFICACION
43
43
44 #define bit_up_2 0x00010000 //Mascara de cada bit a revisar: bit_up_2 es MSB
44 #define bit_up_2 0x00010000 //Mascara de cada bit a revisar: bit_up_2 es MSB
45 #define bit_up_1 0x00040000
45 #define bit_up_1 0x00040000
46 #define bit_up_0 0x00100000
46 #define bit_up_0 0x00100000
47 #define bit_dow_2 0x40000000
47 #define bit_dow_2 0x40000000
48 #define bit_dow_1 0x01000000
48 #define bit_dow_1 0x01000000
49 #define bit_dow_0 0x00400000
49 #define bit_dow_0 0x00400000
50
50
51 #define MyID 11
51 #define MyID 11
52 #define MAXPENDING 5 /* Maximum outstanding connection requests */
52 #define MAXPENDING 5 /* Maximum outstanding connection requests */
53
53
54 //parameters for the name of the output file
54 //parameters for the name of the output file
55 #define FPRE "AD" //prefix for the output file name
55 #define FPRE "AD" //prefix for the output file name
56 #define FEXT ".out" //file extension for the output file
56 #define FEXT ".out" //file extension for the output file
57 #define FNAMELEN 40
57 #define FNAMELEN 40
58
58
59 //ADC parameters
59 //ADC parameters
60 #define REP 1 //defines how many times the data acquisation loop is repeated
60 #define REP 1 //defines how many times the data acquisation loop is repeated
61 #define NSAMPLES 100 //defines how many samples are taken in one data acqu-
61 #define NSAMPLES 100 //defines how many samples are taken in one data acqu-
62 // isation loop
62 // isation loop
63 #define CNVTIME 14.3 //defines how long it takes to get one sample. Value
63 #define CNVTIME 14.3 //defines how long it takes to get one sample. Value
64 // is only needed for the output file, doesn't change
64 // is only needed for the output file, doesn't change
65 // any ADC configurations
65 // any ADC configurations
66 #define UREF 3.3 //Reference Voltage of ADC (max. ADC Voltage)
66 #define UREF 3.3 //Reference Voltage of ADC (max. ADC Voltage)
67 #define ADCRES 1023 //Resolution of ADC (10bit=1023)
67 #define ADCRES 1023 //Resolution of ADC (10bit=1023)
68
68
69
69
70 char *buff_experimento= NULL;
70 char *buff_experimento= NULL;
71
71
72 AT91S_PIO *pioc;
72 AT91S_PIO *pioc;
73 AT91S_PIO *piob;
73 AT91S_PIO *piob;
74
74
75 struct control_module_parameters {
75 struct control_module_parameters {
76 char ID[20];
76 char ID[20];
77 char param2[20];
77 char param2[20];
78 char param3[20];
78 char param3[20];
79 char param4[20];
79 char param4[20];
80 };
80 };
81
81
82 typedef struct control_module_parameters cmp;
82 typedef struct control_module_parameters cmp;
83
83
84 char *header = NULL;
84 char *header = NULL;
85 char *TypeOfInstrument = NULL;
85 char *TypeOfInstrument = NULL;
86 char *iDSource = NULL;
86 char *iDSource = NULL;
87 char *iDDestino = NULL;
87 char *iDDestino = NULL;
88 char *rx_len = NULL;
88 char *rx_len = NULL;
89 char *cmd = NULL;
89 char *cmd = NULL;
90 char *rx_data = NULL;
90 char *rx_data = NULL;
91 char *crc = NULL;
91 char *crc = NULL;
92
92
93 cmp parameters;
93 cmp parameters;
94 /*
94 /*
95 * Zona de declaracion de cabeceras.
95 * Zona de declaracion de cabeceras.
96 */
96 */
97 cmp inicializa_modulo(cmp p);
97 cmp inicializa_modulo(cmp p);
98 int inicializa_ethernet();
98 int inicializa_ethernet();
99 int rxData(int, char*);
99 int rxData(int, char*);
100 void txData(int, char*);
100 void txData(int, char*);
101 void inicializa_gpio();
101 void inicializa_gpio();
102 void procesa_peticion(char *rx_buffer, char *tx_buffer);
102 void procesa_peticion(char *rx_buffer, char *tx_buffer);
103 int cambia_apuntamiento(char *puntero_char);
103 int cambia_apuntamiento(char *puntero_char);
104 int carga_experimento(char *nombre_archivo);
104 int carga_experimento(char *nombre_archivo);
105 char *chequeo_sistema(char *filename, char *numero_muestras);
105 char *chequeo_sistema(char *filename, char *numero_muestras);
106 void recibe_experimento(char *data, char filename[]);
106 void recibe_experimento(char *data, char filename[]);
107 void SplitFrame(char *frame);
107 void SplitFrame(char *frame);
108 void intToStr( int number, char* str );
108 void intToStr( int number, char* str );
109
109
110 //ABS monitoring
110 //ABS monitoring
111 int ABS_monitoreo(int sel_atenuador, int sel_calibracion, float umbral, int pulsewidth);
111 int ABS_monitoreo(int sel_atenuador, int sel_calibracion, float umbral, int pulsewidth);
112
112
113 AT91S_ADC * configADC1(void);
113 AT91S_ADC * configADC1(void);
114 AT91S_ADC * configADC2(void);
114 AT91S_ADC * configADC2(void);
115
115
116 FILE * create_Output(char*, time_t);
116 FILE * create_Output(char*, time_t);
117
117
118 void writeOutput(float resultado, FILE * output);
118 void writeOutput(float resultado, FILE * output);
119
119
120 int checkTx(long int results1[],long int results2[], float umbral, int pulsewidth);
120 int checkTx(long int results1[],long int results2[], float umbral, int pulsewidth);
121
121
122 double mediana(long int *results, unsigned int cuenta);
122 double mediana(long int *results, unsigned int cuenta);
123 float getPhase(long int results1[], long int results2[]);
123 float getPhase(long int results1[], long int results2[]);
124
124
125 int fExists(char *);
125 int fExists(char *);
126 int configCLK();
126 int configCLK();
127 //
127 //
128
128
129 /*
129 /*
130 *
130 *
131 */
131 */
132 int main(){
132 int main(){
133
133
134 int servSocket;
134 int servSocket;
135 int clntSocket;
135 int clntSocket;
136
136
137
137
138 char *rx_buffer = (char *) malloc(TAM_BUFFER);
138 char *rx_buffer = (char *) malloc(TAM_BUFFER);
139 char *tx_buffer = (char *) malloc(TAM_BUFFER);
139 char *tx_buffer = (char *) malloc(TAM_BUFFER);
140 /* Inicializa parametros del modulo*/
140 /* Inicializa parametros del modulo*/
141 parameters = inicializa_modulo(parameters);
141 parameters = inicializa_modulo(parameters);
142 printf("%s\n%s\n%s\n%s\n",parameters.ID, parameters.param2, parameters.param3, parameters.param4);
142 printf("%s\n%s\n%s\n%s\n",parameters.ID, parameters.param2, parameters.param3, parameters.param4);
143 /* Inicializa red*/
143 /* Inicializa red*/
144 servSocket = inicializa_ethernet();
144 servSocket = inicializa_ethernet();
145 /* Inicializamos el puerto GPIO del sistema embebido GSBC-9260S */
145 /* Inicializamos el puerto GPIO del sistema embebido GSBC-9260S */
146 inicializa_gpio();
146 inicializa_gpio();
147
147
148 while(1){
148 while(1){
149 // Recepción TCP de petición
149 // Recepción TCP de petición
150 clntSocket = rxData(servSocket, rx_buffer);
150 clntSocket = rxData(servSocket, rx_buffer);
151 //testpoint
151 //testpoint
152 printf("rx:%s\n",rx_buffer);
152 printf("rx:%s\n",rx_buffer);
153 // Procesamiento de la petición
153 // Procesamiento de la petición
154 procesa_peticion(rx_buffer, tx_buffer);
154 procesa_peticion(rx_buffer, tx_buffer);
155 //testpoint
155 //testpoint
156 printf("tx:%s\n",tx_buffer);
156 printf("tx:%s\n",tx_buffer);
157 // Respuesta del modulo de control
157 // Respuesta del modulo de control
158 txData(clntSocket, tx_buffer);
158 txData(clntSocket, tx_buffer);
159
159
160 }
160 }
161 }
161 }
162
162
163
163
164 int inicializa_ethernet(){
164 int inicializa_ethernet(){
165
165
166 struct sockaddr_in inf_servidor;
166 struct sockaddr_in inf_servidor;
167
167
168 int servSocket;
168 int servSocket;
169
169
170 int resultado;
170 int resultado;
171
171
172 /* Haciendo la estructura local*/
172 /* Haciendo la estructura local*/
173 memset(&inf_servidor, 0, sizeof(inf_servidor));
173 memset(&inf_servidor, 0, sizeof(inf_servidor));
174 inf_servidor.sin_family= AF_INET;
174 inf_servidor.sin_family= AF_INET;
175 inf_servidor.sin_port= htons(PUERTO_SERVIDOR);
175 inf_servidor.sin_port= htons(PUERTO_SERVIDOR);
176 inf_servidor.sin_addr.s_addr= INADDR_ANY;
176 inf_servidor.sin_addr.s_addr= INADDR_ANY;
177
177
178 /* Se establece el socket */
178 /* Se establece el socket */
179 servSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP);
179 servSocket = socket(AF_INET,SOCK_STREAM, IPPROTO_TCP);
180 if (servSocket == -1){
180 if (servSocket == -1){
181 printf("No se establecio correctamente el socket: socket()\n");
181 printf("No se establecio correctamente el socket: socket()\n");
182 //ERROR_FATAL("No se establecio correctamente el socket: socket()\n");
182 //ERROR_FATAL("No se establecio correctamente el socket: socket()\n");
183 exit(-1);
183 exit(-1);
184 }
184 }
185
185
186 /* Se asocia el socket a un puerto y una IP */
186 /* Se asocia el socket a un puerto y una IP */
187 resultado = bind(servSocket,(struct sockaddr *)&inf_servidor,sizeof(inf_servidor));
187 resultado = bind(servSocket,(struct sockaddr *)&inf_servidor,sizeof(inf_servidor));
188 if (resultado== -1){
188 if (resultado== -1){
189 printf("No se establecio correctamente el socket: bind()\n");
189 printf("No se establecio correctamente el socket: bind()\n");
190 //ERROR_FATAL("No se establecio correctamente el socket: bind()\n");
190 //ERROR_FATAL("No se establecio correctamente el socket: bind()\n");
191 exit(-1);
191 exit(-1);
192 }
192 }
193
193
194 if (listen(servSocket, MAXPENDING) < 0){
194 if (listen(servSocket, MAXPENDING) < 0){
195 printf("listen() failed\n");
195 printf("listen() failed\n");
196 exit(-1);
196 exit(-1);
197 }
197 }
198
198
199 return servSocket;
199 return servSocket;
200
200
201 }
201 }
202
202
203 int rxData(int servSocket, char* rx_buffer){
203 int rxData(int servSocket, char* rx_buffer){
204
204
205 int clntSocket;
205 int clntSocket;
206 struct sockaddr_in inf_cliente;
206 struct sockaddr_in inf_cliente;
207 int numbytes_recibidos;
207 int numbytes_recibidos;
208 unsigned int inf_client_Len;
208 unsigned int inf_client_Len;
209
209
210 printf("\nEsperando solicitud de cliente...\n");
210 printf("\nEsperando solicitud de cliente...\n");
211
211
212 /* Set the size of the in-out parameter */
212 /* Set the size of the in-out parameter */
213 inf_client_Len = sizeof(inf_cliente);
213 inf_client_Len = sizeof(inf_cliente);
214 /* Se espera hasta que un cliente se conecte */
214 /* Se espera hasta que un cliente se conecte */
215 if ((clntSocket = accept(servSocket, (struct sockaddr *) &inf_cliente,
215 if ((clntSocket = accept(servSocket, (struct sockaddr *) &inf_cliente,
216 &inf_client_Len)) < 0)
216 &inf_client_Len)) < 0)
217 printf("accept() failed\n");
217 printf("accept() failed\n");
218
218
219 if ((numbytes_recibidos = recv(clntSocket, rx_buffer, TAM_BUFFER, 0)) < 0)
219 if ((numbytes_recibidos = recv(clntSocket, rx_buffer, TAM_BUFFER, 0)) < 0)
220 printf("recv() failed\n");
220 printf("recv() failed\n");
221
221
222 /* Se procede a procesar los datos recibidos */
222 /* Se procede a procesar los datos recibidos */
223 rx_buffer[numbytes_recibidos]= '\0';
223 rx_buffer[numbytes_recibidos]= '\0';
224
224
225 return clntSocket;
225 return clntSocket;
226 }
226 }
227
227
228 void txData(int clntSocket, char* data){
228 void txData(int clntSocket, char* data){
229
229
230 /* Echo message back to client */
230 /* Echo message back to client */
231 if (send(clntSocket, data, strlen(data), 0) != strlen(data))
231 if (send(clntSocket, data, strlen(data), 0) != strlen(data))
232 printf("send() failed\n");
232 printf("send() failed\n");
233
233
234 close(clntSocket); /* Close client socket */
234 close(clntSocket); /* Close client socket */
235 }
235 }
236
236
237 /*
237 /*
238 * Esta funcion incializa el puerto GPIO
238 * Esta funcion incializa el puerto GPIO
239 */
239 */
240 void inicializa_gpio(){
240 void inicializa_gpio(){
241
241
242 // Configuracion de los pines de APUNTE
242 // Configuracion de los pines de APUNTE
243 pioc = pio_map(PIOC_BASE);
243 pioc = pio_map(PIOC_BASE);
244 pio_enable(pioc, maskc_out);
244 pio_enable(pioc, maskc_out);
245 pio_disable_irq(pioc, maskc_out);
245 pio_disable_irq(pioc, maskc_out);
246 pio_disable_multiple_driver(pioc, maskc_out);
246 pio_disable_multiple_driver(pioc, maskc_out);
247 pio_disable_pull_ups(pioc, maskc_out);
247 pio_disable_pull_ups(pioc, maskc_out);
248 pio_synchronous_data_output(pioc, maskc_out);
248 pio_synchronous_data_output(pioc, maskc_out);
249 pio_output_enable(pioc, maskc_out);
249 pio_output_enable(pioc, maskc_out);
250
250
251 // Configuracion de los pines de VERIFICACION
251 // Configuracion de los pines de VERIFICACION
252 piob = pio_map(PIOB_BASE);
252 piob = pio_map(PIOB_BASE);
253 pio_enable(piob, maskb_in);
253 pio_enable(piob, maskb_in);
254 pio_disable_irq(piob, maskb_in);
254 pio_disable_irq(piob, maskb_in);
255 pio_disable_multiple_driver(piob, maskb_in);
255 pio_disable_multiple_driver(piob, maskb_in);
256 pio_disable_pull_ups(piob, maskb_in);
256 pio_disable_pull_ups(piob, maskb_in);
257 pio_input_enable(piob, maskb_in);
257 pio_input_enable(piob, maskb_in);
258 }
258 }
259
259
260
260
261 /*
261 /*
262 * Divide rx frame into the frame components
262 * Divide rx frame into the frame components
263 */
263 */
264 void SplitFrame(char *frame){
264 void SplitFrame(char *frame){
265 header = malloc(4);
265 header = malloc(4);
266 *header = *frame;
266 *header = *frame;
267 *(header + 1) = *(frame + 1);
267 *(header + 1) = *(frame + 1);
268 *(header + 2) = *(frame + 2);
268 *(header + 2) = *(frame + 2);
269 *(header + 3) = '\0';
269 *(header + 3) = '\0';
270 TypeOfInstrument = malloc(4);
270 TypeOfInstrument = malloc(4);
271 *TypeOfInstrument = *(frame + 3);
271 *TypeOfInstrument = *(frame + 3);
272 *(TypeOfInstrument + 1) = *(frame + 4);
272 *(TypeOfInstrument + 1) = *(frame + 4);
273 *(TypeOfInstrument + 2) = *(frame + 5);
273 *(TypeOfInstrument + 2) = *(frame + 5);
274 *(TypeOfInstrument + 3) = '\0';
274 *(TypeOfInstrument + 3) = '\0';
275 iDSource = malloc(8);
275 iDSource = malloc(8);
276 *iDSource = *(frame + 6);
276 *iDSource = *(frame + 6);
277 *(iDSource + 1) = *(frame + 7);
277 *(iDSource + 1) = *(frame + 7);
278 *(iDSource + 2) = *(frame + 8);
278 *(iDSource + 2) = *(frame + 8);
279 *(iDSource + 3) = *(frame + 9);
279 *(iDSource + 3) = *(frame + 9);
280 *(iDSource + 4) = *(frame + 10);
280 *(iDSource + 4) = *(frame + 10);
281 *(iDSource + 5) = *(frame + 11);
281 *(iDSource + 5) = *(frame + 11);
282 *(iDSource + 6) = *(frame + 12);
282 *(iDSource + 6) = *(frame + 12);
283 *(iDSource + 7) = '\0';
283 *(iDSource + 7) = '\0';
284 iDDestino = malloc(8);
284 iDDestino = malloc(8);
285 *iDDestino = *(frame + 13);
285 *iDDestino = *(frame + 13);
286 *(iDDestino + 1) = *(frame + 14);
286 *(iDDestino + 1) = *(frame + 14);
287 *(iDDestino + 2) = *(frame + 15);
287 *(iDDestino + 2) = *(frame + 15);
288 *(iDDestino + 3) = *(frame + 16);
288 *(iDDestino + 3) = *(frame + 16);
289 *(iDDestino + 4) = *(frame + 17);
289 *(iDDestino + 4) = *(frame + 17);
290 *(iDDestino + 5) = *(frame + 18);
290 *(iDDestino + 5) = *(frame + 18);
291 *(iDDestino + 6) = *(frame + 19);
291 *(iDDestino + 6) = *(frame + 19);
292 *(iDDestino + 7) = '\0';
292 *(iDDestino + 7) = '\0';
293 rx_len = malloc(7);
293 rx_len = malloc(7);
294 *rx_len = *(frame + 20);
294 *rx_len = *(frame + 20);
295 *(rx_len + 1) = *(frame + 21);
295 *(rx_len + 1) = *(frame + 21);
296 *(rx_len + 2) = *(frame + 22);
296 *(rx_len + 2) = *(frame + 22);
297 *(rx_len + 3) = *(frame + 23);
297 *(rx_len + 3) = *(frame + 23);
298 *(rx_len + 4) = *(frame + 24);
298 *(rx_len + 4) = *(frame + 24);
299 *(rx_len + 5) = *(frame + 25);
299 *(rx_len + 5) = *(frame + 25);
300 *(rx_len + 6) = '\0';
300 *(rx_len + 6) = '\0';
301 cmd = malloc(5);
301 cmd = malloc(5);
302 *cmd = *(frame + 26);
302 *cmd = *(frame + 26);
303 *(cmd + 1) = *(frame + 27);
303 *(cmd + 1) = *(frame + 27);
304 *(cmd + 2) = *(frame + 28);
304 *(cmd + 2) = *(frame + 28);
305 *(cmd + 3) = *(frame + 29);
305 *(cmd + 3) = *(frame + 29);
306 *(cmd + 4) = '\0';
306 *(cmd + 4) = '\0';
307
307
308 int l = atoi(rx_len);
308 int l = atoi(rx_len);
309 rx_data = malloc(l + 1);
309 rx_data = malloc(l + 1);
310 int i;
310 int i;
311 for (i = 30; i < 30 + l; i++)
311 for (i = 30; i < 30 + l; i++)
312 *(rx_data + (i-30)) = *(frame + i);
312 *(rx_data + (i-30)) = *(frame + i);
313 *(rx_data + l) = '\0';
313 *(rx_data + l) = '\0';
314 crc = malloc(2);
314 crc = malloc(2);
315 *crc = *(frame + 30 + l);
315 *crc = *(frame + 30 + l);
316 *(crc + 1) = '\0';
316 *(crc + 1) = '\0';
317 }
317 }
318
318
319
319
320 /*
320 /*
321 * Esta funcion procesa el mensaje de peticion y genera respuesta
321 * Esta funcion procesa el mensaje de peticion y genera respuesta
322 */
322 */
323 void procesa_peticion(char *rx_buffer, char *tx_buffer){
323 void procesa_peticion(char *rx_buffer, char *tx_buffer){
324 // int n = 0;
324 // int n = 0;
325 char filename1[50];
325 char filename1[50];
326 char filename2[] = "verificacion.txt";
326 char filename2[] = "verificacion.txt";
327 char *tx_data = NULL;
327 char *tx_data = NULL;
328 char *tx_len = NULL;
328 char *tx_len = NULL;
329 SplitFrame(rx_buffer);
329 SplitFrame(rx_buffer);
330
330
331 if ((cmd == NULL) || (rx_data == NULL)){
331 if ((cmd == NULL) || (rx_data == NULL)){
332 printf("procesarPeticion: formato de mensaje incorrecto");
332 printf("procesarPeticion: formato de mensaje incorrecto");
333 //ERROR("procesarPeticion: formato de mensaje incorrecto");
333 //ERROR("procesarPeticion: formato de mensaje incorrecto");
334
334
335 }
335 }
336 else{
336 else{
337 if(strcmp(cmd,"SNDF") == 0){
337 if(strcmp(cmd,"SNDF") == 0){
338 recibe_experimento(rx_data,filename1);
338 recibe_experimento(rx_data,filename1);
339 carga_experimento(filename1);
339 carga_experimento(filename1);
340 cambia_apuntamiento("0");
340 cambia_apuntamiento("0");
341 tx_data = (char*)malloc(3);
341 tx_data = (char*)malloc(3);
342 tx_data = "OK";
342 tx_data = "OK";
343 }
343 }
344 else if(strcmp(cmd,"CHGB") == 0){
344 else if(strcmp(cmd,"CHGB") == 0){
345 cambia_apuntamiento(rx_data);
345 cambia_apuntamiento(rx_data);
346 tx_data = (char*)malloc(3);
346 tx_data = (char*)malloc(3);
347 tx_data = "OK";
347 tx_data = "OK";
348 }
348 }
349 else if(strcmp(cmd,"ANST") == 0){
349 else if(strcmp(cmd,"ANST") == 0){
350 tx_data = chequeo_sistema(filename2,rx_data);
350 tx_data = chequeo_sistema(filename2,rx_data);
351 ABS_monitoreo(1, 1, 50, 10);
351 ABS_monitoreo(1, 1, 50, 10);
352 printf("%s\n",tx_data);
352 printf("%s\n",tx_data);
353 }
353 }
354 else if(strcmp(cmd,"NTST") == 0){
354 else if(strcmp(cmd,"NTST") == 0){
355 tx_data = malloc(strlen(parameters.ID) + 1);
355 tx_data = malloc(strlen(parameters.ID) + 1);
356 strcpy(tx_data,parameters.ID);
356 strcpy(tx_data,parameters.ID);
357 printf("%s\n",tx_data);
357 printf("%s\n",tx_data);
358 }
358 }
359 else{
359 else{
360 tx_data = (char*)malloc(6);
360 tx_data = (char*)malloc(6);
361 tx_data = "Error";
361 tx_data = "Error";
362 printf("procesa_peticion: comando no reconocido");
362 printf("procesa_peticion: comando no reconocido");
363 //ERROR("procesa_peticion: comando no reconocido");
363 //ERROR("procesa_peticion: comando no reconocido");
364 }
364 }
365
365
366 tx_len = malloc(7);
366 tx_len = malloc(7);
367 int number = strlen(tx_data);
367 int number = strlen(tx_data);
368 intToStr(number, tx_len );
368 intToStr(number, tx_len );
369
369
370 strcpy(tx_buffer,header); //3
370 strcpy(tx_buffer,header); //3
371 strcat(tx_buffer,TypeOfInstrument); //3
371 strcat(tx_buffer,TypeOfInstrument); //3
372 strcat(tx_buffer,parameters.ID); //7
372 strcat(tx_buffer,parameters.ID); //7
373 strcat(tx_buffer,iDSource); //7
373 strcat(tx_buffer,iDSource); //7
374 strcat(tx_buffer,tx_len); //6
374 strcat(tx_buffer,tx_len); //6
375 strcat(tx_buffer,cmd); //4
375 strcat(tx_buffer,cmd); //4
376 strcat(tx_buffer,tx_data); //?
376 strcat(tx_buffer,tx_data); //?
377 strcat(tx_buffer,crc); //1
377 strcat(tx_buffer,crc); //1
378
378
379 }
379 }
380
380
381 }
381 }
382
382
383 /*
383 /*
384 * Esta función genera el archivo de experimento a partir de la trama TCP recibida
384 * Esta función genera el archivo de experimento a partir de la trama TCP recibida
385 */
385 */
386 void recibe_experimento(char *p_data, char filename[]){
386 void recibe_experimento(char *p_data, char filename[]){
387 FILE *fd;
387 FILE *fd;
388 int i = 0;
388 int i = 0;
389
389
390 while (*p_data != '\n'){
390 while (*p_data != '\n'){
391 filename[i] = *p_data;
391 filename[i] = *p_data;
392 i++;
392 i++;
393 p_data++;
393 p_data++;
394 }
394 }
395 filename[i] = '\0';
395 filename[i] = '\0';
396 p_data = p_data - i;
396 p_data = p_data - i;
397 fd = fopen(filename,"w");
397 fd = fopen(filename,"w");
398 fprintf(fd, p_data);
398 fprintf(fd, p_data);
399 fclose(fd);
399 fclose(fd);
400 }
400 }
401
401
402 /*
402 /*
403 * Esta funcion carga un archivo en un buffer que esta ubicado en memoria, luego
403 * Esta funcion carga un archivo en un buffer que esta ubicado en memoria, luego
404 * este buffer es usado en la funcion "cambia_apuntamiento" para obtener el dato
404 * este buffer es usado en la funcion "cambia_apuntamiento" para obtener el dato
405 * que sera usado en el cambio de apuntamiento.
405 * que sera usado en el cambio de apuntamiento.
406 */
406 */
407 int carga_experimento(char *nombre_archivo){
407 int carga_experimento(char *nombre_archivo){
408
408
409 FILE *Archivo_Fd;
409 FILE *Archivo_Fd;
410
410
411 char *cadena = (char *) malloc(25);
411 char *cadena = (char *) malloc(25);
412
412
413 int longitud_cadena;
413 int longitud_cadena;
414 int num_bytes= 0;
414 int num_bytes= 0;
415 int num_filas= 0;
415 int num_filas= 0;
416
416
417 Archivo_Fd = fopen(nombre_archivo,"r"); // Se procede a abrir el archivo, segun la ruta especificada
417 Archivo_Fd = fopen(nombre_archivo,"r"); // Se procede a abrir el archivo, segun la ruta especificada
418 if(!Archivo_Fd){
418 if(!Archivo_Fd){
419 printf("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n");
419 printf("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n");
420 //ERROR("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n");
420 //ERROR("carga_archivo: No se pudo abrir el archivo!!! --> fopen()\n");
421 return -1;
421 return -1;
422 }else{
422 }else{
423
423
424 while(!feof(Archivo_Fd)){ // Se procede a calcular la longitud del archivo para separar memoria
424 while(!feof(Archivo_Fd)){ // Se procede a calcular la longitud del archivo para separar memoria
425 fgets(cadena,20,Archivo_Fd);
425 fgets(cadena,20,Archivo_Fd);
426 longitud_cadena= strlen(cadena);
426 longitud_cadena= strlen(cadena);
427 cadena[longitud_cadena-1] = '\0';
427 cadena[longitud_cadena-1] = '\0';
428 num_bytes = num_bytes + longitud_cadena;
428 num_bytes = num_bytes + longitud_cadena;
429 num_filas++;
429 num_filas++;
430 }
430 }
431
431
432 rewind(Archivo_Fd); // Se reinicia el puntero del archivo
432 rewind(Archivo_Fd); // Se reinicia el puntero del archivo
433
433
434 char *buffer_temporal = (char *) malloc(num_bytes+1); // Se separa espacio de memoria segun
434 char *buffer_temporal = (char *) malloc(num_bytes+1); // Se separa espacio de memoria segun
435 // la longitud del archivo
435 // la longitud del archivo
436 fread(buffer_temporal, sizeof(char), num_bytes, Archivo_Fd);
436 fread(buffer_temporal, sizeof(char), num_bytes, Archivo_Fd);
437
437
438 char *puntero= strstr(buffer_temporal,".ab1"); // Se procede a eliminar la cabecera del archivo
438 char *puntero= strstr(buffer_temporal,".ab1"); // Se procede a eliminar la cabecera del archivo
439 puntero= puntero + 12;
439 puntero= puntero + 12;
440
440
441 buff_experimento = (char *) malloc(7*(num_filas-3)); // num_bytes_fila*(num_filas-3);
441 buff_experimento = (char *) malloc(7*(num_filas-3)); // num_bytes_fila*(num_filas-3);
442 strncpy(buff_experimento,puntero,7*(num_filas-3)); // Se carga en memoria la informacion del archivo
442 strncpy(buff_experimento,puntero,7*(num_filas-3)); // Se carga en memoria la informacion del archivo
443
443
444 fclose(Archivo_Fd);
444 fclose(Archivo_Fd);
445
445
446 return 1;
446 return 1;
447 }
447 }
448 }
448 }
449
449
450 /*
450 /*
451 * Esta funcion recibe un numero en formato char, el dato se transforma a su equivalente en
451 * Esta funcion recibe un numero en formato char, el dato se transforma a su equivalente en
452 * un numero entero, que sera usado para sacar un dato del buffer "buff_experimento", esta
452 * un numero entero, que sera usado para sacar un dato del buffer "buff_experimento", esta
453 * dato es el valor que se enviara al sistema de conmutacion RF para el cambio de apunte a
453 * dato es el valor que se enviara al sistema de conmutacion RF para el cambio de apunte a
454 * traves del puerto GPIO.
454 * traves del puerto GPIO.
455 */
455 */
456 int cambia_apuntamiento(char *puntero_char){
456 int cambia_apuntamiento(char *puntero_char){
457
457
458 /*MSB-UP-LSB MSB-DOWN-LSB*/
458 /*MSB-UP-LSB MSB-DOWN-LSB*/
459 int desplazamiento[6]={30,28,26,24,22,20}; // Defino los dezplazamientos que se aplicara
459 int desplazamiento[6]={30,28,26,24,22,20}; // Defino los dezplazamientos que se aplicara
460 // al dato que ingresa para formar el número
460 // al dato que ingresa para formar el número
461 // entero que se le pasara al puerto GPIO
461 // entero que se le pasara al puerto GPIO
462 // Estos números son los pines del puerto GPIO
462 // Estos números son los pines del puerto GPIO
463 // que se estan usando para el control
463 // que se estan usando para el control
464
464
465 int puntero= atoi(puntero_char); // Se convierte a entero la direccion del puntero
465 int puntero= atoi(puntero_char); // Se convierte a entero la direccion del puntero
466
466
467 int base= 7*puntero; // base= cantidad_bytes del dato x puntero
467 int base= 7*puntero; // base= cantidad_bytes del dato x puntero
468 // cantidad de bytes es el numero de bytes que
468 // cantidad de bytes es el numero de bytes que
469 printf("%s\n",puntero_char); // contiene cada dato, para este caso es 7
469 printf("%s\n",puntero_char); // contiene cada dato, para este caso es 7
470 // porque es 6 bits de datos + 1 bit del cambio
470 // porque es 6 bits de datos + 1 bit del cambio
471 // de linea.
471 // de linea.
472 char valor_char;
472 char valor_char;
473 unsigned long valor;
473 unsigned long valor;
474 unsigned long acumulado_ceros=0;
474 unsigned long acumulado_ceros=0;
475 unsigned long acumulado_unos=0;
475 unsigned long acumulado_unos=0;
476
476
477 int offset; // Defino offset para el desplazamiento a traves
477 int offset; // Defino offset para el desplazamiento a traves
478 for(offset=0;offset<6;offset++){ // de cada dato que se obtiene del "buff_experimento"
478 for(offset=0;offset<6;offset++){ // de cada dato que se obtiene del "buff_experimento"
479
479
480 valor_char= buff_experimento[base+offset]; // Obtengo el dato
480 valor_char= buff_experimento[base+offset]; // Obtengo el dato
481
481
482 if (valor_char == '0'){ // Obtengo el número acumulado segun sea un cero o un uno
482 if (valor_char == '0'){ // Obtengo el número acumulado segun sea un cero o un uno
483 valor= 0;
483 valor= 0;
484 acumulado_ceros= acumulado_ceros + (1 << desplazamiento[offset]);
484 acumulado_ceros= acumulado_ceros + (1 << desplazamiento[offset]);
485 }else{
485 }else{
486 valor= 1;
486 valor= 1;
487 acumulado_unos= acumulado_unos + (1 << desplazamiento[offset]);
487 acumulado_unos= acumulado_unos + (1 << desplazamiento[offset]);
488 }
488 }
489 }
489 }
490 pio_out(pioc, maskc_out, acumulado_unos, 1);
490 pio_out(pioc, maskc_out, acumulado_unos, 1);
491 pio_out(pioc, maskc_out, acumulado_ceros, 0);
491 pio_out(pioc, maskc_out, acumulado_ceros, 0);
492
492
493 return 1;
493 return 1;
494
494
495 }
495 }
496
496
497 /*
497 /*
498 * Esta funcion lee "n" veces el estado del APUNTE actual y reporta
498 * Esta funcion lee "n" veces el estado del APUNTE actual y reporta
499 * una cadena de Verificacion.
499 * una cadena de Verificacion.
500 */
500 */
501 char* chequeo_sistema(char *filename, char *numero_muestras){
501 char* chequeo_sistema(char *filename, char *numero_muestras){
502
502
503 int i;
503 int i;
504 int cnt = 0;
504 int cnt = 0;
505 unsigned int entradac= 0;
505 unsigned int entradac= 0;
506
506
507 char page0[250];
507 char page0[250];
508
508
509 strcpy(page0,"Verificacion\n");
509 strcpy(page0,"Verificacion\n");
510 strcat(page0,parameters.ID);
510 strcat(page0,parameters.ID);
511 strcat(page0,"\n------------\n");
511 strcat(page0,"\n------------\n");
512
512
513 char page1[8];
513 char page1[8];
514
514
515 do{
515 do{
516 //Inicializando arreglo
516 //Inicializando arreglo
517 for(i=0;i<6;i++)
517 for(i=0;i<6;i++)
518 page1[i]='0';
518 page1[i]='0';
519 page1[6] = '\n';
519 page1[6] = '\n';
520 page1[7] = '\0';
520 page1[7] = '\0';
521 //Lectura de puerto
521 //Lectura de puerto
522 entradac= pio_in(piob,maskb_in);
522 entradac= pio_in(piob,maskb_in);
523 //Dandole formato al dato
523 //Dandole formato al dato
524 if (!(entradac & bit_up_2))
524 if (!(entradac & bit_up_2))
525 page1[0] = '1';
525 page1[0] = '1';
526 if (!(entradac & bit_up_1))
526 if (!(entradac & bit_up_1))
527 page1[1] = '1';
527 page1[1] = '1';
528 if (!(entradac & bit_up_0))
528 if (!(entradac & bit_up_0))
529 page1[2] = '1';
529 page1[2] = '1';
530 if (!(entradac & bit_dow_2))
530 if (!(entradac & bit_dow_2))
531 page1[3] = '1';
531 page1[3] = '1';
532 if (!(entradac & bit_dow_1))
532 if (!(entradac & bit_dow_1))
533 page1[4] = '1';
533 page1[4] = '1';
534 if (!(entradac & bit_dow_0))
534 if (!(entradac & bit_dow_0))
535 page1[5] = '1';
535 page1[5] = '1';
536
536
537 strcat(page0, page1);
537 strcat(page0, page1);
538 cnt=cnt+1;
538 cnt=cnt+1;
539 usleep(1*1000*1000);
539 usleep(1*1000*1000);
540
540
541 }while(cnt < atoi(numero_muestras));
541 }while(cnt < atoi(numero_muestras));
542
542
543 page0[strlen(page0)] = '\0';
543 page0[strlen(page0)] = '\0';
544
544
545 char *all_pages = malloc(strlen(page0)+1);
545 char *all_pages = malloc(strlen(page0)+1);
546 strcpy(all_pages, page0);
546 strcpy(all_pages, page0);
547 return all_pages;
547 return all_pages;
548 }
548 }
549
549
550 /*
550 /*
551 *
551 *
552 */
552 */
553 cmp inicializa_modulo(cmp p){
553 cmp inicializa_modulo(cmp p){
554 FILE *fd = fopen("configuration.txt","r");
554 FILE *fd = fopen("configuration.txt","r");
555 fgets(p.ID,20,fd);
555 fgets(p.ID,20,fd);
556 p.ID[7]='\0';
556 p.ID[7]='\0';
557 fgets(p.param2,20,fd);
557 fgets(p.param2,20,fd);
558 p.param2[10]='\0';
558 p.param2[10]='\0';
559 fgets(p.param3,20,fd);
559 fgets(p.param3,20,fd);
560 p.param3[10]='\0';
560 p.param3[10]='\0';
561 fgets(p.param4,20,fd);
561 fgets(p.param4,20,fd);
562 p.param4[10]='\0';
562 p.param4[10]='\0';
563 fclose(fd);
563 fclose(fd);
564 return p;
564 return p;
565 }
565 }
566
566
567 /*
567 /*
568 *
568 *
569 */
569 */
570 void intToStr( int number, char* str )
570 void intToStr( int number, char* str )
571
571
572 {
572 {
573 int index = 0;
573 int index = 0;
574
574
575 while( number > 0 )
575 while( number > 0 )
576 {
576 {
577 int digit = number%10;
577 int digit = number%10;
578 str[index++] = digit + '0';
578 str[index++] = digit + '0';
579 number /= 10;
579 number /= 10;
580 }
580 }
581 str[index] = '\0';
581 str[index] = '\0';
582 //Adding zero to the left
582 //Adding zero to the left
583 int n= strlen(str);
583 int n= strlen(str);
584 if (n == 1) {
584 if (n == 1) {
585 strcat(str,"00000");
585 strcat(str,"00000");
586 index = index + 5;
586 index = index + 5;
587 }else if(n == 2){
587 }else if(n == 2){
588 strcat(str,"0000");
588 strcat(str,"0000");
589 index = index + 4;
589 index = index + 4;
590 }else if(n == 3){
590 }else if(n == 3){
591 strcat(str,"000");
591 strcat(str,"000");
592 index = index + 3;
592 index = index + 3;
593 }else if(n == 4){
593 }else if(n == 4){
594 strcat(str,"00");
594 strcat(str,"00");
595 index = index + 2;
595 index = index + 2;
596 }else if(n == 5){
596 }else if(n == 5){
597 strcat(str,"0");
597 strcat(str,"0");
598 index = index + 1;
598 index = index + 1;
599 }
599 }
600 //Now reverse the numbers in the string.
600 //Now reverse the numbers in the string.
601 int position;
601 int position;
602 for( position = 0; position <= (index-1)/2; ++position )
602 for( position = 0; position <= (index-1)/2; ++position )
603 {
603 {
604 char tmp = str[position];
604 char tmp = str[position];
605 str[position] = str[(index-1)-position];
605 str[position] = str[(index-1)-position];
606 str[(index-1)-position] = tmp;
606 str[(index-1)-position] = tmp;
607 }
607 }
608 }
608 }
609
609
610
610
611 //*****************************************************************
611 //*****************************************************************
612 //ABS_monitoreo es la funci�n principal del proyecto ABS_Monitoreo.
612 //ABS_monitoreo es la funci�n principal del proyecto ABS_Monitoreo.
613 //Esta funci�n es la que se debe agregar en otros c�digos.
613 //Esta funci�n es la que se debe agregar en otros c�digos.
614 //*****************************************************************
614 //*****************************************************************
615 int ABS_monitoreo(int sel_atenuador, int sel_calibracion, float umbral, int pulsewidth){
615 int ABS_monitoreo(int sel_atenuador, int sel_calibracion, float umbral, int pulsewidth){
616
616
617 //local variables
617 //local variables
618 AT91S_PIO *pioc;
618 AT91S_PIO *pioc;
619 pioc = pio_map(PIOC_BASE);
619 pioc = pio_map(PIOC_BASE);
620 unsigned int mask_sel_canal =PC4; //Aqu� se indican los pines que se desean usar como salidas. Las constantes PCx est�n defiidas en el header at91gpio.h
620 unsigned int mask_sel_canal =PC4; //Aqu� se indican los pines que se desean usar como salidas. Las constantes PCx est�n defiidas en el header at91gpio.h
621 unsigned int mask_sel_atenuacion =PC5;
621 unsigned int mask_sel_atenuacion =PC5;
622 unsigned int mask_sel_calibracion =PC6;
622 unsigned int mask_sel_calibracion =PC6;
623 AT91S_ADC *padc;
623 AT91S_ADC *padc;
624 AT91S_ADC *padd;
624 AT91S_ADC *padd;
625 FILE *fp;
625 FILE *fp;
626 long int results1[NSAMPLES], results2[NSAMPLES], results3[NSAMPLES], results4[NSAMPLES];
626 long int results1[NSAMPLES], results2[NSAMPLES], results3[NSAMPLES], results4[NSAMPLES];
627 unsigned int i=0;
627 unsigned int i=0;
628 char fname[FNAMELEN];
628 char fname[FNAMELEN];
629 int j=0;
629 int j=0;
630 time_t now;
630 time_t now;
631 FILE *archivo;
631 FILE *archivo;
632 float phase1;
632 float phase1;
633 float phase2;
633 float phase2;
634 //system("./map_clock");
634 //system("./map_clock");
635
635
636 if (configCLK() == 1)
636 if (configCLK() == 1)
637 printf("clock ADC enable.\n");
637 printf("clock ADC enable.\n");
638
638
639
639
640 //configurar tres pines como salida usando als m�scaras mask_sel_canal, mask_sel_atenuacion y mask_sel_calibracion. En este caso corresponden a los pines pc4, pc5 y pc6.
640 //configurar tres pines como salida usando als m�scaras mask_sel_canal, mask_sel_atenuacion y mask_sel_calibracion. En este caso corresponden a los pines pc4, pc5 y pc6.
641 pio_enable(pioc, mask_sel_canal);
641 pio_enable(pioc, mask_sel_canal);
642 pio_enable(pioc, mask_sel_atenuacion);
642 pio_enable(pioc, mask_sel_atenuacion);
643 pio_enable(pioc, mask_sel_calibracion);
643 pio_enable(pioc, mask_sel_calibracion);
644 pio_output_enable(pioc, mask_sel_canal); //configurar pc4 como salida
644 pio_output_enable(pioc, mask_sel_canal); //configurar pc4 como salida
645 pio_output_enable(pioc, mask_sel_atenuacion); //configurar pc5 como salida
645 pio_output_enable(pioc, mask_sel_atenuacion); //configurar pc5 como salida
646 pio_output_enable(pioc, mask_sel_calibracion); //configurar pc6 como salida
646 pio_output_enable(pioc, mask_sel_calibracion); //configurar pc6 como salida
647
647
648
648
649 //Se modifican las salidas correspondientes a la selecci�n del atenuador y calibraci�n, de acuerdo a los par�metros ingresados en la funci�n ABS_monitoreo.
649 //Se modifican las salidas correspondientes a la selecci�n del atenuador y calibraci�n, de acuerdo a los par�metros ingresados en la funci�n ABS_monitoreo.
650 pio_out(pioc, mask_sel_atenuacion, sel_atenuador,1);
650 if ( sel_atenuador == 1)
651 pio_out(pioc, mask_sel_calibracion, sel_calibracion,1);
651 pio_out(pioc, mask_sel_atenuacion, sel_atenuador,1);
652 else
653 pio_out(pioc, mask_sel_atenuacion, sel_atenuador,0);
654 if ( sel_calibracion == 1)
655 pio_out(pioc, mask_sel_calibracion, sel_calibracion,1);
656 else
657 pio_out(pioc, mask_sel_calibracion, sel_calibracion,0);
652
658
653
659
654 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt"); //Direcci�n y nombre del archivo donde se desea guardar los datos.
660 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt"); //Direcci�n y nombre del archivo donde se desea guardar los datos.
655
661
656 if (fExists(fname)==0){ //si el archivo no existe, crea uno y le asigna el titulo
662 if (fExists(fname)==0){ //si el archivo no existe, crea uno y le asigna el titulo
657 archivo = fopen(fname,"a+");
663 archivo = fopen(fname,"a+");
658 fprintf(archivo,"%s"," Registro de datos del ABS Control \n");
664 fprintf(archivo,"%s"," Registro de datos del ABS Control \n");
659 fprintf(archivo,"%s"," Fecha y hora Fase UP Fase DOWN\n");
665 fprintf(archivo,"%s"," Fecha y hora Fase UP Fase DOWN\n");
660 fclose(archivo);
666 fclose(archivo);
661 }
667 }
662
668
663
669
664 //configure ADC Settings
670 //configure ADC Settings
665 padc=configADC1();
671 padc=configADC1();
666 padd=configADC2();
672 padd=configADC2();
667
673
668 while (1){
674 while (1){
669
675
670 ENABLE_CHANNEL(padc, ADC_CH0+ADC_CH1);
676 ENABLE_CHANNEL(padc, ADC_CH0+ADC_CH1);
671 printf("\nAdquiriendo datos...\n"); //Indica en el terminal que se est�n adquiriendo datos (muestreando la se�al).
677 printf("\nAdquiriendo datos...\n"); //Indica en el terminal que se est�n adquiriendo datos (muestreando la se�al).
672
678
673
679
674 now = time(0); //Get current Time for File Name
680 now = time(0); //Get current Time for File Name
675
681
676
682
677 //Se pone la salida de selecci�n de canal para seleccionar el canal 1 del detector de fase
683 //Se pone la salida de selecci�n de canal para seleccionar el canal 1 del detector de fase
684 // pio_out(pioc, mask_sel_canal, 0,1);
678 pio_out(pioc, mask_sel_canal, 0,1);
685 pio_out(pioc, mask_sel_canal, 0,1);
679
686
680
687
681 //Se toman muestras para el canal 1 del detector de fase
688 //Se toman muestras para el canal 1 del detector de fase
682 while(1){
689 while(1){
683 for(i=0; i < NSAMPLES; i++){
690 for(i=0; i < NSAMPLES; i++){
684
691
685 ADC_INIT(padc);
692 ADC_INIT(padc);
686 results1[i] = GET_ADC0(padc);
693 results1[i] = GET_ADC0(padc);
687 results2[i] = GET_ADC1(padd);
694 results2[i] = GET_ADC1(padd);
688 }
695 }
689
696
690
697
691 if (checkTx(results1, results2, umbral, pulsewidth)==1){ //Se verifica que las muestras tomadas del canal 1 del datector de fase //correspondan a un pulso.
698 if (checkTx(results1, results2, umbral, pulsewidth)==1){ //Se verifica que las muestras tomadas del canal 1 del datector de fase //correspondan a un pulso.
692 break;
699 break;
693 }
700 }
694 }
701 }
695
702
696
703
697 //Se pone la salida de selecci�n de canal para seleccionar el canal 2 del detector de fase
704 //Se pone la salida de selecci�n de canal para seleccionar el canal 2 del detector de fase
698 pio_out(pioc, mask_sel_canal, 1,1);
705 pio_out(pioc, mask_sel_canal, 1,1);
699
706
700
707
701
708
702 //Setoman muestras para el canal 2 del detector de fase
709 //Setoman muestras para el canal 2 del detector de fase
703 while(1){
710 while(1){
704 for(i=0; i < NSAMPLES; i++){
711 for(i=0; i < NSAMPLES; i++){
705
712
706 ADC_INIT(padc);
713 ADC_INIT(padc);
707 results3[i] = GET_ADC0(padc);
714 results3[i] = GET_ADC0(padc);
708 results4[i] = GET_ADC1(padd);
715 results4[i] = GET_ADC1(padd);
709 }
716 }
710
717
711 if (checkTx(results3, results4, umbral, pulsewidth)==1){ //Se verifica que las muestras tomadas del canal 2 del detector de fase //correspondan a un pulso.
718 if (checkTx(results3, results4, umbral, pulsewidth)==1){ //Se verifica que las muestras tomadas del canal 2 del detector de fase //correspondan a un pulso.
712 break;
719 break;
713 }
720 }
714 }
721 }
715
722
716
723
717 //Una vez que se ha encontrado un pulso en cada canal, se calcula la fase de ambos.
724 //Una vez que se ha encontrado un pulso en cada canal, se calcula la fase de ambos.
718
725
719 phase1 = getPhase(results1, results2); //Calcular la fase del canal 1 del detector de fase.
726 phase1 = getPhase(results1, results2); //Calcular la fase del canal 1 del detector de fase.
720 phase2 = getPhase(results3, results4); //Calcular la fase del canal 2 del detector de fase.
727 phase2 = getPhase(results3, results4); //Calcular la fase del canal 2 del detector de fase.
721 //create Output File
728 //create Output File
722
729
723 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt");
730 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt");
724 printf("\nTerminada la prueba # %d \n", j++);
731 printf("\nTerminada la prueba # %d \n", j++);
725 fp=create_Output(fname, now); //Coloca la fecha y la hora en el archivo de texto
732 fp=create_Output(fname, now); //Coloca la fecha y la hora en el archivo de texto
726 printf("mediana ch1 = %1.2f\n", phase1); //muestra resultado en terminal
733 printf("mediana ch1 = %1.2f\n", phase1); //muestra resultado en terminal
727 printf("mediana ch2 = %1.2f\n", phase2); //muestra resultado en terminal
734 printf("mediana ch2 = %1.2f\n", phase2); //muestra resultado en terminal
728 writeOutput(phase1, fp); //graba el resultado en el archivo de texto
735 writeOutput(phase1, fp); //graba el resultado en el archivo de texto
729 writeOutput(phase2, fp); //graba el resultado en el archivo de texto
736 writeOutput(phase2, fp); //graba el resultado en el archivo de texto
730 fprintf(fp, "\n"); //Pasa a la siguiente l�nea del archivo de texto
737 fprintf(fp, "\n"); //Pasa a la siguiente l�nea del archivo de texto
731 fclose(fp);
738 fclose(fp);
732 printf("Resultado guardado en %s \n", fname);
739 printf("Resultado guardado en %s \n", fname);
733
740
734 sleep(1);
741 sleep(1);
735
742
736 }
743 }
737 return 0;
744 return 0;
738 }
745 }
739 /*=============================================================================
746 /*=============================================================================
740 Function definitions
747 Function definitions
741 =============================================================================*/
748 =============================================================================*/
742
749
743 // Configures ADC registers in order to get a sample every 10us
750 // Configures ADC registers in order to get a sample every 10us
744 AT91S_ADC * configADC1(void){
751 AT91S_ADC * configADC1(void){
745 //Variables a usar:
752 //Variables a usar:
746 unsigned int maskc_adc =PC0; //Usamos ADC0 y ADC1
753 unsigned int maskc_adc =PC0; //Usamos ADC0 y ADC1
747
754
748 //configuro pin:
755 //configuro pin:
749 AT91S_PIO *pioc;
756 AT91S_PIO *pioc;
750 pioc = pio_map(PIOC_BASE);
757 pioc = pio_map(PIOC_BASE);
751 pin_adc_enable(pioc,maskc_adc); //Habilitamos PC0 para usar con ADC0 y 1
758 pin_adc_enable(pioc,maskc_adc); //Habilitamos PC0 para usar con ADC0 y 1
752 pio_disable_irq(pioc, maskc_adc);
759 pio_disable_irq(pioc, maskc_adc);
753 pio_disable_multiple_driver(pioc, maskc_adc);
760 pio_disable_multiple_driver(pioc, maskc_adc);
754 pio_disable_pull_ups(pioc, maskc_adc);
761 pio_disable_pull_ups(pioc, maskc_adc);
755 pio_input_enable(pioc, maskc_adc);
762 pio_input_enable(pioc, maskc_adc);
756
763
757
764
758 //Configuro el ADC:
765 //Configuro el ADC:
759 AT91S_ADC *padc;
766 AT91S_ADC *padc;
760
767
761 padc = adc_map1(ADC_BASE);
768 padc = adc_map1(ADC_BASE);
762
769
763 //clock ADC = 1MHz
770 //clock ADC = 1MHz
764 //time startup = 8us
771 //time startup = 8us
765 //time sample and hold = 2us
772 //time sample and hold = 2us
766 // hold
773 // hold
767 // ___________
774 // ___________
768 // start ___________| |___________
775 // start ___________| |___________
769 //
776 //
770 // | --1.2us-- | --0.15us-- |
777 // | --1.2us-- | --0.15us-- |
771 //ADC_RESET(padc);
778 //ADC_RESET(padc);
772 CONFIG_ADC(padc,ADC_TRGEN_DIS | ADC_RES_10BIT | ADC_SLEEP_NORMAL_MODE | ADC_PRESCAL | ADC_STARTUP | ADC_SHTIM);
779 CONFIG_ADC(padc,ADC_TRGEN_DIS | ADC_RES_10BIT | ADC_SLEEP_NORMAL_MODE | ADC_PRESCAL | ADC_STARTUP | ADC_SHTIM);
773 ENABLE_CHANNEL(padc,ADC_CH0); //habilito canal 0
780 ENABLE_CHANNEL(padc,ADC_CH0); //habilito canal 0
774
781
775
782
776 return padc;
783 return padc;
777 }
784 }
778
785
779 AT91S_ADC * configADC2(void){
786 AT91S_ADC * configADC2(void){
780 //Variables a usar:
787 //Variables a usar:
781 unsigned int maskc_adc =PC1; //Usamos ADC0 y ADC1
788 unsigned int maskc_adc =PC1; //Usamos ADC0 y ADC1
782
789
783 //configuro pin:
790 //configuro pin:
784 AT91S_PIO *piod;
791 AT91S_PIO *piod;
785 piod = pio_map(PIOC_BASE);
792 piod = pio_map(PIOC_BASE);
786 pin_adc_enable(piod,maskc_adc); //Habilitamos PC0 para usar con ADC0 y 1
793 pin_adc_enable(piod,maskc_adc); //Habilitamos PC0 para usar con ADC0 y 1
787 pio_disable_irq(piod, maskc_adc);
794 pio_disable_irq(piod, maskc_adc);
788 pio_disable_multiple_driver(piod, maskc_adc);
795 pio_disable_multiple_driver(piod, maskc_adc);
789 pio_disable_pull_ups(piod, maskc_adc);
796 pio_disable_pull_ups(piod, maskc_adc);
790 pio_input_enable(piod, maskc_adc);
797 pio_input_enable(piod, maskc_adc);
791
798
792 //Configuro el ADC:
799 //Configuro el ADC:
793 AT91S_ADC *padd;
800 AT91S_ADC *padd;
794
801
795 padd = adc_map1(ADC_BASE);
802 padd = adc_map1(ADC_BASE);
796
803
797 //clock ADC = 1MHz
804 //clock ADC = 1MHz
798 //time startup = 8us
805 //time startup = 8us
799 //time sample and hold = 2us
806 //time sample and hold = 2us
800 // hold
807 // hold
801 // ___________
808 // ___________
802 // start ___________| |___________
809 // start ___________| |___________
803 //
810 //
804 // | --1.2us-- | --0.15us-- |
811 // | --1.2us-- | --0.15us-- |
805 //ADC_RESET(padc);
812 //ADC_RESET(padc);
806 CONFIG_ADC(padd,ADC_TRGEN_DIS | ADC_RES_10BIT | ADC_SLEEP_NORMAL_MODE | ADC_PRESCAL | ADC_STARTUP | ADC_SHTIM);
813 CONFIG_ADC(padd,ADC_TRGEN_DIS | ADC_RES_10BIT | ADC_SLEEP_NORMAL_MODE | ADC_PRESCAL | ADC_STARTUP | ADC_SHTIM);
807 ENABLE_CHANNEL(padd,ADC_CH1); //habilito canal 1
814 ENABLE_CHANNEL(padd,ADC_CH1); //habilito canal 1
808 return padd;
815 return padd;
809 }
816 }
810
817
811
818
812 //++++++++++++++++++++
819 //++++++++++++++++++++
813
820
814 //creats the output file with a timestamp in the name
821 //creats the output file with a timestamp in the name
815 FILE * create_Output(char *fname, time_t rawtime){
822 FILE * create_Output(char *fname, time_t rawtime){
816 FILE *file;
823 FILE *file;
817 char timestamp[80];//, counter[5]="dcv";
824 char timestamp[80];//, counter[5]="dcv";
818 //char str[4];
825 //char str[4];
819 struct tm * timeinfo;
826 struct tm * timeinfo;
820
827
821 //format time
828 //format time
822 timeinfo = localtime ( &rawtime );
829 timeinfo = localtime ( &rawtime );
823 strftime (timestamp,sizeof(timestamp),"%a %y-%m-%d %H:%M:%S %Z",timeinfo);
830 strftime (timestamp,sizeof(timestamp),"%a %y-%m-%d %H:%M:%S %Z",timeinfo);
824
831
825
832
826 //Creates the file name out of the #define parameters
833 //Creates the file name out of the #define parameters
827
834
828 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt");
835 strcpy (fname, "/mnt/sd/archivos/absmonitoreo.txt");
829 file = fopen(fname,"a+");
836 file = fopen(fname,"a+");
830 fprintf(file,"%s", timestamp);
837 fprintf(file,"%s", timestamp);
831 //printf("\nTerminada la prueba # %d. Guardando resultado en %s\n",r, fname);
838 //printf("\nTerminada la prueba # %d. Guardando resultado en %s\n",r, fname);
832 //printf("\nTerminada la prueba # %d/%d. Writing data to the file %s\n",r+1 , REP, fname);
839 //printf("\nTerminada la prueba # %d/%d. Writing data to the file %s\n",r+1 , REP, fname);
833 //printf("\nAAAAAAAAAA %d...%s\n", counter[1], fname);
840 //printf("\nAAAAAAAAAA %d...%s\n", counter[1], fname);
834 // return file pointer
841 // return file pointer
835 return file;
842 return file;
836 }
843 }
837
844
838 //++++++++++++++++++++
845 //++++++++++++++++++++
839
846
840 //tests if a file already exists. returns 1 if it exists and 0 if it doesn't
847 //tests if a file already exists. returns 1 if it exists and 0 if it doesn't
841
848
842
849
843
850
844 //Funci�n checkTx verifica que la se�al muestreada corresponda a un pulso.
851 //Funci�n checkTx verifica que la se�al muestreada corresponda a un pulso.
845 //results1 y results2 son los arreglos que contienen los datos muestreados por ambos canales del ADC del embebido.
852 //results1 y results2 son los arreglos que contienen los datos muestreados por ambos canales del ADC del embebido.
846 //umbral indica qu� valor debe superar una muestra para considerarla un posible pulso o pico.
853 //umbral indica qu� valor debe superar una muestra para considerarla un posible pulso o pico.
847 //pulsewidth indica cu�ntas muestras consecutivas deben superar el umbral para que se considere que se ha detectado un pulso.
854 //pulsewidth indica cu�ntas muestras consecutivas deben superar el umbral para que se considere que se ha detectado un pulso.
848 int checkTx(long int results1[],long int results2[], float umbral, int pulsewidth){
855 int checkTx(long int results1[],long int results2[], float umbral, int pulsewidth){
849
856
850 int i, cont;
857 int i, cont;
851 float z[NSAMPLES], sum, avg;
858 float z[NSAMPLES], sum, avg;
852 int isSignal, pulse;
859 int isSignal, pulse;
853
860
854 for(i=0;i<NSAMPLES;i++){
861 for(i=0;i<NSAMPLES;i++){
855
862
856 z[i] =sqrt(1.0*results1[i]*results1[i]+1.0*results2[i]*results2[i]);
863 z[i] =sqrt(1.0*results1[i]*results1[i]+1.0*results2[i]*results2[i]);
857 }
864 }
858
865
859 pulse = 0;
866 pulse = 0;
860 isSignal = 0;
867 isSignal = 0;
861 cont =0;
868 cont =0;
862
869
863 sum = 0;
870 sum = 0;
864 for(i=0;i<NSAMPLES;i++){
871 for(i=0;i<NSAMPLES;i++){
865
872
866 sum += z[i];
873 sum += z[i];
867 avg = sum/(i+1);
874 avg = sum/(i+1);
868 if ((z[i] - avg) > umbral){
875 if ((z[i] - avg) > umbral){
869 if (isSignal == 1){
876 if (isSignal == 1){
870 cont += 1;
877 cont += 1;
871 }
878 }
872 if (cont == pulsewidth){
879 if (cont == pulsewidth){
873 pulse = 1;
880 pulse = 1;
874 break;
881 break;
875 }
882 }
876 isSignal = 1;
883 isSignal = 1;
877 continue;
884 continue;
878 isSignal = 0;
885 isSignal = 0;
879 cont = 0;
886 cont = 0;
880 }
887 }
881 }
888 }
882
889
883 return pulse; //devuelve un entero: 1 si se ha detectado pulso, de lo contrario, 0.
890 return pulse; //devuelve un entero: 1 si se ha detectado pulso, de lo contrario, 0.
884 }
891 }
885
892
886
893
887 int fExists(char * fname){
894 int fExists(char * fname){
888 FILE * file;
895 FILE * file;
889
896
890 file = fopen (fname, "r");
897 file = fopen (fname, "r");
891 if (file == NULL)
898 if (file == NULL)
892 {
899 {
893 return 0;
900 return 0;
894 }
901 }
895 fclose(file);
902 fclose(file);
896 return 1;
903 return 1;
897 }
904 }
898
905
899
906
900 //Funci�n que calcula la mediana de un conjunto de muestras
907 //Funci�n que calcula la mediana de un conjunto de muestras
901 double mediana(long int *results,unsigned int cuenta){
908 double mediana(long int *results,unsigned int cuenta){
902 unsigned int i=0,j=0,aux=0;
909 unsigned int i=0,j=0,aux=0;
903
910
904 double median=0;
911 double median=0;
905 /*Calculo mediana */
912 /*Calculo mediana */
906
913
907 for(i=0;i<cuenta-1;i++){
914 for(i=0;i<cuenta-1;i++){
908 for (j=i+1;j<cuenta;j++){
915 for (j=i+1;j<cuenta;j++){
909 if(results[i]>results[j] ){
916 if(results[i]>results[j] ){
910
917
911 aux=results[i];
918 aux=results[i];
912 results[i]=results[j];
919 results[i]=results[j];
913 results[j]=aux;
920 results[j]=aux;
914
921
915 }
922 }
916 }
923 }
917
924
918 }
925 }
919 median=results[cuenta/2];
926 median=results[cuenta/2];
920 return median;
927 return median;
921 }
928 }
922
929
923
930
924
931
925 //Funci�n que halla la fase de la se�al.
932 //Funci�n que halla la fase de la se�al.
926 //Tiene como entradas las muestras correspondientes a la parte real e imaginaria de la se�al.
933 //Tiene como entradas las muestras correspondientes a la parte real e imaginaria de la se�al.
927 float getPhase(long int results1[],long int results2[]){
934 float getPhase(long int results1[],long int results2[]){
928
935
929 unsigned int count=0, i=0,umbral=1000;
936 unsigned int count=0, i=0,umbral=1000;
930 //long int results1[];
937 //long int results1[];
931 //long int results2[];
938 //long int results2[];
932 long int power[NSAMPLES];
939 long int power[NSAMPLES];
933 long int sumI=0,sumQ=0,I[NSAMPLES], Q[NSAMPLES],II[NSAMPLES], QQ[NSAMPLES];
940 long int sumI=0,sumQ=0,I[NSAMPLES], Q[NSAMPLES],II[NSAMPLES], QQ[NSAMPLES];
934 double median1=0,median2=0;
941 double median1=0,median2=0;
935 long int promedioI=0,promedioQ=0;/*Calculo mediana 1*/
942 long int promedioI=0,promedioQ=0;/*Calculo mediana 1*/
936 float resultado=0;
943 float resultado=0;
937
944
938 for(i=0;i<NSAMPLES;i++){
945 for(i=0;i<NSAMPLES;i++){
939
946
940 I[i] =results1[i];
947 I[i] =results1[i];
941 Q[i] =results2[i];
948 Q[i] =results2[i];
942 }
949 }
943
950
944 /*Calculo mediana 1*/
951 /*Calculo mediana 1*/
945 median1=mediana(I,NSAMPLES);
952 median1=mediana(I,NSAMPLES);
946
953
947 /*Calculo mediana 2*/
954 /*Calculo mediana 2*/
948 median2=mediana(Q,NSAMPLES);
955 median2=mediana(Q,NSAMPLES);
949
956
950
957
951
958
952
959
953
960
954
961
955 for(i=0;i<NSAMPLES;i++){
962 for(i=0;i<NSAMPLES;i++){
956
963
957 I[i] =results1[i];
964 I[i] =results1[i];
958 Q[i] =results2[i];
965 Q[i] =results2[i];
959
966
960 }
967 }
961
968
962
969
963
970
964 for(i = 0; i < NSAMPLES ; i++){
971 for(i = 0; i < NSAMPLES ; i++){
965
972
966 I[i]=(I[i]-median1);
973 I[i]=(I[i]-median1);
967 Q[i]=(Q[i]-median2);
974 Q[i]=(Q[i]-median2);
968
975
969 }
976 }
970
977
971 for(i = 0; i < NSAMPLES ; i++){
978 for(i = 0; i < NSAMPLES ; i++){
972
979
973 power[i]=I[i]*I[i]+Q[i]*Q[i];
980 power[i]=I[i]*I[i]+Q[i]*Q[i];
974
981
975 if(power[i] > umbral)
982 if(power[i] > umbral)
976 {
983 {
977
984
978 II[count]=I[i];
985 II[count]=I[i];
979 QQ[count]=Q[i];
986 QQ[count]=Q[i];
980 count=count+1;
987 count=count+1;
981
988
982 }
989 }
983
990
984 }
991 }
985
992
986 for(i = 0; i < count ; i++){
993 for(i = 0; i < count ; i++){
987
994
988 sumI=sumI+II[i];
995 sumI=sumI+II[i];
989 sumQ=sumQ+QQ[i];
996 sumQ=sumQ+QQ[i];
990
997
991 }
998 }
992
999
993 promedioI=sumI;
1000 promedioI=sumI;
994 promedioQ=sumQ;
1001 promedioQ=sumQ;
995
1002
996 resultado = atan2(1.0*promedioI,1.0*promedioQ)*180/3.1416+62-44;
1003 resultado = atan2(1.0*promedioI,1.0*promedioQ)*180/3.1416+62-44;
997
1004
998
1005
999 return resultado;
1006 return resultado;
1000
1007
1001 }
1008 }
1002
1009
1003
1010
1004
1011
1005 //Funci�n que muestra la fase detectada en el terminal y tambi�n la graba en el archivo de texto.
1012 //Funci�n que muestra la fase detectada en el terminal y tambi�n la graba en el archivo de texto.
1006 void writeOutput(float resultado, FILE * output){
1013 void writeOutput(float resultado, FILE * output){
1007
1014
1008
1015
1009 //
1016 //
1010
1017
1011 fprintf(output," %1.2f ",resultado); //graba resultado en archivo .txt
1018 fprintf(output," %1.2f ",resultado); //graba resultado en archivo .txt
1012 //
1019 //
1013
1020
1014 }
1021 }
1015
1022
1016 int configCLK(){
1023 int configCLK(){
1017 //configuro pin:
1024 //configuro pin:
1018 AT91S_PMC *sys_clock;
1025 AT91S_PMC *sys_clock;
1019 sys_clock = clock_map(CLOCK_BASE);
1026 sys_clock = clock_map(CLOCK_BASE);
1020 enable_clock_adc(sys_clock);
1027 enable_clock_adc(sys_clock);
1021 //printf("clock ADC enable.\n");
1028 //printf("clock ADC enable.\n");
1022 return 1;
1029 return 1;
1023 }
1030 }
General Comments 0
You need to be logged in to leave comments. Login now