Changeset 364 for asp3_tinet_ecnl_arm
- Timestamp:
- Feb 1, 2019, 9:57:09 PM (5 years ago)
- Location:
- asp3_tinet_ecnl_arm/trunk
- Files:
-
- 10 added
- 122 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/.cproject
r352 r364 22 22 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 23 23 <option id="toolchain.id" value="gcc-arm-embedded"/> 24 <option id="toolchain.version" value=" 5.4.1.20160919"/>24 <option id="toolchain.version" value="6.3.1.20170620"/> 25 25 </storageModule> 26 26 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 59 59 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.2041552637" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 60 60 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1106389026" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 61 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1499740602" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>61 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1499740602" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 62 62 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.473685659" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 63 63 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.600330630" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 127 127 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 128 128 <option id="toolchain.id" value="gcc-arm-embedded"/> 129 <option id="toolchain.version" value=" 5.4.1.20160919"/>129 <option id="toolchain.version" value="6.3.1.20170620"/> 130 130 </storageModule> 131 131 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 164 164 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.504056262" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 165 165 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.211973441" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 166 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.559752886" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>166 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.559752886" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 167 167 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.541834310" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 168 168 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1603061550" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 232 232 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 233 233 <option id="toolchain.id" value="gcc-arm-embedded"/> 234 <option id="toolchain.version" value=" 5.4.1.20160919"/>234 <option id="toolchain.version" value="6.3.1.20170620"/> 235 235 </storageModule> 236 236 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 269 269 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.1222794445" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 270 270 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1527919964" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 271 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/DebugEnbt" id="com.renesas.cdt.managedbuild.gcc.rz.builder.896433184" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>271 <builder buildPath="${workspace_loc:/app1_usb_watt_meter}/DebugEnbt" id="com.renesas.cdt.managedbuild.gcc.rz.builder.896433184" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 272 272 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.893283254" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 273 273 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1741240748" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 341 341 </configuration> 342 342 </storageModule> 343 <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/> 343 344 </cproject> -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/Debug/Makefile
r352 r364 182 182 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 183 183 endif 184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 185 185 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 186 186 -I$(SRCDIR)/../btstack/include \ … … 196 196 -I$(SRCDIR)/../curl-7.57.0 \ 197 197 $(INCLUDES) 198 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.198 LDFLAGS := $(LDFLAGS) -L. 199 199 LIBS := $(LIBS) $(CXXLIBS) 200 200 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 207 207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o 208 208 APPLDIRS := $(APPLDIRS) ../../ntshell/lcd 209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o 209 APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o 210 APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT 210 211 211 212 # … … 220 221 APPL_ASMOBJS := 221 222 ifdef USE_CXX 222 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o 223 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o jsonsl.o 223 224 APPL_COBJS := $(APPL_COBJS) 224 225 else 225 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o 226 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o jsonsl.o 226 227 endif 227 228 APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o … … 232 233 endif 233 234 234 235 # 236 # ネットワークサービスの定義 237 # 238 NO_USE_TINET_LIBRARY = true 239 240 # ネットワークインタフェースの選択、何れか一つ選択する。 241 NET_IF = ether 242 243 # イーサネット・ディバイスドライバの選択 244 NET_DEV = if_btusb 245 246 # ネットワーク層の選択 247 #SUPPORT_INET6 = true 248 SUPPORT_INET4 = true 249 250 # API に組込む機能の選択 251 #API_CFG_IP4MAPPED_ADDR = true 252 253 # トランスポート層の選択 254 SUPPORT_TCP = true 255 SUPPORT_UDP = true 256 257 # IGMPを有効に設定 258 SUPPORT_IGMP = true 259 260 # 261 # ネットワークサービスの Makefile のインクルード 262 # 263 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 235 ifdef TINETDIR 236 # 237 # ネットワークサービスの定義 238 # 239 NO_USE_TINET_LIBRARY = true 240 241 # ネットワークインタフェースの選択、何れか一つ選択する。 242 NET_IF = ether 243 244 # イーサネット・ディバイスドライバの選択 245 NET_DEV = if_btusb 246 247 # ネットワーク層の選択 248 #SUPPORT_INET6 = true 249 SUPPORT_INET4 = true 250 251 # API に組込む機能の選択 252 #API_CFG_IP4MAPPED_ADDR = true 253 254 # トランスポート層の選択 255 SUPPORT_TCP = true 256 SUPPORT_UDP = true 257 258 # IGMPを有効に設定 259 SUPPORT_IGMP = true 260 261 # 262 # ネットワークサービスの Makefile のインクルード 263 # 264 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 265 endif 264 266 265 267 # … … 294 296 # コンフィギュレータに関する定義 295 297 # 296 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 297 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 ifndef TINETDIR 299 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 300 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 301 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 302 else 303 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 304 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 305 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 299 306 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 301 308 --symval-table ../../ntshell/echonet/echonet_sym.def \ 302 309 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 310 endif 303 311 CFG_ASMOBJS := $(CFG_ASMOBJS) 304 312 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 446 454 447 455 # 456 # 並列makeのための依存関係の定義 457 # 458 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 459 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 460 | offset.timestamp 461 462 # 448 463 # 特別な依存関係の定義 449 464 # … … 454 469 # 455 470 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 456 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \471 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 457 472 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 458 473 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEnbt/Makefile
r352 r364 182 182 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 183 183 endif 184 CDEFS := $(CDEFS) -DIF_ETHER_MULTI_NIC -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start184 CDEFS := $(CDEFS) -DIF_ETHER_MULTI_NIC -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 185 185 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 186 186 -I$(SRCDIR)/../btstack/include \ … … 196 196 -I$(SRCDIR)/../curl-7.57.0 \ 197 197 $(INCLUDES) 198 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.198 LDFLAGS := $(LDFLAGS) -L. 199 199 LIBS := $(LIBS) $(CXXLIBS) 200 200 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 207 207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o 208 208 APPLDIRS := $(APPLDIRS) ../../ntshell/lcd 209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o 209 APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o 210 APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT 210 211 211 212 # … … 220 221 APPL_ASMOBJS := 221 222 ifdef USE_CXX 222 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o 223 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o jsonsl.o 223 224 APPL_COBJS := $(APPL_COBJS) 224 225 else 225 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o 226 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o jsonsl.o 226 227 endif 227 228 APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o … … 232 233 endif 233 234 234 235 # 236 # ネットワークサービスの定義 237 # 238 NO_USE_TINET_LIBRARY = true 239 240 # ネットワークインタフェースの選択、何れか一つ選択する。 241 NET_IF = ether 242 243 # イーサネット・ディバイスドライバの選択 244 NET_DEV = if_enbt 245 246 # ネットワーク層の選択 247 #SUPPORT_INET6 = true 248 SUPPORT_INET4 = true 249 250 # API に組込む機能の選択 251 #API_CFG_IP4MAPPED_ADDR = true 252 253 # トランスポート層の選択 254 SUPPORT_TCP = true 255 SUPPORT_UDP = true 256 257 # IGMPを有効に設定 258 SUPPORT_IGMP = true 259 260 # 261 # ネットワークサービスの Makefile のインクルード 262 # 263 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 235 ifdef TINETDIR 236 # 237 # ネットワークサービスの定義 238 # 239 NO_USE_TINET_LIBRARY = true 240 241 # ネットワークインタフェースの選択、何れか一つ選択する。 242 NET_IF = ether 243 244 # イーサネット・ディバイスドライバの選択 245 NET_DEV = if_enbt 246 247 # ネットワーク層の選択 248 #SUPPORT_INET6 = true 249 SUPPORT_INET4 = true 250 251 # API に組込む機能の選択 252 #API_CFG_IP4MAPPED_ADDR = true 253 254 # トランスポート層の選択 255 SUPPORT_TCP = true 256 SUPPORT_UDP = true 257 258 # IGMPを有効に設定 259 SUPPORT_IGMP = true 260 261 # 262 # ネットワークサービスの Makefile のインクルード 263 # 264 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 265 endif 264 266 265 267 # … … 294 296 # コンフィギュレータに関する定義 295 297 # 296 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 297 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 ifndef TINETDIR 299 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 300 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 301 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 302 else 303 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 304 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 305 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 299 306 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 301 308 --symval-table ../../ntshell/echonet/echonet_sym.def \ 302 309 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 310 endif 303 311 CFG_ASMOBJS := $(CFG_ASMOBJS) 304 312 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 446 454 447 455 # 456 # 並列makeのための依存関係の定義 457 # 458 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 459 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 460 | offset.timestamp 461 462 # 448 463 # 特別な依存関係の定義 449 464 # … … 454 469 # 455 470 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 456 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \471 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 457 472 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 458 473 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEther/Makefile
r352 r364 182 182 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 183 183 endif 184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 185 185 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 186 186 -I$(SRCDIR)/../btstack/include \ … … 196 196 -I$(SRCDIR)/../curl-7.57.0 \ 197 197 $(INCLUDES) 198 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.198 LDFLAGS := $(LDFLAGS) -L. 199 199 LIBS := $(LIBS) $(CXXLIBS) 200 200 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 207 207 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o 208 208 APPLDIRS := $(APPLDIRS) ../../ntshell/lcd 209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o 209 APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o 210 APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT 210 211 211 212 # … … 220 221 APPL_ASMOBJS := 221 222 ifdef USE_CXX 222 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o 223 APPL_CXXOBJS := main.o ntshell_main.o echonet_main.o client.o jsonsl.o 223 224 APPL_COBJS := $(APPL_COBJS) 224 225 else 225 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o 226 APPL_COBJS := $(APPL_COBJS) main.o ntshell_main.o echonet_main.o client.o jsonsl.o 226 227 endif 227 228 APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o … … 232 233 endif 233 234 234 235 #236 # ネットワークサービスの定義237 #238 NO_USE_TINET_LIBRARY = true239 240 # ネットワークインタフェースの選択、何れか一つ選択する。241 NET_IF = ether242 243 # イーサネット・ディバイスドライバの選択235 ifdef TINETDIR 236 # 237 # ネットワークサービスの定義 238 # 239 NO_USE_TINET_LIBRARY = true 240 241 # ネットワークインタフェースの選択、何れか一つ選択する。 242 NET_IF = ether 243 244 # イーサネット・ディバイスドライバの選択 244 245 NET_DEV = if_mbed 245 246 246 # ネットワーク層の選択 247 #SUPPORT_INET6 = true 248 SUPPORT_INET4 = true 249 250 # API に組込む機能の選択 251 #API_CFG_IP4MAPPED_ADDR = true 252 253 # トランスポート層の選択 254 SUPPORT_TCP = true 255 SUPPORT_UDP = true 256 257 # IGMPを有効に設定 258 SUPPORT_IGMP = true 259 260 # 261 # ネットワークサービスの Makefile のインクルード 262 # 263 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 247 # ネットワーク層の選択 248 #SUPPORT_INET6 = true 249 SUPPORT_INET4 = true 250 251 # API に組込む機能の選択 252 #API_CFG_IP4MAPPED_ADDR = true 253 254 # トランスポート層の選択 255 SUPPORT_TCP = true 256 SUPPORT_UDP = true 257 258 # IGMPを有効に設定 259 SUPPORT_IGMP = true 260 261 # 262 # ネットワークサービスの Makefile のインクルード 263 # 264 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 265 endif 264 266 265 267 # … … 294 296 # コンフィギュレータに関する定義 295 297 # 296 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 297 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 ifndef TINETDIR 299 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 300 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 301 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 302 else 303 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 304 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 298 305 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 299 306 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 301 308 --symval-table ../../ntshell/echonet/echonet_sym.def \ 302 309 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 310 endif 303 311 CFG_ASMOBJS := $(CFG_ASMOBJS) 304 312 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 446 454 447 455 # 456 # 並列makeのための依存関係の定義 457 # 458 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 459 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 460 | offset.timestamp 461 462 # 448 463 # 特別な依存関係の定義 449 464 # … … 454 469 # 455 470 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 456 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \471 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 457 472 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 458 473 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/client.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2016 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ … … 48 48 #include "ff.h" 49 49 #include "util/ntstdio.h" 50 #include "client.h" 51 #include "jsonsl.h" 50 52 51 53 #define SKIP_PEER_VERIFICATION 52 54 //#define SKIP_HOSTNAME_VERIFICATION 55 56 const char SCOPE_DRIVE_FILE[] = "https://www.googleapis.com/auth/drive.file"; 57 const char GRANT_TYPE_DEVICE[] = "http://oauth.net/grant_type/device/1.0"; 58 53 59 char response[80]; 54 extern ntstdio_t ntstdio; 60 char errbuf[CURL_ERROR_SIZE]; 61 62 google_drive_t google_drive; 63 64 void curl_setopt_common(CURL *curl); 65 int google_drive_error_callback(jsonsl_t jsn, jsonsl_error_t err, 66 struct jsonsl_state_st *state, char *errat); 67 void google_drive_state_callback(jsonsl_t jsn, jsonsl_action_t action, 68 struct jsonsl_state_st *state, const char *buf); 55 69 56 70 void client_init(void) 57 71 { 72 google_drive_t *gd = &google_drive; 73 jsonsl_t jsn; 74 75 memset(gd, 0, sizeof(google_drive_t)); 76 memcpy(gd->fname, "1:/log/20160101000000.log", sizeof(gd->fname)); 77 78 jsn = gd->jsn = jsonsl_new(3); 79 jsn->data = gd; 80 jsn->error_callback = google_drive_error_callback; 81 jsn->action_callback = google_drive_state_callback; 82 jsonsl_enable_all_callbacks(jsn); 83 58 84 //uITRON4_minit(ITRON_POOL_SIZE); 59 85 … … 61 87 } 62 88 63 size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp) 64 { 65 int rest = size * nmemb; 89 size_t write_callback(void *buffer, size_t size, size_t nmemb, void *arg) 90 { 91 google_drive_t *gd = (google_drive_t *)arg; 92 jsonsl_t jsn = gd->jsn; 93 size_t len = size * nmemb, pos; 94 jsonsl_char_t data; 95 96 for (pos = 0; pos < len; pos++) { 97 data = *((jsonsl_char_t *)&((uint8_t *)buffer)[pos]); 98 99 if ((gd->jsn_buf_pos >= 0) && (gd->jsn_buf_pos < sizeof(gd->jsn_buf))) 100 gd->jsn_buf[gd->jsn_buf_pos++] = data; 101 jsonsl_feed(jsn, &data, 1); 102 } 103 104 return len; 105 } 106 107 void get_device_id_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 108 { 109 switch (gd->state) { 110 case psRoot: 111 if (state->level != 2) { 112 break; 113 } 114 else if (strcmp(buf, "device_code") == 0) { 115 gd->state = psDeviceCode; 116 } 117 else if (strcmp(buf, "user_code") == 0) { 118 gd->state = psUserCode; 119 } 120 else if (strcmp(buf, "expires_in") == 0) { 121 gd->state = psExpiresIn; 122 } 123 else if (strcmp(buf, "interval") == 0) { 124 gd->state = psInterval; 125 } 126 else if (strcmp(buf, "verification_url") == 0) { 127 gd->state = psVerificationUrl; 128 } 129 else if (strcmp(buf, "error") == 0) { 130 gd->state = psError; 131 } 132 else if (strcmp(buf, "error_description") == 0) { 133 gd->state = psErrorDescription; 134 } 135 break; 136 case psDeviceCode: 137 if (state->type == JSONSL_T_STRING) { 138 strlcpy(gd->credential.device_code, buf, sizeof(gd->credential.device_code)); 139 gd->state = psRoot; 140 } 141 break; 142 case psUserCode: 143 if (state->type == JSONSL_T_STRING) { 144 strlcpy(gd->credential.user_code, buf, sizeof(gd->credential.user_code)); 145 gd->state = psRoot; 146 } 147 break; 148 case psExpiresIn: 149 if (state->type == JSONSL_T_SPECIAL) { 150 gd->credential.expires_in = atoi(buf); 151 gd->state = psRoot; 152 } 153 break; 154 case psInterval: 155 if (state->type == JSONSL_T_SPECIAL) { 156 gd->credential.interval = atoi(buf); 157 gd->state = psRoot; 158 } 159 break; 160 case psVerificationUrl: 161 if (state->type == JSONSL_T_STRING) { 162 strlcpy(gd->credential.verification_url, buf, sizeof(gd->credential.verification_url)); 163 gd->state = psRoot; 164 } 165 break; 166 case psError: 167 if (state->type == JSONSL_T_STRING) { 168 strlcpy(gd->error.error, buf, sizeof(gd->error.error)); 169 gd->state = psRoot; 170 } 171 break; 172 case psErrorDescription: 173 if (state->type == JSONSL_T_STRING) { 174 strlcpy(gd->error.error_description, buf, sizeof(gd->error.error_description)); 175 gd->state = psRoot; 176 } 177 break; 178 } 179 } 180 181 void get_device_id_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 182 { 183 } 184 185 int get_device_id(google_drive_t *gd, const char *scope) 186 { 187 client_info_t *client_info = &gd->client_info; 188 credential_t *credential = &gd->credential; 189 CURLcode ret; 190 CURL *curl; 191 struct curl_slist *slist1; 192 size_t len; 193 char *postdata; 194 jsonsl_t jsn = gd->jsn; 195 196 gd->jsn_buf_pos = -1; 197 198 jsonsl_reset(jsn); 199 gd->start = get_device_id_state_start; 200 gd->end = get_device_id_state_end; 201 202 slist1 = NULL; 203 slist1 = curl_slist_append(slist1, "Content-Type: application/x-www-form-urlencoded"); 204 205 curl = curl_easy_init(); 206 207 char *client_id = curl_easy_escape(curl, client_info->client_id, strnlen(client_info->client_id, sizeof(client_info->client_id))); 208 char *esc_scope = curl_easy_escape(curl, scope, strlen(scope)); 209 210 len = sizeof("client_id=") + strlen(client_id) + sizeof("scope=") + strlen(esc_scope); 211 postdata = malloc(len); 212 snprintf(postdata, len, "client_id=%s&scope=%s", client_id, esc_scope); 213 214 curl_free(client_id); 215 curl_free(esc_scope); 216 217 curl_easy_setopt(curl, CURLOPT_URL, "https://accounts.google.com/o/oauth2/device/code"); 218 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata); 219 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)strnlen(postdata, len)); 220 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); 221 curl_setopt_common(curl); 222 223 curl_easy_setopt(curl, CURLOPT_WRITEDATA, gd); 224 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); 225 226 ret = curl_easy_perform(curl); 227 228 free(postdata); 229 230 curl_easy_cleanup(curl); 231 curl = NULL; 232 curl_slist_free_all(slist1); 233 slist1 = NULL; 234 235 return (int)ret; 236 } 237 238 void get_access_token_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 239 { 240 switch (gd->state) { 241 case psRoot: 242 if (state->level != 2) { 243 break; 244 } 245 else if (strcmp(buf, "access_token") == 0) { 246 gd->state = psAccessToken; 247 } 248 else if (strcmp(buf, "expires_in") == 0) { 249 gd->state = psExpiresIn; 250 } 251 else if (strcmp(buf, "refresh_token") == 0) { 252 gd->state = psRefreshToken; 253 } 254 else if (strcmp(buf, "scope") == 0) { 255 gd->state = psScope; 256 } 257 else if (strcmp(buf, "token_type") == 0) { 258 gd->state = psTokenType; 259 } 260 else if (strcmp(buf, "error") == 0) { 261 gd->state = psError; 262 } 263 else if (strcmp(buf, "error_description") == 0) { 264 gd->state = psErrorDescription; 265 } 266 break; 267 case psAccessToken: 268 if (state->type == JSONSL_T_STRING) { 269 strlcpy(gd->credential.access_token, buf, sizeof(gd->credential.access_token)); 270 gd->state = psRoot; 271 } 272 break; 273 case psExpiresIn: 274 if (state->type == JSONSL_T_SPECIAL) { 275 gd->credential.expires_in = atoi(buf); 276 gd->state = psRoot; 277 } 278 break; 279 case psRefreshToken: 280 if (state->type == JSONSL_T_STRING) { 281 strlcpy(gd->credential.refresh_token, buf, sizeof(gd->credential.refresh_token)); 282 gd->state = psRoot; 283 } 284 break; 285 case psScope: 286 if (state->type == JSONSL_T_STRING) { 287 strlcpy(gd->credential.scope, buf, sizeof(gd->credential.scope)); 288 gd->state = psRoot; 289 } 290 break; 291 case psTokenType: 292 if (state->type == JSONSL_T_STRING) { 293 strlcpy(gd->credential.token_type, buf, sizeof(gd->credential.token_type)); 294 gd->state = psRoot; 295 } 296 break; 297 case psError: 298 if (state->type == JSONSL_T_STRING) { 299 strlcpy(gd->error.error, buf, sizeof(gd->error.error)); 300 gd->state = psRoot; 301 } 302 break; 303 case psErrorDescription: 304 if (state->type == JSONSL_T_STRING) { 305 strlcpy(gd->error.error_description, buf, sizeof(gd->error.error_description)); 306 gd->state = psRoot; 307 } 308 break; 309 } 310 } 311 312 void get_access_token_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 313 { 314 } 315 316 int get_access_token(google_drive_t *gd) 317 { 318 client_info_t *client_info = &gd->client_info; 319 credential_t *credential = &gd->credential; 320 CURLcode ret; 321 CURL *curl; 322 struct curl_slist *slist1; 323 size_t len; 324 char *postdata; 325 jsonsl_t jsn = gd->jsn; 326 327 gd->jsn_buf_pos = -1; 328 329 jsonsl_reset(jsn); 330 gd->start = get_access_token_state_start; 331 gd->end = get_access_token_state_end; 332 333 slist1 = NULL; 334 slist1 = curl_slist_append(slist1, "Content-Type: application/x-www-form-urlencoded"); 335 336 curl = curl_easy_init(); 337 338 char *client_id = curl_easy_escape(curl, client_info->client_id, strnlen(client_info->client_id, sizeof(client_info->client_id))); 339 char *client_secret = curl_easy_escape(curl, client_info->client_secret, strnlen(client_info->client_secret, sizeof(client_info->client_secret))); 340 char *grant_type = curl_easy_escape(curl, GRANT_TYPE_DEVICE, strnlen(GRANT_TYPE_DEVICE, sizeof(GRANT_TYPE_DEVICE))); 341 342 len = sizeof("client_id=") + strlen(client_id) + sizeof("client_secret=") + strlen(client_secret) 343 + sizeof("code=") + strlen(credential->device_code) + sizeof("grant_type=") + strlen(grant_type); 344 postdata = malloc(len); 345 snprintf(postdata, len, "client_id=%s&client_secret=%s&code=%s&grant_type=%s", 346 client_id, client_secret, credential->device_code, grant_type); 347 348 curl_free(client_id); 349 curl_free(client_secret); 350 curl_free(grant_type); 351 352 curl_easy_setopt(curl, CURLOPT_URL, "https://www.googleapis.com/oauth2/v4/token"); 353 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata); 354 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)strnlen(postdata, len)); 355 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); 356 curl_setopt_common(curl); 357 358 curl_easy_setopt(curl, CURLOPT_WRITEDATA, gd); 359 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); 360 361 ret = curl_easy_perform(curl); 362 363 free(postdata); 364 365 curl_easy_cleanup(curl); 366 curl = NULL; 367 curl_slist_free_all(slist1); 368 slist1 = NULL; 369 370 return (int)ret; 371 } 372 373 void update_access_token_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 374 { 375 switch (gd->state) { 376 case psRoot: 377 if (state->level != 2) { 378 break; 379 } 380 else if (strcmp(buf, "access_token") == 0) { 381 gd->state = psAccessToken; 382 } 383 else if (strcmp(buf, "expires_in") == 0) { 384 gd->state = psExpiresIn; 385 } 386 else if (strcmp(buf, "scope") == 0) { 387 gd->state = psScope; 388 } 389 else if (strcmp(buf, "token_type") == 0) { 390 gd->state = psTokenType; 391 } 392 else if (strcmp(buf, "error") == 0) { 393 gd->state = psError; 394 } 395 else if (strcmp(buf, "error_description") == 0) { 396 gd->state = psErrorDescription; 397 } 398 break; 399 case psAccessToken: 400 if (state->type == JSONSL_T_STRING) { 401 strlcpy(gd->credential.access_token, buf, sizeof(gd->credential.access_token)); 402 gd->state = psRoot; 403 } 404 break; 405 case psExpiresIn: 406 if (state->type == JSONSL_T_SPECIAL) { 407 gd->credential.expires_in = atoi(buf); 408 gd->state = psRoot; 409 } 410 break; 411 case psScope: 412 if (state->type == JSONSL_T_STRING) { 413 strlcpy(gd->credential.scope, buf, sizeof(gd->credential.scope)); 414 gd->state = psRoot; 415 } 416 break; 417 case psTokenType: 418 if (state->type == JSONSL_T_STRING) { 419 strlcpy(gd->credential.token_type, buf, sizeof(gd->credential.token_type)); 420 gd->state = psRoot; 421 } 422 break; 423 case psError: 424 if (state->type == JSONSL_T_STRING) { 425 strlcpy(gd->error.error, buf, sizeof(gd->error.error)); 426 gd->state = psRoot; 427 } 428 break; 429 case psErrorDescription: 430 if (state->type == JSONSL_T_STRING) { 431 strlcpy(gd->error.error_description, buf, sizeof(gd->error.error_description)); 432 gd->state = psRoot; 433 } 434 break; 435 } 436 } 437 438 void update_access_token_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 439 { 440 } 441 442 int update_access_token(google_drive_t *gd) 443 { 444 client_info_t *client_info = &gd->client_info; 445 credential_t *credential = &gd->credential; 446 CURLcode ret; 447 CURL *curl; 448 struct curl_slist *slist1; 449 size_t len; 450 char *postdata; 451 jsonsl_t jsn = gd->jsn; 452 453 gd->jsn_buf_pos = -1; 454 455 jsonsl_reset(jsn); 456 gd->start = update_access_token_state_start; 457 gd->end = update_access_token_state_end; 458 459 slist1 = NULL; 460 slist1 = curl_slist_append(slist1, "Content-Type: application/x-www-form-urlencoded"); 461 462 curl = curl_easy_init(); 463 464 char *client_id = curl_easy_escape(curl, client_info->client_id, strnlen(client_info->client_id, sizeof(client_info->client_id))); 465 char *client_secret = curl_easy_escape(curl, client_info->client_secret, strnlen(client_info->client_secret, sizeof(client_info->client_secret))); 466 467 len = sizeof("client_id=") + strlen(client_id) + sizeof("client_secret=") + strlen(client_secret) 468 + sizeof("refresh_token=") + strlen(credential->refresh_token); 469 postdata = malloc(len); 470 snprintf(postdata, len, "client_id=%s&client_secret=%s&code=%s&grant_type=refresh_token", 471 client_id, client_secret, credential->refresh_token); 472 473 curl_free(client_id); 474 curl_free(client_secret); 475 476 curl_easy_setopt(curl, CURLOPT_URL, "https://www.googleapis.com/oauth2/v4/token"); 477 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata); 478 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)strnlen(postdata, len)); 479 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); 480 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); 481 curl_setopt_common(curl); 482 483 curl_easy_setopt(curl, CURLOPT_WRITEDATA, gd); 484 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); 485 486 ret = curl_easy_perform(curl); 487 488 free(postdata); 489 490 curl_easy_cleanup(curl); 491 curl = NULL; 492 curl_slist_free_all(slist1); 493 slist1 = NULL; 494 495 return (int)ret; 496 } 497 498 void revoke_device_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 499 { 500 } 501 502 void revoke_device_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 503 { 504 } 505 506 int revoke_device(google_drive_t *gd) 507 { 508 client_info_t *client_info = &gd->client_info; 509 credential_t *credential = &gd->credential; 510 CURLcode ret; 511 CURL *curl; 512 size_t len; 513 struct curl_slist *slist1; 514 char *postdata; 515 jsonsl_t jsn = gd->jsn; 516 517 gd->jsn_buf_pos = -1; 518 519 jsonsl_reset(jsn); 520 gd->start = revoke_device_state_start; 521 gd->end = revoke_device_state_end; 522 523 slist1 = NULL; 524 slist1 = curl_slist_append(slist1, "Content-Type: application/x-www-form-urlencoded"); 525 526 curl = curl_easy_init(); 527 528 len = sizeof("token=") + strlen(credential->access_token); 529 postdata = malloc(len); 530 snprintf(postdata, len, "token=%s", credential->access_token); 531 532 curl_easy_setopt(curl, CURLOPT_URL, "https://accounts.google.com/o/oauth2/revoke"); 533 curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postdata); 534 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)strnlen(postdata, len)); 535 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); 536 curl_setopt_common(curl); 537 538 curl_easy_setopt(curl, CURLOPT_WRITEDATA, gd); 539 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); 540 541 ret = curl_easy_perform(curl); 542 543 free(postdata); 544 545 curl_easy_cleanup(curl); 546 curl = NULL; 547 curl_slist_free_all(slist1); 548 slist1 = NULL; 549 550 return (int)ret; 551 } 552 553 void upload_file_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 554 { 555 switch (gd->state) { 556 case psRoot: 557 if (state->level != 2) { 558 break; 559 } 560 else if (strcmp(buf, "kind") == 0) { 561 gd->state = psKind; 562 } 563 else if (strcmp(buf, "id") == 0) { 564 gd->state = psId; 565 } 566 else if (strcmp(buf, "name") == 0) { 567 gd->state = psName; 568 } 569 else if (strcmp(buf, "mimeType") == 0) { 570 gd->state = psMimeType; 571 } 572 else if (strcmp(buf, "error") == 0) { 573 gd->state = psError; 574 } 575 else if (strcmp(buf, "error_description") == 0) { 576 gd->state = psErrorDescription; 577 } 578 break; 579 case psKind: 580 if (state->type == JSONSL_T_STRING) { 581 strlcpy(gd->file.kind, buf, sizeof(gd->file.kind)); 582 gd->state = psRoot; 583 } 584 break; 585 case psId: 586 if (state->type == JSONSL_T_STRING) { 587 strlcpy(gd->file.id, buf, sizeof(gd->file.id)); 588 gd->state = psRoot; 589 } 590 break; 591 case psName: 592 if (state->type == JSONSL_T_STRING) { 593 strlcpy(gd->file.name, buf, sizeof(gd->file.name)); 594 gd->state = psRoot; 595 } 596 break; 597 case psMimeType: 598 if (state->type == JSONSL_T_STRING) { 599 strlcpy(gd->file.mimeType, buf, sizeof(gd->file.mimeType)); 600 gd->state = psRoot; 601 } 602 break; 603 case psError: 604 if (state->type == JSONSL_T_STRING) { 605 strlcpy(gd->error.error, buf, sizeof(gd->error.error)); 606 gd->state = psRoot; 607 } 608 break; 609 case psErrorDescription: 610 if (state->type == JSONSL_T_STRING) { 611 strlcpy(gd->error.error_description, buf, sizeof(gd->error.error_description)); 612 gd->state = psRoot; 613 } 614 break; 615 } 616 } 617 618 void upload_file_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf) 619 { 620 } 621 622 size_t read_callback(char *buffer, size_t size, size_t nitems, void *arg) 623 { 624 FIL *file = (FIL *)arg; 625 UINT ret = 0; 626 FRESULT res; 627 628 res = f_read(file, buffer, size * nitems, &ret); 629 if (res != FR_OK) 630 return 0; 631 632 int rest = ret; 66 633 int len; 67 634 … … 76 643 response[len] = '\0'; 77 644 78 ntstdio_printf(&ntstdio,response);79 80 dly_tsk(100 * 1000);645 printf(response); 646 647 dly_tsk(100); 81 648 82 649 rest -= len; … … 84 651 } 85 652 86 return size * nmemb;87 }88 89 size_t read_data(char *buffer, size_t size, size_t nitems, void *instream)90 {91 FIL *file = (FIL *)instream;92 UINT ret = 0;93 FRESULT res;94 95 res = f_read(file, buffer, size * nitems, &ret);96 if (res != FR_OK)97 return 0;98 99 int rest = ret;100 int len;101 102 while (rest > 0) {103 len = rest;104 if (len > (sizeof(response) - 1)) {105 len = sizeof(response) - 1;106 }107 108 memcpy(response, buffer, len);109 110 response[len] = '\0';111 112 ntstdio_printf(&ntstdio, response);113 114 dly_tsk(100);115 116 rest -= len;117 buffer = (char *)buffer + len;118 }119 120 653 return ret; 121 654 } 122 655 123 char errbuf[CURL_ERROR_SIZE]; 656 int seek_callback(void *arg, curl_off_t offset, int origin) 657 { 658 FIL *file = (FIL *)arg; 659 BYTE mode; 660 FRESULT ret; 661 662 switch (origin) { 663 case SEEK_SET: 664 mode = F_SEEK_SET; 665 break; 666 case SEEK_CUR: 667 mode = F_SEEK_CUR; 668 break; 669 case SEEK_END: 670 mode = F_SEEK_END; 671 break; 672 default: 673 return CURL_SEEKFUNC_FAIL; 674 } 675 676 ret = f_seek(file, offset, mode); 677 if (ret != F_OK) 678 return CURL_SEEKFUNC_FAIL; 679 680 return CURL_SEEKFUNC_OK; 681 } 682 683 int upload_file(google_drive_t *gd, const char *filename, const char *localfilepath) 684 { 685 CURLcode ret; 686 CURL *curl; 687 curl_mime *mime; 688 curl_mimepart *part; 689 struct curl_slist *slist1; 690 size_t len; 691 char *postdata, *authorization; 692 static const char buf[] = "Expect:"; 693 jsonsl_t jsn = gd->jsn; 694 FIL file; 695 FRESULT fret; 696 697 gd->jsn_buf_pos = -1; 698 699 jsonsl_reset(jsn); 700 gd->start = upload_file_state_start; 701 gd->end = upload_file_state_end; 702 703 fret = f_open(&file, localfilepath, FA_READ); 704 if (fret != FR_OK) { 705 printf("log file open error %d\n", fret); 706 return -1; 707 } 708 709 len = sizeof("{\"name\":\"\"}") + strlen(filename); 710 postdata = malloc(len); 711 snprintf(postdata, len, "{\"name\":\"%s\"}", filename); 712 713 curl = curl_easy_init(); 714 715 mime = curl_mime_init(curl); 716 part = curl_mime_addpart(mime); 717 curl_mime_name(part, "metadata"); 718 curl_mime_type(part, "application/json;charset=utf-8"); 719 curl_mime_data(part, postdata, CURL_ZERO_TERMINATED); 720 free(postdata); 721 722 part = curl_mime_addpart(mime); 723 curl_mime_name(part, "file"); 724 curl_mime_type(part, "application/json"); 725 curl_mime_data_cb(part, file.fsize, read_callback, seek_callback, NULL, &file); 726 727 len = sizeof("Authorization: Bearer ") + strnlen(gd->credential.access_token, sizeof(gd->credential.access_token)); 728 authorization = malloc(len); 729 snprintf(authorization, len, "Authorization: Bearer %s", gd->credential.access_token); 730 slist1 = NULL; 731 slist1 = curl_slist_append(slist1, authorization); 732 free(authorization); 733 734 slist1 = curl_slist_append(slist1, buf); 735 736 curl_easy_setopt(curl, CURLOPT_URL, "https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart"); 737 curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, 1L); 738 curl_easy_setopt(curl, CURLOPT_MIMEPOST, mime); 739 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); 740 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "POST"); 741 curl_setopt_common(curl); 742 743 curl_easy_setopt(curl, CURLOPT_WRITEDATA, gd); 744 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); 745 746 ret = curl_easy_perform(curl); 747 748 curl_easy_cleanup(curl); 749 curl = NULL; 750 curl_mime_free(mime); 751 mime = NULL; 752 curl_slist_free_all(slist1); 753 slist1 = NULL; 754 755 f_close(&file); 756 757 return (int)ret; 758 } 759 760 int google_drive_error_callback(jsonsl_t jsn, jsonsl_error_t err, 761 struct jsonsl_state_st *state, char *errat) 762 { 763 return 0; 764 } 765 766 void google_drive_state_callback(jsonsl_t jsn, jsonsl_action_t action, 767 struct jsonsl_state_st *state, const char *buf) 768 { 769 google_drive_t *gd = (google_drive_t *)jsn->data; 770 771 switch (action) { 772 case JSONSL_ACTION_PUSH: 773 switch (state->type) { 774 case JSONSL_T_SPECIAL: 775 gd->jsn_buf[0] = *buf; 776 gd->jsn_buf_pos = 1; 777 break; 778 case JSONSL_T_STRING: 779 case JSONSL_T_HKEY: 780 gd->jsn_buf_pos = 0; 781 break; 782 default: 783 gd->jsn_buf_pos = -1; 784 } 785 break; 786 case JSONSL_ACTION_POP: 787 switch (state->type) { 788 case JSONSL_T_SPECIAL: 789 case JSONSL_T_STRING: 790 case JSONSL_T_HKEY: 791 gd->jsn_buf_pos--; 792 if (gd->jsn_buf_pos < sizeof(gd->jsn_buf)) { 793 gd->jsn_buf[gd->jsn_buf_pos] = '\0'; 794 } 795 gd->start(gd, state, gd->jsn_buf); 796 break; 797 default: 798 gd->jsn_buf[0] = '\0'; 799 break; 800 } 801 gd->jsn_buf_pos = -1; 802 break; 803 default: 804 gd->jsn_buf_pos = -1; 805 break; 806 } 807 } 124 808 125 809 static void get_logfname(char *fname) … … 185 869 ret = f_open(&file, fname, FA_CREATE_ALWAYS | FA_WRITE); 186 870 if (ret != FR_OK) { 187 ntstdio_printf(&ntstdio,"not open a upload file %d\n", ret);871 printf("not open a upload file %d\n", ret); 188 872 return ret; 189 873 } … … 232 916 f_putc('}', &file); 233 917 234 file_close:235 918 f_close(&file); 236 919 … … 238 921 } 239 922 240 void client_task(intptr_t exinf) 241 { 242 CURL *curl; 923 void curl_setopt_common(CURL *curl) 924 { 243 925 CURLcode res; 244 int error = 0;245 //const char *data = "{\"value\":\"data post\"}";246 struct curl_slist *list = NULL;247 FIL file;248 FRESULT ret;249 char fname[] = {"1:/log/20160101000000.log"};250 251 get_logfname(fname);252 253 ret = write_log(fname);254 if (ret != FR_OK) {255 ntstdio_printf(&ntstdio, "log file write error %d\n", ret);256 return;257 }258 259 ret = f_open(&file, fname, FA_READ);260 if (ret != FR_OK) {261 ntstdio_printf(&ntstdio, "log file open error %d\n", ret);262 return;263 }264 265 ntstdio_printf(&ntstdio, "cURL start\n");266 267 curl = curl_easy_init();268 if (curl == NULL) {269 ntstdio_printf(&ntstdio, "curl_easy_init() failed\n");270 goto file_close;271 }272 926 273 927 /* ask libcurl to show us the verbose output */ 274 curl_easy_setopt(curl, CURLOPT_VERBOSE, true); 275 276 res = curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/"); 928 res = curl_easy_setopt(curl, CURLOPT_VERBOSE, true); 277 929 if (res != CURLE_OK) 278 ntstdio_printf(&ntstdio, "CURLOPT_URLfailed: %s\n",930 printf("CURLOPT_VERBOSE failed: %s\n", 279 931 curl_easy_strerror(res)); 280 932 … … 283 935 284 936 /* provide a buffer to store errors in */ 285 curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); 937 res = curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, errbuf); 938 if (res != CURLE_OK) 939 printf("CURLOPT_ERRORBUFFER failed: %s\n", 940 curl_easy_strerror(res)); 286 941 287 942 #ifdef SKIP_PEER_VERIFICATION … … 298 953 res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L); 299 954 if (res != CURLE_OK) 300 ntstdio_printf(&ntstdio,"CURLOPT_SSL_VERIFYPEER failed: %s\n",955 printf("CURLOPT_SSL_VERIFYPEER failed: %s\n", 301 956 curl_easy_strerror(res)); 302 957 #else 303 958 res = curl_easy_setopt(curl, CURLOPT_CAINFO, "0:/certs/ca-cert.pem"); 304 959 if (res != CURLE_OK) 305 ntstdio_printf(&ntstdio,"CURLOPT_CAINFO failed: %s\n",960 printf("CURLOPT_CAINFO failed: %s\n", 306 961 curl_easy_strerror(res)); 307 962 308 963 res = curl_easy_setopt(curl, CURLOPT_SSLCERT, "0:/certs/client-cert.pem"); 309 964 if (res != CURLE_OK) 310 ntstdio_printf(&ntstdio,"CURLOPT_SSLCERT failed: %s\n",965 printf("CURLOPT_SSLCERT failed: %s\n", 311 966 curl_easy_strerror(res)); 312 967 313 968 res = curl_easy_setopt(curl, CURLOPT_SSLKEY, "0:/certs/client-key.pem"); 314 969 if (res != CURLE_OK) 315 ntstdio_printf(&ntstdio,"CURLOPT_SSLKEY failed: %s\n",970 printf("CURLOPT_SSLKEY failed: %s\n", 316 971 curl_easy_strerror(res)); 317 972 #endif … … 326 981 res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L); 327 982 if (res != CURLE_OK) 328 ntstdio_printf(&ntstdio,"CURLOPT_SSL_VERIFYHOST failed: %s\n",983 printf("CURLOPT_SSL_VERIFYHOST failed: %s\n", 329 984 curl_easy_strerror(res)); 330 985 #endif … … 332 987 /*res = curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example.com:8080"); 333 988 if (res != CURLE_OK) 334 ntstdio_printf(&ntstdio,"CURLOPT_PROXY failed: %s\n",989 printf("CURLOPT_PROXY failed: %s\n", 335 990 curl_easy_strerror(res));*/ 336 991 337 curl_easy_setopt(curl, CURLOPT_POST, 1); 338 339 /* size of the POST data */ 340 //curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(data)); 341 curl_easy_setopt(curl, CURLOPT_POSTFIELDSIZE, file.fsize); 342 343 /* pass in a pointer to the data - libcurl will not copy */ 344 //curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data); 345 346 list = curl_slist_append(list, "Content-Type: application/json"); 347 348 curl_easy_setopt(curl, CURLOPT_HTTPHEADER, list); 349 350 curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&error); 351 352 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); 353 354 /* now specify which file to upload */ 355 curl_easy_setopt(curl, CURLOPT_READDATA, &file); 356 357 /* we want to use our own read function */ 358 curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_data); 359 360 ntstdio_printf(&ntstdio, "cURL perform the request\n"); 361 tslp_tsk(100 * 1000); 362 363 /* Perform the request, res will get the return code */ 364 res = curl_easy_perform(curl); 365 /* Check for errors */ 366 if (res != CURLE_OK) { 367 ntstdio_printf(&ntstdio, "curl_easy_perform() failed: %s\n", 992 res = curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L); 993 if (res != CURLE_OK) 994 printf("CURLOPT_NOPROGRESS failed: %s\n", 368 995 curl_easy_strerror(res)); 369 ntstdio_printf(&ntstdio, errbuf); 370 } 371 372 /* always cleanup */ 373 curl_easy_cleanup(curl); 374 375 ntstdio_printf(&ntstdio, "cURL end\n"); 376 377 file_close: 378 f_close(&file); 379 } 380 381 void client_fin(void) 382 { 996 997 res = curl_easy_setopt(curl, CURLOPT_MAXREDIRS, 50L); 998 if (res != CURLE_OK) 999 printf("CURLOPT_MAXREDIRS failed: %s\n", 1000 curl_easy_strerror(res)); 1001 1002 res = curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 1L); 1003 if (res != CURLE_OK) 1004 printf("CURLOPT_TCP_KEEPALIVE failed: %s\n", 1005 curl_easy_strerror(res)); 1006 } 1007 1008 void client_set_client_id(const char *client_id) 1009 { 1010 google_drive_t *gd = &google_drive; 1011 1012 strlcpy(gd->client_info.client_id, client_id, sizeof(gd->client_info.client_id)); 1013 } 1014 1015 void client_set_client_secret(const char *client_secret) 1016 { 1017 google_drive_t *gd = &google_drive; 1018 1019 strlcpy(gd->client_info.client_secret, client_secret, sizeof(gd->client_info.client_secret)); 1020 } 1021 1022 int client_get_device_id(int argc, char **argv) 1023 { 1024 google_drive_t *gd = &google_drive; 1025 int ret; 1026 1027 ret = get_device_id(gd, SCOPE_DRIVE_FILE); 1028 if (ret == 0) { 1029 printf("Device was registered. Enter the code at the following URL\n"); 1030 printf("url: %s\n", gd->credential.verification_url); 1031 printf("code: %s\n", gd->credential.user_code); 1032 } 1033 else { 1034 printf("Device register failed! %d\n", ret); 1035 } 1036 1037 return ret; 1038 } 1039 1040 int client_get_access_token(int argc, char **argv) 1041 { 1042 google_drive_t *gd = &google_drive; 1043 int ret; 1044 1045 ret = get_access_token(gd); 1046 if (ret == 0) { 1047 printf("Access token was give\n"); 1048 printf("Refresh token: %s\n", gd->credential.refresh_token); 1049 printf("Access token: %s\n", gd->credential.access_token); 1050 } 1051 else { 1052 printf("Access token gain failed. %d\n", ret); 1053 } 1054 1055 return ret; 1056 } 1057 1058 int client_update_access_token(int argc, char **argv) 1059 { 1060 google_drive_t *gd = &google_drive; 1061 int ret; 1062 1063 ret = update_access_token(gd); 1064 if (ret == 0) { 1065 printf("Access token was update\n"); 1066 printf("Access token: %s\n", gd->credential.access_token); 1067 } 1068 else { 1069 printf("Access token update failed. %d\n", ret); 1070 } 1071 1072 return ret; 1073 } 1074 1075 int client_revoke(int argc, char **argv) 1076 { 1077 google_drive_t *gd = &google_drive; 1078 int ret; 1079 1080 ret = revoke_device(gd); 1081 if (ret == 0) { 1082 printf("Device was revoked.\n"); 1083 } 1084 else { 1085 printf("Device revoke failed. %d\n", ret); 1086 } 1087 1088 return ret; 1089 } 1090 1091 int client_upload_file(int argc, char **argv) 1092 { 1093 google_drive_t *gd = &google_drive; 1094 int ret; 1095 FRESULT fret; 1096 char fname[] = { "1:/log/20160101000000.log" }; 1097 1098 get_logfname(fname); 1099 1100 fret = write_log(fname); 1101 if (fret != FR_OK) { 1102 printf("log file write error %d\n", fret); 1103 return (int)fret; 1104 } 1105 1106 ret = upload_file(gd, &fname[7], fname); 1107 if (ret == 0) { 1108 printf("%s was uploaded.\n", &fname[7]); 1109 } 1110 else { 1111 printf("%s upload failed. %d\n", &fname[7], ret); 1112 } 1113 1114 return ret; 1115 } 1116 1117 void client_final(void) 1118 { 1119 google_drive_t *gd = &google_drive; 1120 jsonsl_t jsn = gd->jsn; 1121 383 1122 curl_global_cleanup(); 384 } 1123 jsonsl_destroy(jsn); 1124 } -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/client.h
r352 r364 39 39 #define _CLIENT_H_ 40 40 41 #include <kernel.h> 42 #include "target_kernel_impl.h" 41 typedef struct client_info_t { 42 char client_id[80]; 43 char client_secret[32]; 44 } client_info_t; 43 45 44 #define CLIENT_PRIORITY 4 /* クライアントタスクの優先度 */ 46 typedef struct credential_t { 47 char device_code[100]; 48 char user_code[12]; 49 int expires_in; 50 int interval; 51 char verification_url[32]; 52 char access_token[132]; 53 char refresh_token[64]; 54 char scope[64]; 55 char token_type[16]; 56 } credential_t; 45 57 46 #define CLIENT_STACK_SIZE 6144 /* スタック領域のサイズ */ 58 typedef struct error_response_t { 59 char error[64]; 60 char error_description[64]; 61 } error_response_t; 47 62 48 extern void client_init(void); 49 extern void client_task(intptr_t exinf); 50 extern void client_fin(void); 63 typedef struct drive_file_t { 64 char kind[32]; 65 char id[36]; 66 char name[256]; 67 char mimeType[40]; 68 } drive_file_t; 69 70 typedef enum google_drive_parse_state_t { 71 psRoot, 72 psDeviceCode, 73 psUserCode, 74 psExpiresIn, 75 psInterval, 76 psVerificationUrl, 77 psAccessToken, 78 psRefreshToken, 79 psScope, 80 psTokenType, 81 psKind, 82 psId, 83 psName, 84 psMimeType, 85 psError, 86 psErrorDescription, 87 } google_drive_parse_state_t; 88 89 struct jsonsl_st; 90 typedef struct jsonsl_st *jsonsl_t; 91 92 typedef void (*parser_callback_t)(struct google_drive_t *gd, struct jsonsl_state_st *state, const char *buf); 93 94 typedef struct google_drive_t { 95 client_info_t client_info; 96 credential_t credential; 97 drive_file_t file; 98 error_response_t error; 99 jsonsl_t jsn; 100 google_drive_parse_state_t state; 101 char fname[sizeof("1:/log/20160101000000.log")]; 102 char jsn_buf[256]; 103 int jsn_buf_pos; 104 parser_callback_t start; 105 parser_callback_t end; 106 } google_drive_t; 107 108 extern google_drive_t google_drive; 109 110 void client_init(void); 111 void client_final(void); 112 113 void client_set_client_id(const char *client_id); 114 void client_set_client_secret(const char *client_secret); 115 int client_get_device_id(int argc, char **argv); 116 int client_get_access_token(int argc, char **argv); 117 int client_update_access_token(int argc, char **argv); 118 int client_revoke(int argc, char **argv); 119 int client_upload_file(int argc, char **argv); 51 120 52 121 #endif /* _CLIENT_H_ */ -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/echonet_main.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2016-2018 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ 37 37 38 /* 38 /* 39 39 * サンプルプログラム(1)の本体 40 40 */ … … 164 164 { 165 165 /* サイズが1以外は受け付けない */ 166 if (size != 1)166 if (size != 1) 167 167 return 0; 168 168 169 169 *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src); 170 170 171 switch (*(uint8_t *)src){171 switch (*(uint8_t *)src) { 172 172 /* ONの場合 */ 173 173 case 0x30: … … 196 196 { 197 197 /* サイズが1以外は受け付けない */ 198 if (size != 1)198 if (size != 1) 199 199 return 0; 200 200 201 201 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 202 202 203 switch (*(uint8_t *)src){203 switch (*(uint8_t *)src) { 204 204 /* 異常発生ありの場合 */ 205 205 case 0x41: … … 271 271 int date_prop_set(const EPRPINIB *item, const void *src, int size, bool_t *anno) 272 272 { 273 uint8_t *p_src;273 const uint8_t *p_src; 274 274 time_t temp; 275 275 struct tm _tm; … … 283 283 /* 年月日設定 */ 284 284 p_src = (uint8_t *)src; 285 _tm.tm_year = (* (p_src++)* 100) + *p_src++;285 _tm.tm_year = (*p_src++ * 100) + *p_src++; 286 286 _tm.tm_mon = (*p_src++) - 1; 287 287 _tm.tm_mday = *p_src++; … … 325 325 326 326 /* サイズが4以外は受け付けない */ 327 if (size != 4)327 if (size != 4) 328 328 return 0; 329 329 … … 345 345 346 346 len = 48 - meter->current_pos; 347 if (len > 0)347 if (len > 0) 348 348 memcpy(dst, &meter->integral_electric_energy_measurement_log[meter->current_pos], sizeof(uint32_t) * len); 349 349 dst = &((uint8_t *)dst)[len]; … … 404 404 405 405 ret2 = get_tim(&now); 406 if (ret2 != E_OK) {406 if (ret2 != E_OK) { 407 407 syslog(LOG_ERROR, "get_tim"); 408 408 return; 409 409 } 410 410 411 for (;;){411 for (;;) { 412 412 prev = now; 413 413 … … 417 417 /* 応答電文待ち */ 418 418 ret = ecn_trcv_esv(&esv, timer); 419 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {419 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) { 420 420 syslog(LOG_ERROR, "ecn_trcv_esv"); 421 421 break; … … 423 423 424 424 ret2 = get_tim(&now); 425 if (ret2 != E_OK) {425 if (ret2 != E_OK) { 426 426 syslog(LOG_ERROR, "get_tim"); 427 427 break; … … 438 438 /* 領域解放 */ 439 439 ret = ecn_rel_esv(esv); 440 if (ret != E_OK) {440 if (ret != E_OK) { 441 441 syslog(LOG_ERROR, "ecn_rel_esv"); 442 442 break; … … 447 447 /* 応答電文待ちの割り込みデータ取得 */ 448 448 ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len); 449 if (ret != E_OK) {449 if (ret != E_OK) { 450 450 syslog(LOG_ERROR, "ecn_get_brk_dat"); 451 451 break; … … 457 457 /* 領域解放 */ 458 458 ret = ecn_rel_esv(esv); 459 if (ret != E_OK) {459 if (ret != E_OK) { 460 460 syslog(LOG_ERROR, "ecn_rel_esv"); 461 461 break; … … 468 468 } 469 469 470 bool_t started = false;471 472 470 void echonet_change_netif_link(uint8_t link_up, uint8_t up) 473 471 { … … 477 475 return; 478 476 479 if (up && !started) { 480 started = true; 481 482 /* ECHONETミドルウェアを起動 */ 483 ret = ecn_sta_svc(); 484 if (ret != E_OK) 485 return; 486 487 /* ECHONETミドルウェアを起動するのを待つ */ 488 dly_tsk(100); 477 if (up) { 478 /* インスタンスリスト通知の送信 */ 479 ret = ecn_ntf_inl(); 480 if (ret != E_OK) { 481 syslog(LOG_ERROR, "ecn_ntf_inl"); 482 } 489 483 } 490 484 … … 500 494 } 501 495 502 enum main_state_t{ 496 enum main_state_t { 497 main_state_start, 503 498 main_state_idle, 504 499 }; 505 500 506 501 int main_timer = TMO_FEVR; 507 enum main_state_t main_state = main_state_ idle;502 enum main_state_t main_state = main_state_start; 508 503 int main_lcd_state = 0; 509 504 int main_lcd_timer = TMO_FEVR; … … 557 552 analogin_init(&joystick, P1_12); 558 553 559 /* 10ms後にボタン状態を確認*/560 main_ timer = 10 * 1000;561 562 /* ボタン状態読み込み */ 554 /* ECHONETミドルウェアを起動するのを待つ */ 555 main_state = main_state_start; 556 main_timer = 1000 * 1000; 557 563 558 btn = main_read_button(&joystick); 564 559 main_btn1_state = btn == BUTTON_LEFT; … … 568 563 spi_init(&lcd.hspi, P10_14, P10_15, P10_12, NC); 569 564 spi_format(&lcd.hspi, 8, 0, 0); 570 spi_frequency(&lcd.hspi, 1000000);565 spi_frequency(&lcd.hspi, 4000000); 571 566 572 567 gpio_init_out(&lcd.cs_pin, P10_13); … … 590 585 main_adv_timer = 1000 * 1000; 591 586 587 /* メインタスクを起動 */ 592 588 ER ret = act_tsk(MAIN_TASK); 593 589 if (ret != E_OK) { … … 603 599 int result = main_timer; 604 600 605 if ((result == TMO_FEVR)606 || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))) {601 if ((result == TMO_FEVR) 602 || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))) { 607 603 result = main_lcd_timer; 608 604 } … … 621 617 static void main_progress(int interval) 622 618 { 623 if (main_timer != TMO_FEVR){619 if (main_timer != TMO_FEVR) { 624 620 main_timer -= interval; 625 if (main_timer < 0){621 if (main_timer < 0) { 626 622 main_timer = 0; 627 623 } 628 624 } 629 625 630 if (main_lcd_timer != TMO_FEVR){626 if (main_lcd_timer != TMO_FEVR) { 631 627 main_lcd_timer -= interval; 632 if (main_lcd_timer < 0){628 if (main_lcd_timer < 0) { 633 629 main_lcd_timer = 0; 634 630 } … … 655 651 656 652 ret = ecn_itr_ini(&enm, esv); 657 if (ret != E_OK){653 if (ret != E_OK) { 658 654 syslog(LOG_ERROR, "ecn_itr_ini"); 659 655 return; 660 656 } 661 657 662 for (;;) {663 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {658 for (;;) { 659 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) { 664 660 switch (epc) { 665 661 case 0x80: … … 669 665 } 670 666 } 671 if (ret != E_BOVR){667 if (ret != E_BOVR) { 672 668 syslog(LOG_ERROR, "ecn_itr_nxt"); 673 669 break; 674 670 } 675 if (enm.is_eof)671 if (enm.is_eof) 676 672 break; 677 673 } … … 684 680 { 685 681 char mac_text[30] = "mac: "; 686 char ipaddr_text[30] = "ipad dr: ";687 T_IN4_ADDR *ip4_addr;682 char ipaddr_text[30] = "ipadr: "; 683 const T_IN4_ADDR *ip4_addr; 688 684 int pos; 689 685 690 switch (main_state){686 switch (main_state) { 691 687 case main_state_idle: 692 688 if (len == 0) … … 704 700 pos = str_macaddr(&mac_text[4], sizeof(mac_text) - 4, mac_addr, 0); 705 701 mac_text[pos + 4] = '\0'; 706 lcd_drawString(&lcd, mac_text, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 14) + 10, ST7735_BLACK, ST7735_WHITE);702 lcd_drawString(&lcd, mac_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 11), ST7735_BLACK, ST7735_WHITE); 707 703 708 704 ip4_addr = in4_get_ifaddr(0); 709 pos = str_ipv4addr(&ipaddr_text[ 7], sizeof(ipaddr_text) - 7, ip4_addr, 0);710 ipaddr_text[pos + 7] = '\0';711 lcd_drawString(&lcd, ipaddr_text, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 15) + 10, ST7735_BLACK, ST7735_WHITE);705 pos = str_ipv4addr(&ipaddr_text[6], sizeof(ipaddr_text) - 6, ip4_addr, 0); 706 ipaddr_text[pos + 6] = '\0'; 707 lcd_drawString(&lcd, ipaddr_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 12), ST7735_BLACK, ST7735_WHITE); 712 708 } 713 709 break; … … 724 720 static void main_timeout() 725 721 { 726 if (main_timer == 0){722 if (main_timer == 0) { 727 723 main_ontimer(); 728 724 } 729 725 730 if (main_lcd_timer == 0){726 if (main_lcd_timer == 0) { 731 727 main_lcd_ontimer(); 732 728 } … … 746 742 int port_no, btn; 747 743 748 switch (main_lcd_state) {744 switch (main_lcd_state) { 749 745 case 0: 750 746 case 1: … … 757 753 text[16] = '0' + main_7seg[port_no][2]; 758 754 text[17] = '0' + main_7seg[port_no][3]; 759 lcd_drawString(&lcd, &text[14], X_LINE_HALF_TO_PIX(&lcd, 11) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);755 lcd_drawString(&lcd, &text[14], X_LINE_HALF_TO_PIX(&lcd, 11), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE); 760 756 main_lcd_state++; 761 757 break; 762 758 case 6: 763 759 btn = main_read_button(&joystick); 764 lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 10) + 10, ST7735_BLACK, ST7735_WHITE);760 lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 9), ST7735_BLACK, ST7735_WHITE); 765 761 main_lcd_state++; 766 762 break; … … 769 765 break; 770 766 case 10: 771 lcd_drawString(&lcd, "USB電力計", X_LINE_TO_PIX(&lcd, 10) + 10, Y_ROW_TO_PIX(&lcd, 0) + 10, ST7735_BLACK, ST7735_WHITE);767 lcd_drawString(&lcd, "USB電力計", X_LINE_TO_PIX(&lcd, 6), Y_ROW_TO_PIX(&lcd, 0), ST7735_BLACK, ST7735_WHITE); 772 768 for (port_no = 0; port_no < 6; port_no++) { 773 769 text[3] = '1' + port_no; 774 lcd_drawString(&lcd, text, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, port_no + 4) + 10, ST7735_BLACK, ST7735_WHITE);770 lcd_drawString(&lcd, text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, port_no + 2), ST7735_BLACK, ST7735_WHITE); 775 771 } 776 772 main_lcd_state = 0; … … 802 798 static void main_ontimer() 803 799 { 800 ER ret; 804 801 uint8_t btn; 805 802 uint16_t ad_value; 806 803 807 switch(main_state){ 804 switch (main_state) { 805 case main_state_start: 806 /* ECHONETミドルウェアを起動 */ 807 ret = ecn_sta_svc(); 808 if (ret != E_OK) { 809 syslog(LOG_ERROR, "ecn_sta_svc"); 810 } 811 812 /* 10ms後にボタン状態を確認 */ 813 main_state = main_state_idle; 814 main_timer = 10 * 1000; 815 break; 808 816 case main_state_idle: 809 817 /* 10ms後にボタン状態を確認 */ … … 845 853 846 854 /* ボタン1の処理 */ 847 if ((btn == BUTTON_LEFT) && !main_btn1_state){855 if ((btn == BUTTON_LEFT) && !main_btn1_state) { 848 856 main_btn1_count++; 849 if (main_btn1_count > 10){857 if (main_btn1_count > 10) { 850 858 main_btn1_count = 0; 851 859 main_btn1_state = true; … … 854 862 } 855 863 } 856 else if ((btn != BUTTON_LEFT) && main_btn1_state){864 else if ((btn != BUTTON_LEFT) && main_btn1_state) { 857 865 main_btn1_count++; 858 if (main_btn1_count > 10){866 if (main_btn1_count > 10) { 859 867 main_btn1_count = 0; 860 868 main_btn1_state = false; … … 865 873 866 874 /* ボタン2の処理 */ 867 if ((btn == BUTTON_RIGHT) && !main_btn2_state){875 if ((btn == BUTTON_RIGHT) && !main_btn2_state) { 868 876 main_btn2_count++; 869 if (main_btn2_count > 10){877 if (main_btn2_count > 10) { 870 878 main_btn2_count = 0; 871 879 main_btn2_state = true; … … 874 882 } 875 883 } 876 else if ((btn != BUTTON_RIGHT) && main_btn2_state){884 else if ((btn != BUTTON_RIGHT) && main_btn2_state) { 877 885 main_btn2_count++; 878 if (main_btn2_count > 10){886 if (main_btn2_count > 10) { 879 887 main_btn2_count = 0; 880 888 main_btn2_state = false; … … 897 905 static uint8_t main_read_button(analogin_t *obj) 898 906 { 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 907 float a = analogin_read(obj); 908 909 a *= 5.0; 910 911 //printf("Button read analog = %f\r\n",a); 912 if (a < 0.2) 913 return BUTTON_DOWN; 914 if (a < 1.0) 915 return BUTTON_RIGHT; 916 if (a < 1.7) 917 return BUTTON_SELECT; 918 if (a < 2.6) 919 return BUTTON_UP; 920 if (a < 4.6) 921 return BUTTON_LEFT; 922 else 923 return BUTTON_NONE; 916 924 } 917 925 … … 924 932 { 925 933 /* 押されて戻った時に処理する */ 926 if (push)934 if (push) 927 935 return; 928 936 929 937 /* 表示ポート番号 */ 930 if (!main_rev){938 if (!main_rev) { 931 939 main_port_no--; 932 if (main_port_no < 1){940 if (main_port_no < 1) { 933 941 main_port_no = 1; 934 942 main_rev = true; … … 936 944 } 937 945 } 938 else {946 else { 939 947 main_port_no++; 940 if (main_port_no > main_ad_count){948 if (main_port_no > main_ad_count) { 941 949 main_port_no = main_ad_count; 942 950 main_rev = false; … … 952 960 { 953 961 /* 押されて戻った時に処理する */ 954 if (push)962 if (push) 955 963 return; 956 964 … … 961 969 962 970 /* 表示ポート番号 */ 963 if (!main_rev){971 if (!main_rev) { 964 972 main_port_no++; 965 if (main_port_no > main_ad_count){973 if (main_port_no > main_ad_count) { 966 974 main_port_no = main_ad_count; 967 975 main_rev = false; … … 969 977 } 970 978 } 971 else {979 else { 972 980 main_port_no--; 973 if (main_port_no < 1){981 if (main_port_no < 1) { 974 982 main_port_no = 1; 975 983 main_rev = true; … … 988 996 989 997 main_port_no++; 990 if (main_port_no > main_ad_count)998 if (main_port_no > main_ad_count) 991 999 main_port_no = 1; 992 1000 -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.c
r359 r364 45 45 #include <sil.h> 46 46 #include <setjmp.h> 47 #include <stdlib.h> 47 48 #include <string.h> 48 49 #include "syssvc/serial.h" … … 80 81 81 82 ID ws_api_mailboxid = MAIN_DATAQUEUE; 83 #ifndef NOUSE_MPF_NET_BUF 82 84 ID ws_mempoolid = MPF_NET_BUF_256; 85 #endif 83 86 84 87 #if defined(IF_ETHER_BTUSB) || defined(IF_ETHER_ENBT) … … 114 117 static void main_timeout(); 115 118 119 extern int ntshell_exit; 120 116 121 int uart_read(char *buf, int cnt, void *extobj) 117 122 { 118 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 123 struct main_t *obj = (struct main_t *)extobj; 124 int result; 125 ER ret; 126 int timer; 127 128 obj->prev = obj->now; 129 130 /* タイマー取得 */ 131 timer = main_get_timer(); 132 133 /* 待ち */ 134 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 135 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 136 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 137 ntshell_exit = 1; 138 return -1; 139 } 140 result = (int)ret; 141 142 ret = get_tim(&obj->now); 143 if (ret != E_OK) { 144 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 145 ntshell_exit = 1; 146 return -1; 147 } 148 149 /* 時間経過 */ 150 int elapse = obj->now - obj->prev; 151 main_progress(elapse); 152 153 /* タイムアウト処理 */ 154 main_timeout(); 155 156 return result; 119 157 } 120 158 … … 122 160 { 123 161 return serial_wri_dat(SIO_PORTID, buf, cnt); 124 }125 126 unsigned char ntstdio_xi(struct ntstdio_t *handle)127 {128 char buf[1];129 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)130 return -EIO;131 return buf[0];132 }133 134 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)135 {136 char buf[1];137 buf[0] = c;138 serial_wri_dat(SIO_PORTID, buf, 1);139 162 } 140 163 … … 156 179 main_initialize(); 157 180 158 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);181 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj); 159 182 ntshell_set_prompt(&ntshell, "NTShell>"); 160 183 ntshell_execute(&ntshell); … … 176 199 ER ret; 177 200 201 #ifdef TOPPERS_OMIT_TECS 202 serial_opn_por(SIO_PORTID); 203 #endif 204 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 205 178 206 //wolfSSL_Debugging_ON(); 179 207 180 ntshell_task_init( );208 ntshell_task_init(uart_read, uart_write, &main_obj); 181 209 182 210 main_obj.timer = TMO_FEVR; … … 313 341 } 314 342 343 int cmd_creid(int argc, char **argv) 344 { 345 if (argc != 2) { 346 printf("creid {client_id}\n"); 347 return 0; 348 } 349 350 client_set_client_id(argv[1]); 351 352 return 0; 353 } 354 355 int cmd_secret(int argc, char **argv) 356 { 357 if (argc != 2) { 358 printf("secret {client_secret}\n"); 359 return 0; 360 } 361 362 client_set_client_secret(argv[1]); 363 364 return 0; 365 } 366 315 367 int cmd_logupload(int argc, char **argv) 316 368 { 317 client_task(0); 318 return 0; 369 return client_upload_file(argc, argv); 319 370 } 320 371 … … 335 386 {"dnsc", "DNS client", usrcmd_dnsc }, 336 387 {"ntpc", "NTP client", usrcmd_ntpc }, 388 {"creid", "Regster device", cmd_creid}, 389 {"secret", "Regster device", cmd_secret}, 390 {"gdi", "get_device_id", client_get_device_id}, 391 {"gat", "get_access_token", client_get_access_token}, 392 {"uat", "update_access_token", client_update_access_token}, 393 {"rd", "revoke device", client_revoke}, 394 {"uf", "upload_file", client_upload_file}, 337 395 {"logupload", "Upload log to server", cmd_logupload}, 338 396 {"info", "This is a description text string for info command.", usrcmd_info}, -
asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.cfg
r352 r364 54 54 INCLUDE("tinet/tinet_asp.cfg"); 55 55 INCLUDE("tinet_main.cfg"); 56 INCLUDE("netinet/ip_igmp.cfg");57 56 58 57 /* DHCP クライアント */ -
asp3_tinet_ecnl_arm/trunk/app2_light/.cproject
r352 r364 22 22 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 23 23 <option id="toolchain.id" value="gcc-arm-embedded"/> 24 <option id="toolchain.version" value=" 5.4.1.20160919"/>24 <option id="toolchain.version" value="6.3.1.20170620"/> 25 25 </storageModule> 26 26 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 59 59 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.913962636" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 60 60 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.812015080" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 61 <builder buildPath="${workspace_loc:/app2_light}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1678746512" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>61 <builder buildPath="${workspace_loc:/app2_light}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1678746512" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 62 62 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1300910948" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 63 63 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.821934622" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 127 127 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 128 128 <option id="toolchain.id" value="gcc-arm-embedded"/> 129 <option id="toolchain.version" value=" 5.4.1.20160919"/>129 <option id="toolchain.version" value="6.3.1.20170620"/> 130 130 </storageModule> 131 131 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 164 164 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.296419460" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 165 165 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1982161542" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 166 <builder buildPath="${workspace_loc:/app2_light}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.648260189" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>166 <builder buildPath="${workspace_loc:/app2_light}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.648260189" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 167 167 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1287580563" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 168 168 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1691990754" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> -
asp3_tinet_ecnl_arm/trunk/app2_light/Debug/Makefile
r352 r364 173 173 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 174 174 endif 175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 176 176 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 177 177 -I$(SRCDIR)/../btstack/include \ … … 181 181 -I$(SRCDIR)/../usbhost/src \ 182 182 $(INCLUDES) 183 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.183 LDFLAGS := $(LDFLAGS) -L. 184 184 LIBS := $(LIBS) $(CXXLIBS) 185 185 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 215 215 endif 216 216 217 218 # 219 # ネットワークサービスの定義 220 # 221 NO_USE_TINET_LIBRARY = true 222 223 # ネットワークインタフェースの選択、何れか一つ選択する。 224 NET_IF = ether 225 226 # イーサネット・ディバイスドライバの選択 227 NET_DEV = if_btusb 228 229 # ネットワーク層の選択 230 #SUPPORT_INET6 = true 231 SUPPORT_INET4 = true 232 233 # API に組込む機能の選択 234 #API_CFG_IP4MAPPED_ADDR = true 235 236 # トランスポート層の選択 237 SUPPORT_TCP = true 238 SUPPORT_UDP = true 239 240 # IGMPを有効に設定 241 SUPPORT_IGMP = true 242 243 # 244 # ネットワークサービスの Makefile のインクルード 245 # 246 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 217 ifdef TINETDIR 218 # 219 # ネットワークサービスの定義 220 # 221 NO_USE_TINET_LIBRARY = true 222 223 # ネットワークインタフェースの選択、何れか一つ選択する。 224 NET_IF = ether 225 226 # イーサネット・ディバイスドライバの選択 227 NET_DEV = if_btusb 228 229 # ネットワーク層の選択 230 #SUPPORT_INET6 = true 231 SUPPORT_INET4 = true 232 233 # API に組込む機能の選択 234 #API_CFG_IP4MAPPED_ADDR = true 235 236 # トランスポート層の選択 237 SUPPORT_TCP = true 238 SUPPORT_UDP = true 239 240 # IGMPを有効に設定 241 SUPPORT_IGMP = true 242 243 # 244 # ネットワークサービスの Makefile のインクルード 245 # 246 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 247 endif 247 248 248 249 # … … 277 278 # コンフィギュレータに関する定義 278 279 # 279 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 280 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 280 ifndef TINETDIR 281 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 282 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 283 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 284 else 285 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 286 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 281 287 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 282 288 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 284 290 --symval-table ../../ntshell/echonet/echonet_sym.def \ 285 291 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 292 endif 286 293 CFG_ASMOBJS := $(CFG_ASMOBJS) 287 294 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 429 436 430 437 # 438 # 並列makeのための依存関係の定義 439 # 440 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 441 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 442 | offset.timestamp 443 444 # 431 445 # 特別な依存関係の定義 432 446 # … … 437 451 # 438 452 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 439 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \453 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 440 454 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 441 455 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app2_light/DebugEther/Makefile
r352 r364 171 171 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 172 172 endif 173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 174 174 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 175 175 -I$(SRCDIR)/../btstack/include \ … … 179 179 -I$(SRCDIR)/../usbhost/src \ 180 180 $(INCLUDES) 181 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.181 LDFLAGS := $(LDFLAGS) -L. 182 182 LIBS := $(LIBS) $(CXXLIBS) 183 183 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 213 213 endif 214 214 215 216 #217 # ネットワークサービスの定義218 #219 NO_USE_TINET_LIBRARY = true220 221 # ネットワークインタフェースの選択、何れか一つ選択する。222 NET_IF = ether223 224 # イーサネット・ディバイスドライバの選択215 ifdef TINETDIR 216 # 217 # ネットワークサービスの定義 218 # 219 NO_USE_TINET_LIBRARY = true 220 221 # ネットワークインタフェースの選択、何れか一つ選択する。 222 NET_IF = ether 223 224 # イーサネット・ディバイスドライバの選択 225 225 NET_DEV = if_mbed 226 226 227 # ネットワーク層の選択 228 #SUPPORT_INET6 = true 229 SUPPORT_INET4 = true 230 231 # API に組込む機能の選択 232 #API_CFG_IP4MAPPED_ADDR = true 233 234 # トランスポート層の選択 235 SUPPORT_TCP = true 236 SUPPORT_UDP = true 237 238 # IGMPを有効に設定 239 SUPPORT_IGMP = true 240 241 # 242 # ネットワークサービスの Makefile のインクルード 243 # 244 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 227 # ネットワーク層の選択 228 #SUPPORT_INET6 = true 229 SUPPORT_INET4 = true 230 231 # API に組込む機能の選択 232 #API_CFG_IP4MAPPED_ADDR = true 233 234 # トランスポート層の選択 235 SUPPORT_TCP = true 236 SUPPORT_UDP = true 237 238 # IGMPを有効に設定 239 SUPPORT_IGMP = true 240 241 # 242 # ネットワークサービスの Makefile のインクルード 243 # 244 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 245 endif 245 246 246 247 # … … 275 276 # コンフィギュレータに関する定義 276 277 # 277 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 278 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 278 ifndef TINETDIR 279 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 280 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 281 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 282 else 283 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 284 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 279 285 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 280 286 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 282 288 --symval-table ../../ntshell/echonet/echonet_sym.def \ 283 289 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 290 endif 284 291 CFG_ASMOBJS := $(CFG_ASMOBJS) 285 292 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 427 434 428 435 # 436 # 並列makeのための依存関係の定義 437 # 438 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 439 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 440 | offset.timestamp 441 442 # 429 443 # 特別な依存関係の定義 430 444 # … … 435 449 # 436 450 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 437 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \451 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 438 452 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 439 453 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app2_light/src/echonet_main.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2014-2018 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ 37 37 38 /* 38 /* 39 39 * サンプルプログラム(1)の本体 40 40 */ … … 127 127 { 128 128 /* サイズが1以外は受け付けない */ 129 if (size != 1)129 if (size != 1) 130 130 return 0; 131 131 132 132 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 133 133 134 switch (*(uint8_t *)src){134 switch (*(uint8_t *)src) { 135 135 /* ONの場合 */ 136 136 case 0x30: … … 163 163 { 164 164 /* サイズが1以外は受け付けない */ 165 if (size != 1)165 if (size != 1) 166 166 return 0; 167 167 168 168 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 169 169 170 switch (*(uint8_t *)src){170 switch (*(uint8_t *)src) { 171 171 /* 異常発生ありの場合 */ 172 172 case 0x41: … … 189 189 { 190 190 /* サイズが1以外は受け付けない */ 191 if (size != 1)192 return 0; 193 194 switch (*(uint8_t *)src){191 if (size != 1) 192 return 0; 193 194 switch (*(uint8_t *)src) { 195 195 /* 自動の場合 */ 196 196 case 0x41: … … 241 241 uint8_t data[2]; 242 242 243 if (size != 1)244 return 0; 245 246 switch (*(uint8_t *)src){243 if (size != 1) 244 return 0; 245 246 switch (*(uint8_t *)src) { 247 247 /* 人体検出ありの場合 */ 248 248 case 0x41: … … 253 253 data[1] = *(uint8_t *)src; 254 254 ret = ecn_brk_wai(data, sizeof(data)); 255 if (ret != E_OK){255 if (ret != E_OK) { 256 256 syslog(LOG_ERROR, "ecn_brk_wai"); 257 257 return 1; … … 266 266 data[1] = *(uint8_t *)src; 267 267 ret = ecn_brk_wai(data, sizeof(data)); 268 if (ret != E_OK){268 if (ret != E_OK) { 269 269 syslog(LOG_ERROR, "ecn_brk_wai"); 270 270 return 1; … … 288 288 struct tm _tm; 289 289 290 if (size != 2)290 if (size != 2) 291 291 return 0; 292 292 … … 315 315 struct tm _tm; 316 316 317 if (size != 2)317 if (size != 2) 318 318 return 0; 319 319 … … 338 338 struct tm _tm; 339 339 340 if (size != 4)340 if (size != 4) 341 341 return 0; 342 342 … … 365 365 struct tm _tm; 366 366 367 if (size != 4)367 if (size != 4) 368 368 return 0; 369 369 … … 403 403 404 404 ret2 = get_tim(&now); 405 if (ret2 != E_OK) {405 if (ret2 != E_OK) { 406 406 syslog(LOG_ERROR, "get_tim"); 407 407 return; 408 408 } 409 409 410 for (;;){410 for (;;) { 411 411 prev = now; 412 412 … … 416 416 /* 応答電文待ち */ 417 417 ret = ecn_trcv_esv(&esv, timer); 418 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {418 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) { 419 419 syslog(LOG_ERROR, "ecn_trcv_esv"); 420 420 break; … … 422 422 423 423 ret2 = get_tim(&now); 424 if (ret2 != E_OK) {424 if (ret2 != E_OK) { 425 425 syslog(LOG_ERROR, "get_tim"); 426 426 break; … … 437 437 /* 領域解放 */ 438 438 ret = ecn_rel_esv(esv); 439 if (ret != E_OK) {439 if (ret != E_OK) { 440 440 syslog(LOG_ERROR, "ecn_rel_esv"); 441 441 break; … … 446 446 /* 応答電文待ちの割り込みデータ取得 */ 447 447 ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len); 448 if (ret != E_OK) {448 if (ret != E_OK) { 449 449 syslog(LOG_ERROR, "ecn_get_brk_dat"); 450 450 break; … … 456 456 /* 領域解放 */ 457 457 ret = ecn_rel_esv(esv); 458 if (ret != E_OK) {458 if (ret != E_OK) { 459 459 syslog(LOG_ERROR, "ecn_rel_esv"); 460 460 break; … … 467 467 } 468 468 469 bool_t started = false;470 471 469 void echonet_change_netif_link(uint8_t link_up, uint8_t up) 472 470 { … … 476 474 return; 477 475 478 if (up && !started) { 479 started = true; 480 481 /* ECHONETミドルウェアを起動 */ 482 ret = ecn_sta_svc(); 483 if (ret != E_OK) 484 return; 485 486 /* ECHONETミドルウェアを起動するのを待つ */ 487 dly_tsk(100); 476 if (up) { 477 /* インスタンスリスト通知の送信 */ 478 ret = ecn_ntf_inl(); 479 if (ret != E_OK) { 480 syslog(LOG_ERROR, "ecn_ntf_inl"); 481 } 488 482 } 489 483 … … 499 493 } 500 494 501 enum main_state_t{ 495 enum main_state_t { 496 main_state_start, 502 497 main_state_idle, 503 498 main_state_search, … … 506 501 int main_timer = TMO_FEVR; 507 502 int main_btn_timer = TMO_FEVR; 508 enum main_state_t main_state = main_state_ idle;503 enum main_state_t main_state = main_state_start; 509 504 bool_t main_btn1_state; 510 505 int main_btn1_count = 0; … … 535 530 gpio_write(&led_red, 0); 536 531 537 /* 1秒後に人体検知センサを検索*/538 main_state = main_state_s earch;532 /* ECHONETミドルウェアを起動するのを待つ */ 533 main_state = main_state_start; 539 534 main_timer = 1000 * 1000; 540 535 … … 548 543 main_btn2_state = btn2 != 0; 549 544 545 /* メインタスクを起動 */ 550 546 ER ret = act_tsk(MAIN_TASK); 551 547 if (ret != E_OK) { … … 561 557 int result = main_timer; 562 558 563 if ((result == TMO_FEVR)564 || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))) {559 if ((result == TMO_FEVR) 560 || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))) { 565 561 result = main_btn_timer; 566 562 } … … 574 570 static void main_progress(int interval) 575 571 { 576 if (main_timer != TMO_FEVR){572 if (main_timer != TMO_FEVR) { 577 573 main_timer -= interval; 578 if (main_timer < 0){574 if (main_timer < 0) { 579 575 main_timer = 0; 580 576 } 581 577 } 582 578 583 if (main_btn_timer != TMO_FEVR){579 if (main_btn_timer != TMO_FEVR) { 584 580 main_btn_timer -= interval; 585 if (main_btn_timer < 0){581 if (main_btn_timer < 0) { 586 582 main_btn_timer = 0; 587 583 } … … 602 598 603 599 eobjid = ecn_get_eobj(esv); 604 if (eobjid == EOBJ_NULL){600 if (eobjid == EOBJ_NULL) { 605 601 syslog(LOG_ERROR, "ecn_get_eobj"); 606 602 } 607 603 608 604 ret = ecn_itr_ini(&enm, esv); 609 if (ret != E_OK){605 if (ret != E_OK) { 610 606 syslog(LOG_ERROR, "ecn_itr_ini"); 611 607 return; 612 608 } 613 609 614 for (;;) {615 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {610 for (;;) { 611 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) { 616 612 switch (epc) { 617 613 case 0xD6: 618 switch (main_state){614 switch (main_state) { 619 615 case main_state_search: 620 616 if (eobjid == HUMAN_DETECTION_SENSER_ENOD) { … … 628 624 } 629 625 } 630 if (ret != E_BOVR){626 if (ret != E_BOVR) { 631 627 syslog(LOG_ERROR, "ecn_itr_nxt"); 632 628 break; 633 629 } 634 if (enm.is_eof)630 if (enm.is_eof) 635 631 break; 636 632 } … … 646 642 ER ret; 647 643 648 switch (main_state){644 switch (main_state) { 649 645 case main_state_idle: 650 646 if (len < 2) … … 670 666 static void main_timeout() 671 667 { 672 if (main_timer == 0){668 if (main_timer == 0) { 673 669 main_ontimer(); 674 670 } 675 671 676 if (main_btn_timer == 0){672 if (main_btn_timer == 0) { 677 673 main_btn_ontimer(); 678 674 } … … 683 679 static void main_ontimer() 684 680 { 685 switch(main_state){ 681 ER ret; 682 683 switch (main_state) { 684 case main_state_start: 685 /* ECHONETミドルウェアを起動 */ 686 ret = ecn_sta_svc(); 687 if (ret != E_OK) { 688 syslog(LOG_ERROR, "ecn_sta_svc"); 689 } 690 691 /* 1秒後に人体検知センサを検索 */ 692 main_state = main_state_search; 693 main_timer = 1000 * 1000; 694 break; 686 695 case main_state_search: 687 696 /* 人体検知センサ再検索 */ … … 700 709 /* 人体検知センサ検索 */ 701 710 ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6); 702 if (ret != E_OK){711 if (ret != E_OK) { 703 712 syslog(LOG_ERROR, "ecn_esv_inf_req"); 704 713 return; … … 707 716 /* 電文送信 */ 708 717 ret = ecn_snd_esv(esv); 709 if (ret != E_OK){718 if (ret != E_OK) { 710 719 syslog(LOG_ERROR, "ecn_snd_esv"); 711 720 } … … 730 739 731 740 /* ボタン1の処理 */ 732 if ((btn1 != 0) && !main_btn1_state){741 if ((btn1 != 0) && !main_btn1_state) { 733 742 main_btn1_count++; 734 if (main_btn1_count > 10){743 if (main_btn1_count > 10) { 735 744 main_btn1_count = 0; 736 745 main_btn1_state = true; … … 739 748 } 740 749 } 741 else if ((btn1 == 0) && main_btn1_state){750 else if ((btn1 == 0) && main_btn1_state) { 742 751 main_btn1_count++; 743 if (main_btn1_count > 10){752 if (main_btn1_count > 10) { 744 753 main_btn1_count = 0; 745 754 main_btn1_state = false; … … 750 759 751 760 /* ボタン2の処理 */ 752 if ((btn2 != 0) && !main_btn2_state){761 if ((btn2 != 0) && !main_btn2_state) { 753 762 main_btn2_count++; 754 if (main_btn2_count > 10){763 if (main_btn2_count > 10) { 755 764 main_btn2_count = 0; 756 765 main_btn2_state = true; … … 759 768 } 760 769 } 761 else if ((btn2 == 0) && main_btn2_state){770 else if ((btn2 == 0) && main_btn2_state) { 762 771 main_btn2_count++; 763 if (main_btn2_count > 10){772 if (main_btn2_count > 10) { 764 773 main_btn2_count = 0; 765 774 main_btn2_state = false; … … 770 779 } 771 780 772 enum lighting_mode_t {781 enum lighting_mode_t { 773 782 lighting_mode_auto, /* 自動の場合 */ 774 783 lighting_mode_normal, /* 通常灯の場合 */ … … 789 798 790 799 /* 押されて戻った時に処理する */ 791 if (push)800 if (push) 792 801 return; 793 802 … … 798 807 /* プロパティ設定電文作成 */ 799 808 ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0x80, 1, p_edt); 800 if (ret != E_OK){809 if (ret != E_OK) { 801 810 syslog(LOG_ERROR, "ecn_esv_setc"); 802 811 return; … … 817 826 818 827 /* 押されて戻った時に処理する */ 819 if (push)828 if (push) 820 829 return; 821 830 822 831 /* 点灯モードの切り替え */ 823 switch (main_mode){832 switch (main_mode) { 824 833 /* 自動の場合 */ 825 834 case lighting_mode_auto: … … 851 860 /* プロパティ設定電文作成 */ 852 861 ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0xB6, 1, p_edt); 853 if (ret != E_OK){862 if (ret != E_OK) { 854 863 syslog(LOG_ERROR, "ecn_esv_setc"); 855 864 return; … … 867 876 868 877 /* 照明がOFFで人体検出ありの場合 */ 869 if (!main_on && state == 0x41){878 if (!main_on && state == 0x41) { 870 879 /* 照明をON */ 871 880 main_on = true; 872 881 } 873 882 /* 照明がOFFで人体検出ありの場合 */ 874 else if (main_on && state == 0x42){883 else if (main_on && state == 0x42) { 875 884 /* 照明をOFF */ 876 885 main_on = false; … … 883 892 /* プロパティ設定電文作成 */ 884 893 ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0x80, 1, p_edt); 885 if (ret != E_OK){894 if (ret != E_OK) { 886 895 syslog(LOG_ERROR, "ecn_esv_setc"); 887 896 return; -
asp3_tinet_ecnl_arm/trunk/app2_light/src/main.c
r359 r364 79 79 80 80 ID ws_api_mailboxid = MAIN_DATAQUEUE; 81 #ifndef NOUSE_MPF_NET_BUF 81 82 ID ws_mempoolid = MPF_NET_BUF_256; 83 #endif 82 84 83 85 #ifdef IF_ETHER_BTUSB … … 111 113 static void main_timeout(); 112 114 115 extern int ntshell_exit; 116 113 117 int uart_read(char *buf, int cnt, void *extobj) 114 118 { 115 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 119 struct main_t *obj = (struct main_t *)extobj; 120 int result; 121 ER ret; 122 int timer; 123 124 obj->prev = obj->now; 125 126 /* タイマー取得 */ 127 timer = main_get_timer(); 128 129 /* 待ち */ 130 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 131 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 132 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 133 ntshell_exit = 1; 134 return -1; 135 } 136 result = (int)ret; 137 138 ret = get_tim(&obj->now); 139 if (ret != E_OK) { 140 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 141 ntshell_exit = 1; 142 return -1; 143 } 144 145 /* 時間経過 */ 146 int elapse = obj->now - obj->prev; 147 main_progress(elapse); 148 149 /* タイムアウト処理 */ 150 main_timeout(); 151 152 return result; 116 153 } 117 154 … … 119 156 { 120 157 return serial_wri_dat(SIO_PORTID, buf, cnt); 121 }122 123 unsigned char ntstdio_xi(struct ntstdio_t *handle)124 {125 char buf[1];126 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)127 return -EIO;128 return buf[0];129 }130 131 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)132 {133 char buf[1];134 buf[0] = c;135 serial_wri_dat(SIO_PORTID, buf, 1);136 158 } 137 159 … … 150 172 main_initialize(); 151 173 152 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);174 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj); 153 175 ntshell_set_prompt(&ntshell, "NTShell>"); 154 176 ntshell_execute(&ntshell); … … 168 190 ER ret; 169 191 170 ntshell_task_init(); 192 #ifdef TOPPERS_OMIT_TECS 193 serial_opn_por(SIO_PORTID); 194 #endif 195 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 196 197 ntshell_task_init(uart_read, uart_write, &main_obj); 171 198 172 199 main_obj.timer = TMO_FEVR; -
asp3_tinet_ecnl_arm/trunk/app2_light/src/main.cfg
r352 r364 54 54 INCLUDE("tinet/tinet_asp.cfg"); 55 55 INCLUDE("tinet_main.cfg"); 56 INCLUDE("netinet/ip_igmp.cfg");57 56 58 57 /* DHCP クライアント */ -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/.cproject
r352 r364 22 22 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 23 23 <option id="toolchain.id" value="gcc-arm-embedded"/> 24 <option id="toolchain.version" value=" 5.4.1.20160919"/>24 <option id="toolchain.version" value="6.3.1.20170620"/> 25 25 </storageModule> 26 26 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 59 59 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.2061453524" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 60 60 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.2110510466" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 61 <builder buildPath="${workspace_loc:/app3_human_detec}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.2014365971" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>61 <builder buildPath="${workspace_loc:/app3_human_detec}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.2014365971" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 62 62 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1586235718" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 63 63 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1315128639" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 127 127 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 128 128 <option id="toolchain.id" value="gcc-arm-embedded"/> 129 <option id="toolchain.version" value=" 5.4.1.20160919"/>129 <option id="toolchain.version" value="6.3.1.20170620"/> 130 130 </storageModule> 131 131 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 164 164 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.1077866862" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 165 165 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.22147358" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 166 <builder buildPath="${workspace_loc:/app3_human_detec}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1165377046" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>166 <builder buildPath="${workspace_loc:/app3_human_detec}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1165377046" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 167 167 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.154532541" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 168 168 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1431457153" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/Debug/Makefile
r352 r364 173 173 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 174 174 endif 175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 176 176 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 177 177 -I$(SRCDIR)/../btstack/include \ … … 181 181 -I$(SRCDIR)/../usbhost/src \ 182 182 $(INCLUDES) 183 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.183 LDFLAGS := $(LDFLAGS) -L. 184 184 LIBS := $(LIBS) $(CXXLIBS) 185 185 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 215 215 endif 216 216 217 218 # 219 # ネットワークサービスの定義 220 # 221 NO_USE_TINET_LIBRARY = true 222 223 # ネットワークインタフェースの選択、何れか一つ選択する。 224 NET_IF = ether 225 226 # イーサネット・ディバイスドライバの選択 227 NET_DEV = if_btusb 228 229 # ネットワーク層の選択 230 #SUPPORT_INET6 = true 231 SUPPORT_INET4 = true 232 233 # API に組込む機能の選択 234 #API_CFG_IP4MAPPED_ADDR = true 235 236 # トランスポート層の選択 237 SUPPORT_TCP = true 238 SUPPORT_UDP = true 239 240 # IGMPを有効に設定 241 SUPPORT_IGMP = true 242 243 # 244 # ネットワークサービスの Makefile のインクルード 245 # 246 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 217 ifdef TINETDIR 218 # 219 # ネットワークサービスの定義 220 # 221 NO_USE_TINET_LIBRARY = true 222 223 # ネットワークインタフェースの選択、何れか一つ選択する。 224 NET_IF = ether 225 226 # イーサネット・ディバイスドライバの選択 227 NET_DEV = if_btusb 228 229 # ネットワーク層の選択 230 #SUPPORT_INET6 = true 231 SUPPORT_INET4 = true 232 233 # API に組込む機能の選択 234 #API_CFG_IP4MAPPED_ADDR = true 235 236 # トランスポート層の選択 237 SUPPORT_TCP = true 238 SUPPORT_UDP = true 239 240 # IGMPを有効に設定 241 SUPPORT_IGMP = true 242 243 # 244 # ネットワークサービスの Makefile のインクルード 245 # 246 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 247 endif 247 248 248 249 # … … 277 278 # コンフィギュレータに関する定義 278 279 # 279 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 280 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 280 ifndef TINETDIR 281 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 282 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 283 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 284 else 285 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 286 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 281 287 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 282 288 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 284 290 --symval-table ../../ntshell/echonet/echonet_sym.def \ 285 291 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 292 endif 286 293 CFG_ASMOBJS := $(CFG_ASMOBJS) 287 294 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 429 436 430 437 # 438 # 並列makeのための依存関係の定義 439 # 440 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 441 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 442 | offset.timestamp 443 444 # 431 445 # 特別な依存関係の定義 432 446 # … … 437 451 # 438 452 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 439 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \453 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 440 454 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 441 455 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/DebugEther/Makefile
r352 r364 171 171 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 172 172 endif 173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 174 174 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 175 175 -I$(SRCDIR)/../btstack/include \ … … 179 179 -I$(SRCDIR)/../usbhost/src \ 180 180 $(INCLUDES) 181 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.181 LDFLAGS := $(LDFLAGS) -L. 182 182 LIBS := $(LIBS) $(CXXLIBS) 183 183 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 213 213 endif 214 214 215 216 #217 # ネットワークサービスの定義218 #219 NO_USE_TINET_LIBRARY = true220 221 # ネットワークインタフェースの選択、何れか一つ選択する。222 NET_IF = ether223 224 # イーサネット・ディバイスドライバの選択215 ifdef TINETDIR 216 # 217 # ネットワークサービスの定義 218 # 219 NO_USE_TINET_LIBRARY = true 220 221 # ネットワークインタフェースの選択、何れか一つ選択する。 222 NET_IF = ether 223 224 # イーサネット・ディバイスドライバの選択 225 225 NET_DEV = if_mbed 226 226 227 # ネットワーク層の選択 228 #SUPPORT_INET6 = true 229 SUPPORT_INET4 = true 230 231 # API に組込む機能の選択 232 #API_CFG_IP4MAPPED_ADDR = true 233 234 # トランスポート層の選択 235 SUPPORT_TCP = true 236 SUPPORT_UDP = true 237 238 # IGMPを有効に設定 239 SUPPORT_IGMP = true 240 241 # 242 # ネットワークサービスの Makefile のインクルード 243 # 244 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 227 # ネットワーク層の選択 228 #SUPPORT_INET6 = true 229 SUPPORT_INET4 = true 230 231 # API に組込む機能の選択 232 #API_CFG_IP4MAPPED_ADDR = true 233 234 # トランスポート層の選択 235 SUPPORT_TCP = true 236 SUPPORT_UDP = true 237 238 # IGMPを有効に設定 239 SUPPORT_IGMP = true 240 241 # 242 # ネットワークサービスの Makefile のインクルード 243 # 244 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 245 endif 245 246 246 247 # … … 275 276 # コンフィギュレータに関する定義 276 277 # 277 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 278 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 278 ifndef TINETDIR 279 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 280 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 281 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 282 else 283 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 284 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 279 285 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 280 286 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 282 288 --symval-table ../../ntshell/echonet/echonet_sym.def \ 283 289 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 290 endif 284 291 CFG_ASMOBJS := $(CFG_ASMOBJS) 285 292 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 427 434 428 435 # 436 # 並列makeのための依存関係の定義 437 # 438 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 439 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 440 | offset.timestamp 441 442 # 429 443 # 特別な依存関係の定義 430 444 # … … 435 449 # 436 450 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 437 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \451 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 438 452 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 439 453 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/echonet_main.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2014-2018 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ 37 37 38 /* 38 /* 39 39 * サンプルプログラム(1)の本体 40 40 */ … … 94 94 { 95 95 /* サイズが1以外は受け付けない */ 96 if (size != 1)96 if (size != 1) 97 97 return 0; 98 98 99 99 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 100 100 101 switch (*(uint8_t *)src){101 switch (*(uint8_t *)src) { 102 102 /* ONの場合 */ 103 103 case 0x30: … … 126 126 { 127 127 /* サイズが1以外は受け付けない */ 128 if (size != 1)128 if (size != 1) 129 129 return 0; 130 130 131 131 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 132 132 133 switch (*(uint8_t *)src){133 switch (*(uint8_t *)src) { 134 134 /* 異常発生ありの場合 */ 135 135 case 0x41: … … 152 152 { 153 153 /* サイズが1以外は受け付けない */ 154 if (size != 1)155 return 0; 156 157 if ((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)){154 if (size != 1) 155 return 0; 156 157 if ((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)) { 158 158 *((uint8_t *)item->exinf) = *((uint8_t *)src); 159 159 } 160 160 /* 上記以外は受け付けない */ 161 else {161 else { 162 162 return 0; 163 163 } … … 180 180 181 181 /* サイズが1以外は受け付けない */ 182 if (size != 1)182 if (size != 1) 183 183 return 0; 184 184 185 185 *anno = false; 186 186 187 if ((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)){187 if ((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)) { 188 188 /* 以前の検知レベルを保存 */ 189 189 prev_state = eobj->state; … … 197 197 198 198 /* 人体検知状態に変化があった場合 */ 199 if((prev_state < eobj->threshold) != (eobj->state < eobj->threshold)) 200 { 199 if ((prev_state < eobj->threshold) != (eobj->state < eobj->threshold)) { 201 200 /* プロパティ通知 */ 202 201 *anno = true; … … 204 203 } 205 204 /* 上記以外は受け付けない */ 206 else {205 else { 207 206 return 0; 208 207 } … … 211 210 } 212 211 213 /* 212 /* 214 213 * 人体検知状態取得関数 215 214 */ … … 219 218 220 219 /* 閾値より検知レベルが低い場合 */ 221 if (eobj->state < eobj->threshold){220 if (eobj->state < eobj->threshold) { 222 221 /* 人体検知なし */ 223 222 ((uint8_t *)dst)[0] = 0x42; 224 223 } 225 224 /* 閾値より検知レベルが高い場合 */ 226 else {225 else { 227 226 /* 人体検知あり */ 228 227 ((uint8_t *)dst)[0] = 0x41; … … 255 254 256 255 ret2 = get_tim(&now); 257 if (ret2 != E_OK) {256 if (ret2 != E_OK) { 258 257 syslog(LOG_ERROR, "get_tim"); 259 258 return; 260 259 } 261 260 262 for (;;){261 for (;;) { 263 262 prev = now; 264 263 … … 268 267 /* 応答電文待ち */ 269 268 ret = ecn_trcv_esv(&esv, timer); 270 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {269 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) { 271 270 syslog(LOG_ERROR, "ecn_trcv_esv"); 272 271 break; … … 274 273 275 274 ret2 = get_tim(&now); 276 if (ret2 != E_OK) {275 if (ret2 != E_OK) { 277 276 syslog(LOG_ERROR, "get_tim"); 278 277 break; … … 289 288 /* 領域解放 */ 290 289 ret = ecn_rel_esv(esv); 291 if (ret != E_OK) {290 if (ret != E_OK) { 292 291 syslog(LOG_ERROR, "ecn_rel_esv"); 293 292 break; … … 298 297 /* 応答電文待ちの割り込みデータ取得 */ 299 298 ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len); 300 if (ret != E_OK) {299 if (ret != E_OK) { 301 300 syslog(LOG_ERROR, "ecn_get_brk_dat"); 302 301 break; … … 308 307 /* 領域解放 */ 309 308 ret = ecn_rel_esv(esv); 310 if (ret != E_OK) {309 if (ret != E_OK) { 311 310 syslog(LOG_ERROR, "ecn_rel_esv"); 312 311 break; … … 319 318 } 320 319 321 bool_t started = false;322 323 320 void echonet_change_netif_link(uint8_t link_up, uint8_t up) 324 321 { … … 328 325 return; 329 326 330 if (up && !started) { 331 started = true; 332 333 /* ECHONETミドルウェアを起動 */ 334 ret = ecn_sta_svc(); 335 if (ret != E_OK) 336 return; 337 338 /* ECHONETミドルウェアを起動するのを待つ */ 339 dly_tsk(100); 327 if (up) { 328 /* インスタンスリスト通知の送信 */ 329 ret = ecn_ntf_inl(); 330 if (ret != E_OK) { 331 syslog(LOG_ERROR, "ecn_ntf_inl"); 332 } 340 333 } 341 334 … … 351 344 } 352 345 353 enum main_state_t{ 346 enum main_state_t { 347 main_state_start, 354 348 main_state_idle, 355 349 }; 356 350 357 351 int main_timer = TMO_FEVR; 358 enum main_state_t main_state = main_state_ idle;352 enum main_state_t main_state = main_state_start; 359 353 bool_t main_btn1_state; 360 354 int main_btn1_count = 0; … … 386 380 gpio_write(&led_red, 0); 387 381 388 /* 10ms後にボタン状態を確認 */ 389 main_timer = 10 * 1000; 382 /* ECHONETミドルウェアを起動するのを待つ */ 383 main_state = main_state_start; 384 main_timer = 1000 * 1000; 390 385 391 386 /* アナログ入力の初期化 */ … … 398 393 main_btn2_state = btn2 != 0; 399 394 395 /* メインタスクを起動 */ 400 396 ER ret = act_tsk(MAIN_TASK); 401 397 if (ret != E_OK) { … … 417 413 static void main_progress(int interval) 418 414 { 419 if (main_timer == TMO_FEVR)415 if (main_timer == TMO_FEVR) 420 416 return; 421 417 422 418 main_timer -= interval; 423 if (main_timer < 0){419 if (main_timer < 0) { 424 420 main_timer = 0; 425 421 } … … 438 434 439 435 ret = ecn_itr_ini(&enm, esv); 440 if (ret != E_OK){436 if (ret != E_OK) { 441 437 syslog(LOG_ERROR, "ecn_itr_ini"); 442 438 return; 443 439 } 444 440 445 for (;;) {446 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {441 for (;;) { 442 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) { 447 443 switch (epc) { 448 444 case 0x80: … … 452 448 } 453 449 } 454 if (ret != E_BOVR){450 if (ret != E_BOVR) { 455 451 syslog(LOG_ERROR, "ecn_itr_nxt"); 456 452 break; 457 453 } 458 if (enm.is_eof)454 if (enm.is_eof) 459 455 break; 460 456 } … … 466 462 static void main_break_wait(uint8_t *brkdat, int32_t len) 467 463 { 468 switch (main_state){464 switch (main_state) { 469 465 case main_state_idle: 470 466 break; … … 488 484 static void main_timeout() 489 485 { 486 ER ret; 490 487 uint8_t btn1, btn2; 491 488 uint16_t ad_value; 492 489 uint8_t ad_level; 493 490 494 if(main_timer != 0) 495 return; 496 497 switch(main_state){ 491 if (main_timer != 0) 492 return; 493 494 switch (main_state) { 495 case main_state_start: 496 /* ECHONETミドルウェアを起動 */ 497 ret = ecn_sta_svc(); 498 if (ret != E_OK) { 499 syslog(LOG_ERROR, "ecn_sta_svc"); 500 } 501 502 /* 10ms後にボタン状態を確認 */ 503 main_state = main_state_idle; 504 main_timer = 10 * 1000; 505 break; 498 506 case main_state_idle: 499 507 /* 10ms後にボタン状態を確認 */ … … 507 515 508 516 main_ad_pos++; 509 if (main_ad_pos >= main_ad_table_count){517 if (main_ad_pos >= main_ad_table_count) { 510 518 main_ad_pos = 0; 511 519 } 512 520 513 ad_level = (((main_ad_avelage / main_ad_table_count) >> 9) & 0x7) + 1;514 if (main_ad_level != ad_level){521 ad_level = 8 - (((main_ad_avelage / main_ad_table_count) >> 9) & 0x7); 522 if (main_ad_level != ad_level) { 515 523 /* 1秒変化が続いたら */ 516 if (main_count < 100){524 if (main_count < 100) { 517 525 main_count++; 518 526 } 519 else {527 else { 520 528 main_ad_level = ad_level; 521 529 … … 524 532 } 525 533 } 526 else {534 else { 527 535 main_count = 0; 528 536 } … … 533 541 534 542 /* ボタン1の処理 */ 535 if ((btn1 != 0) && !main_btn1_state){543 if ((btn1 != 0) && !main_btn1_state) { 536 544 main_btn1_count++; 537 if (main_btn1_count > 10){545 if (main_btn1_count > 10) { 538 546 main_btn1_count = 0; 539 547 main_btn1_state = true; … … 542 550 } 543 551 } 544 else if ((btn1 == 0) && main_btn1_state){552 else if ((btn1 == 0) && main_btn1_state) { 545 553 main_btn1_count++; 546 if (main_btn1_count > 10){554 if (main_btn1_count > 10) { 547 555 main_btn1_count = 0; 548 556 main_btn1_state = false; … … 553 561 554 562 /* ボタン2の処理 */ 555 if ((btn2 != 0) && !main_btn2_state){563 if ((btn2 != 0) && !main_btn2_state) { 556 564 main_btn2_count++; 557 if (main_btn2_count > 10){565 if (main_btn2_count > 10) { 558 566 main_btn2_count = 0; 559 567 main_btn2_state = true; … … 562 570 } 563 571 } 564 else if ((btn2 == 0) && main_btn2_state){572 else if ((btn2 == 0) && main_btn2_state) { 565 573 main_btn2_count++; 566 if (main_btn2_count > 10){574 if (main_btn2_count > 10) { 567 575 main_btn2_count = 0; 568 576 main_btn2_state = false; … … 588 596 /* プロパティ設定電文作成 */ 589 597 ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt); 590 if (ret != E_OK){598 if (ret != E_OK) { 591 599 syslog(LOG_ERROR, "ecn_esv_setc"); 592 600 return; … … 610 618 611 619 /* 押されて戻った時に処理する */ 612 if (push)620 if (push) 613 621 return; 614 622 615 623 /* 人体検知状態 */ 616 if (!main_rev){624 if (!main_rev) { 617 625 main_level--; 618 if (main_level < 1){626 if (main_level < 1) { 619 627 main_level = 1; 620 628 main_rev = true; 621 629 } 622 630 } 623 else {631 else { 624 632 main_level++; 625 if (main_level > 8){633 if (main_level > 8) { 626 634 main_level = 8; 627 635 main_rev = false; … … 633 641 /* プロパティ設定電文作成 */ 634 642 ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt); 635 if (ret != E_OK){643 if (ret != E_OK) { 636 644 syslog(LOG_ERROR, "ecn_esv_setc"); 637 645 return; … … 652 660 653 661 /* 押されて戻った時に処理する */ 654 if (push)662 if (push) 655 663 return; 656 664 657 665 /* 人体検知状態 */ 658 if (!main_rev){666 if (!main_rev) { 659 667 main_level++; 660 if (main_level > 8){668 if (main_level > 8) { 661 669 main_level = 8; 662 670 main_rev = false; 663 671 } 664 672 } 665 else {673 else { 666 674 main_level--; 667 if (main_level < 1){675 if (main_level < 1) { 668 676 main_level = 1; 669 677 main_rev = true; … … 675 683 /* プロパティ設定電文作成 */ 676 684 ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt); 677 if (ret != E_OK){685 if (ret != E_OK) { 678 686 syslog(LOG_ERROR, "ecn_esv_setc"); 679 687 return; -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.c
r359 r364 79 79 80 80 ID ws_api_mailboxid = MAIN_DATAQUEUE; 81 #ifndef NOUSE_MPF_NET_BUF 81 82 ID ws_mempoolid = MPF_NET_BUF_256; 83 #endif 82 84 83 85 #ifdef IF_ETHER_BTUSB … … 111 113 static void main_timeout(); 112 114 115 extern int ntshell_exit; 116 113 117 int uart_read(char *buf, int cnt, void *extobj) 114 118 { 115 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 119 struct main_t *obj = (struct main_t *)extobj; 120 int result; 121 ER ret; 122 int timer; 123 124 obj->prev = obj->now; 125 126 /* タイマー取得 */ 127 timer = main_get_timer(); 128 129 /* 待ち */ 130 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 131 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 132 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 133 ntshell_exit = 1; 134 return -1; 135 } 136 result = (int)ret; 137 138 ret = get_tim(&obj->now); 139 if (ret != E_OK) { 140 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 141 ntshell_exit = 1; 142 return -1; 143 } 144 145 /* 時間経過 */ 146 int elapse = obj->now - obj->prev; 147 main_progress(elapse); 148 149 /* タイムアウト処理 */ 150 main_timeout(); 151 152 return result; 116 153 } 117 154 … … 119 156 { 120 157 return serial_wri_dat(SIO_PORTID, buf, cnt); 121 }122 123 unsigned char ntstdio_xi(struct ntstdio_t *handle)124 {125 char buf[1];126 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)127 return -EIO;128 return buf[0];129 }130 131 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)132 {133 char buf[1];134 buf[0] = c;135 serial_wri_dat(SIO_PORTID, buf, 1);136 158 } 137 159 … … 150 172 main_initialize(); 151 173 152 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);174 ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj); 153 175 ntshell_set_prompt(&ntshell, "NTShell>"); 154 176 ntshell_execute(&ntshell); … … 168 190 ER ret; 169 191 170 ntshell_task_init(); 192 #ifdef TOPPERS_OMIT_TECS 193 serial_opn_por(SIO_PORTID); 194 #endif 195 serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV); 196 197 ntshell_task_init(uart_read, uart_write, &main_obj); 171 198 172 199 main_obj.timer = TMO_FEVR; -
asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.cfg
r352 r364 54 54 INCLUDE("tinet/tinet_asp.cfg"); 55 55 INCLUDE("tinet_main.cfg"); 56 INCLUDE("netinet/ip_igmp.cfg");57 56 58 57 /* DHCP クライアント */ -
asp3_tinet_ecnl_arm/trunk/app4_aircon/.cproject
r352 r364 22 22 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 23 23 <option id="toolchain.id" value="gcc-arm-embedded"/> 24 <option id="toolchain.version" value=" 5.4.1.20160919"/>24 <option id="toolchain.version" value="6.3.1.20170620"/> 25 25 </storageModule> 26 26 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 59 59 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.1501102219" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 60 60 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1085912920" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 61 <builder buildPath="${workspace_loc:/app4_aircon}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1132488688" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>61 <builder buildPath="${workspace_loc:/app4_aircon}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1132488688" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 62 62 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1278248884" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 63 63 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1219404387" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> … … 127 127 <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo"> 128 128 <option id="toolchain.id" value="gcc-arm-embedded"/> 129 <option id="toolchain.version" value=" 5.4.1.20160919"/>129 <option id="toolchain.version" value="6.3.1.20170620"/> 130 130 </storageModule> 131 131 <storageModule moduleId="cdtBuildSystem" version="4.0.0"> … … 164 164 <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.956370110" name="Warn if stack size exceeds the limit (-Wstack-usage) (H')" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack" useByScannerDiscovery="false" value="100" valueType="string"/> 165 165 <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1652770796" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/> 166 <builder buildPath="${workspace_loc:/app4_aircon}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.994484673" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn=" false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>166 <builder buildPath="${workspace_loc:/app4_aircon}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.994484673" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/> 167 167 <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1242790859" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler"> 168 168 <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1960328126" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/> -
asp3_tinet_ecnl_arm/trunk/app4_aircon/Debug/Makefile
r352 r364 179 179 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 180 180 endif 181 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start181 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 182 182 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 183 183 -I$(SRCDIR)/../btstack/include \ … … 187 187 -I$(SRCDIR)/../usbhost/src \ 188 188 $(INCLUDES) 189 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.189 LDFLAGS := $(LDFLAGS) -L. 190 190 LIBS := $(LIBS) $(CXXLIBS) 191 191 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 198 198 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o 199 199 APPLDIRS := $(APPLDIRS) ../../ntshell/lcd 200 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o 200 APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o 201 APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT 201 202 202 203 # … … 223 224 endif 224 225 225 226 # 227 # ネットワークサービスの定義 228 # 229 NO_USE_TINET_LIBRARY = true 230 231 # ネットワークインタフェースの選択、何れか一つ選択する。 232 NET_IF = ether 233 234 # イーサネット・ディバイスドライバの選択 235 NET_DEV = if_btusb 236 237 # ネットワーク層の選択 238 #SUPPORT_INET6 = true 239 SUPPORT_INET4 = true 240 241 # API に組込む機能の選択 242 #API_CFG_IP4MAPPED_ADDR = true 243 244 # トランスポート層の選択 245 SUPPORT_TCP = true 246 SUPPORT_UDP = true 247 248 # IGMPを有効に設定 249 SUPPORT_IGMP = true 250 251 # 252 # ネットワークサービスの Makefile のインクルード 253 # 254 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 226 ifdef TINETDIR 227 # 228 # ネットワークサービスの定義 229 # 230 NO_USE_TINET_LIBRARY = true 231 232 # ネットワークインタフェースの選択、何れか一つ選択する。 233 NET_IF = ether 234 235 # イーサネット・ディバイスドライバの選択 236 NET_DEV = if_btusb 237 238 # ネットワーク層の選択 239 #SUPPORT_INET6 = true 240 SUPPORT_INET4 = true 241 242 # API に組込む機能の選択 243 #API_CFG_IP4MAPPED_ADDR = true 244 245 # トランスポート層の選択 246 SUPPORT_TCP = true 247 SUPPORT_UDP = true 248 249 # IGMPを有効に設定 250 SUPPORT_IGMP = true 251 252 # 253 # ネットワークサービスの Makefile のインクルード 254 # 255 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 256 endif 255 257 256 258 # … … 285 287 # コンフィギュレータに関する定義 286 288 # 287 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 288 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 289 ifndef TINETDIR 290 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 291 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 292 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 293 else 294 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 295 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 289 296 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 290 297 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 292 299 --symval-table ../../ntshell/echonet/echonet_sym.def \ 293 300 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 301 endif 294 302 CFG_ASMOBJS := $(CFG_ASMOBJS) 295 303 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 437 445 438 446 # 447 # 並列makeのための依存関係の定義 448 # 449 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 450 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 451 | offset.timestamp 452 453 # 439 454 # 特別な依存関係の定義 440 455 # … … 445 460 # 446 461 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 447 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \462 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 448 463 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 449 464 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app4_aircon/DebugEther/Makefile
r352 r364 177 177 CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS) 178 178 endif 179 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -D ECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start179 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DNOUSE_MPF_NET_BUF -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start 180 180 INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \ 181 181 -I$(SRCDIR)/../btstack/include \ … … 185 185 -I$(SRCDIR)/../usbhost/src \ 186 186 $(INCLUDES) 187 LDFLAGS := $(LDFLAGS) - Wl,-Map=$(OBJNAME).map,--cref -L.187 LDFLAGS := $(LDFLAGS) -L. 188 188 LIBS := $(LIBS) $(CXXLIBS) 189 189 CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES) … … 196 196 APPL_COBJS := $(APPL_COBJS) netcmd.o fdtable.o io_stub.o socket_stub.o ffarch.o diskio.o ff.o sdfs.o ccsbcs.o ntshell.o text_editor.o text_history.o usrcmd.o vtrecv.o vtsend.o ntlibc.o ntstdio.o ntopt.o syscall.o tlsf.o 197 197 APPLDIRS := $(APPLDIRS) ../../ntshell/lcd 198 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o 198 APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o 199 APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT 199 200 200 201 # … … 221 222 endif 222 223 223 224 #225 # ネットワークサービスの定義226 #227 NO_USE_TINET_LIBRARY = true228 229 # ネットワークインタフェースの選択、何れか一つ選択する。230 NET_IF = ether231 232 # イーサネット・ディバイスドライバの選択224 ifdef TINETDIR 225 # 226 # ネットワークサービスの定義 227 # 228 NO_USE_TINET_LIBRARY = true 229 230 # ネットワークインタフェースの選択、何れか一つ選択する。 231 NET_IF = ether 232 233 # イーサネット・ディバイスドライバの選択 233 234 NET_DEV = if_mbed 234 235 235 # ネットワーク層の選択 236 #SUPPORT_INET6 = true 237 SUPPORT_INET4 = true 238 239 # API に組込む機能の選択 240 #API_CFG_IP4MAPPED_ADDR = true 241 242 # トランスポート層の選択 243 SUPPORT_TCP = true 244 SUPPORT_UDP = true 245 246 # IGMPを有効に設定 247 SUPPORT_IGMP = true 248 249 # 250 # ネットワークサービスの Makefile のインクルード 251 # 252 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 236 # ネットワーク層の選択 237 #SUPPORT_INET6 = true 238 SUPPORT_INET4 = true 239 240 # API に組込む機能の選択 241 #API_CFG_IP4MAPPED_ADDR = true 242 243 # トランスポート層の選択 244 SUPPORT_TCP = true 245 SUPPORT_UDP = true 246 247 # IGMPを有効に設定 248 SUPPORT_IGMP = true 249 250 # 251 # ネットワークサービスの Makefile のインクルード 252 # 253 include $(SRCDIR)/$(TINETDIR)/Makefile.tinet 254 endif 253 255 254 256 # … … 283 285 # コンフィギュレータに関する定義 284 286 # 285 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 286 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 287 ifndef TINETDIR 288 CFG_TRB := -T $(TARGETDIR)/target_kernel.trb 289 CFG_TABS := --api-table $(SRCDIR)/kernel/kernel_api.def \ 290 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 291 else 292 CFG_TRB := -T $(TINET_ROOT)/tinet.trb:tcpip -T ../../ntshell/echonet/echonet.trb:echonet -T $(TARGETDIR)/target_kernel.trb:kernel 293 CFG_TABS := --api-table $(TINET_ROOT)/tcpip_api.def:tcpip \ 287 294 --api-table ../../ntshell/echonet/echonet_api.def:echonet \ 288 295 --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \ … … 290 297 --symval-table ../../ntshell/echonet/echonet_sym.def \ 291 298 --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS) 299 endif 292 300 CFG_ASMOBJS := $(CFG_ASMOBJS) 293 301 CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS) … … 435 443 436 444 # 445 # 並列makeのための依存関係の定義 446 # 447 $(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp 448 $(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \ 449 | offset.timestamp 450 451 # 437 452 # 特別な依存関係の定義 438 453 # … … 443 458 # 444 459 $(OBJFILE): $(ALL_OBJS) $(LIBS_DEP) 445 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \460 $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \ 446 461 $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \ 447 462 -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS) -
asp3_tinet_ecnl_arm/trunk/app4_aircon/src/echonet_main.c
r352 r364 1 1 /* 2 2 * TOPPERS ECHONET Lite Communication Middleware 3 * 3 * 4 4 * Copyright (C) 2014 Cores Co., Ltd. Japan 5 * 5 * 6 6 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ 7 7 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改 … … 26 26 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを 27 27 * 免責すること. 28 * 28 * 29 29 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お 30 30 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的 … … 32 32 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ 33 33 * の責任を負わない. 34 * 34 * 35 35 * @(#) $Id$ 36 36 */ 37 37 38 /* 38 /* 39 39 * サンプルプログラム(1)の本体 40 40 */ … … 55 55 #include "adafruit_st7735.h" 56 56 #include "draw_font.h" 57 #include <tinet_defs.h> 58 #include <tinet_config.h> 59 #include <netinet/in.h> 60 #include <netinet/in_var.h> 61 #include <net/ethernet.h> 62 #include <net/if_var.h> 63 64 extern uint8_t mac_addr[6]; 57 65 58 66 /* TODO: メーカーコードを設定 */ … … 184 192 185 193 /* サイズが1以外は受け付けない */ 186 if (size != 1)194 if (size != 1) 187 195 return 0; 188 196 189 197 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 190 198 191 switch (*(uint8_t *)src){199 switch (*(uint8_t *)src) { 192 200 /* ONの場合 */ 193 201 case 0x30: … … 198 206 data[0] = 0x80; 199 207 ret = ecn_brk_wai(data, sizeof(data)); 200 if (ret != E_OK){208 if (ret != E_OK) { 201 209 syslog(LOG_ERROR, "ecn_brk_wai"); 202 210 return 2; … … 217 225 { 218 226 /* サイズが1以外は受け付けない */ 219 if (size != 1)227 if (size != 1) 220 228 return 0; 221 229 222 230 *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src); 223 231 224 switch (*(uint8_t *)src){232 switch (*(uint8_t *)src) { 225 233 /* 異常発生ありの場合 */ 226 234 case 0x41: … … 246 254 247 255 /* サイズが1以外は受け付けない */ 248 if (size != 1)256 if (size != 1) 249 257 return 0; 250 258 251 switch (*(uint8_t *)src){259 switch (*(uint8_t *)src) { 252 260 /* 自動の場合 */ 253 261 case 0x41: … … 266 274 data[0] = 0xB0; 267 275 ret = ecn_brk_wai(data, sizeof(data)); 268 if (ret != E_OK){276 if (ret != E_OK) { 269 277 syslog(LOG_ERROR, "ecn_brk_wai"); 270 278 return 2; … … 288 296 289 297 /* サイズが1以外は受け付けない */ 290 if (size != 1)298 if (size != 1) 291 299 return 0; 292 300 293 301 /* 0℃~50℃ */ 294 if ((*(uint8_t *)src >= 0x00) && (*(uint8_t *)src <= 0x32)){302 if ((*(uint8_t *)src >= 0x00) && (*(uint8_t *)src <= 0x32)) { 295 303 *((uint8_t *)item->exinf) = *((uint8_t *)src); 296 304 /* メインタスクに通知 */ 297 305 data[0] = 0xB3; 298 306 ret = ecn_brk_wai(data, sizeof(data)); 299 if (ret != E_OK){307 if (ret != E_OK) { 300 308 syslog(LOG_ERROR, "ecn_brk_wai"); 301 309 return 2; … … 303 311 } 304 312 /* 上記以外は受け付けない */ 305 else {313 else { 306 314 return 0; 307 315 } … … 333 341 334 342 ret2 = get_tim(&now); 335 if (ret2 != E_OK) {343 if (ret2 != E_OK) { 336 344 syslog(LOG_ERROR, "get_tim"); 337 345 return; 338 346 } 339 347 340 for (;;){348 for (;;) { 341 349 prev = now; 342 350 … … 346 354 /* 応答電文待ち */ 347 355 ret = ecn_trcv_esv(&esv, timer); 348 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {356 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) { 349 357 syslog(LOG_ERROR, "ecn_trcv_esv"); 350 358 break; … … 352 360 353 361 ret2 = get_tim(&now); 354 if (ret2 != E_OK) {362 if (ret2 != E_OK) { 355 363 syslog(LOG_ERROR, "get_tim"); 356 364 break; … … 367 375 /* 領域解放 */ 368 376 ret = ecn_rel_esv(esv); 369 if (ret != E_OK) {377 if (ret != E_OK) { 370 378 syslog(LOG_ERROR, "ecn_rel_esv"); 371 379 break; … … 376 384 /* 応答電文待ちの割り込みデータ取得 */ 377 385 ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len); 378 if (ret != E_OK) {386 if (ret != E_OK) { 379 387 syslog(LOG_ERROR, "ecn_get_brk_dat"); 380 388 break; … … 386 394 /* 領域解放 */ 387 395 ret = ecn_rel_esv(esv); 388 if (ret != E_OK) {396 if (ret != E_OK) { 389 397 syslog(LOG_ERROR, "ecn_rel_esv"); 390 398 break; … … 397 405 } 398 406 399 bool_t started = false;400 401 407 void echonet_change_netif_link(uint8_t link_up, uint8_t up) 402 408 { … … 406 412 return; 407 413 408 if (up && !started) { 409 started = true; 410 411 /* ECHONETミドルウェアを起動 */ 412 ret = ecn_sta_svc(); 413 if (ret != E_OK) 414 return; 415 416 /* ECHONETミドルウェアを起動するのを待つ */ 417 dly_tsk(100); 414 if (up) { 415 /* インスタンスリスト通知の送信 */ 416 ret = ecn_ntf_inl(); 417 if (ret != E_OK) { 418 syslog(LOG_ERROR, "ecn_ntf_inl"); 419 } 418 420 } 419 421 … … 421 423 uint8_t data[2]; 422 424 data[0] = 0x01; 423 data[1] = up ? 0x01 : 0x02;425 data[1] = (up ? 0x01 : 0x02) | (link_up ? 0x10 : 0x20); 424 426 ret = ecn_brk_wai(data, sizeof(data)); 425 427 if (ret != E_OK) { … … 429 431 } 430 432 431 enum main_state_t{ 433 enum main_state_t { 434 main_state_start, 432 435 main_state_idle, 433 436 main_state_search, … … 440 443 441 444 int main_timer = TMO_FEVR; 442 enum main_state_t main_state = main_state_ idle;445 enum main_state_t main_state = main_state_start; 443 446 int16_t main_ave_templ; 444 447 bool_t main_tmp_fan_on; … … 470 473 LCD_DrawProp_t drawProp; 471 474 472 enum main_rly_state_t {475 enum main_rly_state_t { 473 476 main_rly_state_off, 474 477 main_rly_state_on … … 486 489 uint8_t btn; 487 490 488 /* 1秒後に温度センサーを探す */ 491 /* ECHONETミドルウェアを起動するのを待つ */ 492 main_state = main_state_start; 489 493 main_timer = 1000 * 1000; 490 494 … … 505 509 spi_init(&lcd.hspi, P10_14, P10_15, P10_12, NC); 506 510 spi_format(&lcd.hspi, 8, 0, 0); 507 spi_frequency(&lcd.hspi, 1000000);511 spi_frequency(&lcd.hspi, 4000000); 508 512 509 513 gpio_init_out(&lcd.cs_pin, P10_13); … … 524 528 main_lcd_timer = 1000 * 1000; 525 529 530 /* メインタスクを起動 */ 526 531 ER ret = act_tsk(MAIN_TASK); 527 532 if (ret != E_OK) { … … 537 542 int result = main_timer; 538 543 539 if ((result == TMO_FEVR)540 || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))) {544 if ((result == TMO_FEVR) 545 || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))) { 541 546 result = main_btn_timer; 542 547 } 543 548 544 if ((result == TMO_FEVR)545 || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))) {549 if ((result == TMO_FEVR) 550 || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))) { 546 551 result = main_lcd_timer; 547 552 } 548 553 549 if ((result == TMO_FEVR)550 || ((main_rly_timer != TMO_FEVR) && (main_rly_timer < result))) {554 if ((result == TMO_FEVR) 555 || ((main_rly_timer != TMO_FEVR) && (main_rly_timer < result))) { 551 556 result = main_rly_timer; 552 557 } … … 560 565 static void main_progress(int interval) 561 566 { 562 if (main_timer != TMO_FEVR){567 if (main_timer != TMO_FEVR) { 563 568 main_timer -= interval; 564 if (main_timer < 0){569 if (main_timer < 0) { 565 570 main_timer = 0; 566 571 } 567 572 } 568 573 569 if (main_btn_timer != TMO_FEVR){574 if (main_btn_timer != TMO_FEVR) { 570 575 main_btn_timer -= interval; 571 if (main_btn_timer < 0){576 if (main_btn_timer < 0) { 572 577 main_btn_timer = 0; 573 578 } 574 579 } 575 580 576 if (main_lcd_timer != TMO_FEVR){581 if (main_lcd_timer != TMO_FEVR) { 577 582 main_lcd_timer -= interval; 578 if (main_lcd_timer < 0){583 if (main_lcd_timer < 0) { 579 584 main_lcd_timer = 0; 580 585 } 581 586 } 582 587 583 if (main_rly_timer != TMO_FEVR){588 if (main_rly_timer != TMO_FEVR) { 584 589 main_rly_timer -= interval; 585 if (main_rly_timer < 0){590 if (main_rly_timer < 0) { 586 591 main_rly_timer = 0; 587 592 } … … 605 610 606 611 eobjid = ecn_get_eobj(esv); 607 if (eobjid == EOBJ_NULL){612 if (eobjid == EOBJ_NULL) { 608 613 syslog(LOG_ERROR, "ecn_get_eobj"); 609 614 } 610 615 611 616 ret = ecn_itr_ini(&enm, esv); 612 if (ret != E_OK){617 if (ret != E_OK) { 613 618 syslog(LOG_ERROR, "ecn_itr_ini"); 614 619 return; 615 620 } 616 621 617 for (;;) {618 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {622 for (;;) { 623 while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) { 619 624 switch (epc) { 620 625 case 0xD6: 621 switch (main_state){626 switch (main_state) { 622 627 case main_state_idle: 623 628 case main_state_search: … … 630 635 break; 631 636 case 0xE0: 632 switch (main_state){637 switch (main_state) { 633 638 case main_state_survey_01: 634 639 /* 温度センサー2温度監視 */ … … 660 665 } 661 666 } 662 if (ret != E_BOVR){667 if (ret != E_BOVR) { 663 668 syslog(LOG_ERROR, "ecn_itr_nxt"); 664 669 break; 665 670 } 666 if (enm.is_eof)671 if (enm.is_eof) 667 672 break; 668 673 } … … 685 690 /* 温度センサー動作状態取得電文作成 */ 686 691 ret = ecn_esv_get(&esv, senserids[no - 1], 0x80); 687 if (ret != E_OK){692 if (ret != E_OK) { 688 693 syslog(LOG_ERROR, "ecn_esv_get"); 689 694 return; … … 692 697 /* 温度計測値取得追加 */ 693 698 ret = ecn_add_epc(esv, 0xE0); 694 if (ret != E_OK){699 if (ret != E_OK) { 695 700 syslog(LOG_ERROR, "ecn_add_epc"); 696 701 697 702 ret = ecn_rel_esv(esv); 698 if (ret != E_OK){703 if (ret != E_OK) { 699 704 syslog(LOG_ERROR, "ecn_rel_esv"); 700 705 } … … 704 709 /* 電文送信 */ 705 710 ret = ecn_snd_esv(esv); 706 if (ret != E_OK){711 if (ret != E_OK) { 707 712 syslog(LOG_ERROR, "ecn_snd_esv"); 708 713 } … … 717 722 int templ = 0; 718 723 719 if (temp_sensor_01_data.property80 == 0x30){724 if (temp_sensor_01_data.property80 == 0x30) { 720 725 templ += ((((uint16_t)temp_sensor_01_data.propertyE0) & 0xFF) << 8) 721 726 | ((((uint16_t)temp_sensor_01_data.propertyE0) & 0xFF00) >> 8); 722 727 count++; 723 728 } 724 if (temp_sensor_02_data.property80 == 0x30){729 if (temp_sensor_02_data.property80 == 0x30) { 725 730 templ += ((((uint16_t)temp_sensor_02_data.propertyE0) & 0xFF) << 8) 726 731 | ((((uint16_t)temp_sensor_02_data.propertyE0) & 0xFF00) >> 8); 727 732 count++; 728 733 } 729 if (temp_sensor_03_data.property80 == 0x30){734 if (temp_sensor_03_data.property80 == 0x30) { 730 735 templ += ((((uint16_t)temp_sensor_03_data.propertyE0) & 0xFF) << 8) 731 736 | ((((uint16_t)temp_sensor_03_data.propertyE0) & 0xFF00) >> 8); 732 737 count++; 733 738 } 734 if (temp_sensor_04_data.property80 == 0x30){739 if (temp_sensor_04_data.property80 == 0x30) { 735 740 templ += ((((uint16_t)temp_sensor_04_data.propertyE0) & 0xFF) << 8) 736 741 | ((((uint16_t)temp_sensor_04_data.propertyE0) & 0xFF00) >> 8); … … 738 743 } 739 744 740 if (count > 0){745 if (count > 0) { 741 746 templ = templ / count; 742 if (templ < -2732)747 if (templ < -2732) 743 748 main_ave_templ = 0x8000; 744 else if (templ > 32766)749 else if (templ > 32766) 745 750 main_ave_templ = 0x7FFF; 746 751 else … … 748 753 749 754 /* FANが停止中の場合 */ 750 if (!main_tmp_fan_on){751 if (main_ave_templ > (10 * home_air_conditioner_data.propertyB3 + 5)){755 if (!main_tmp_fan_on) { 756 if (main_ave_templ > (10 * home_air_conditioner_data.propertyB3 + 5)) { 752 757 main_tmp_fan_on = true; 753 758 … … 758 763 } 759 764 /* FANが稼働中の場合 */ 760 else {761 if (main_ave_templ < (10 * home_air_conditioner_data.propertyB3 - 5)){765 else { 766 if (main_ave_templ < (10 * home_air_conditioner_data.propertyB3 - 5)) { 762 767 main_tmp_fan_on = false; 763 768 … … 777 782 static void main_break_wait(uint8_t *brkdat, int32_t len) 778 783 { 784 char mac_text[30] = "mac: "; 785 char ipaddr_text[30] = "ipadr: "; 786 const T_IN4_ADDR *ip4_addr; 787 int pos; 788 bool_t prev; 789 779 790 switch (brkdat[0]) { 780 791 case 0x01: 781 // Link up/down 792 switch (brkdat[1] >> 4) { 793 case 1: 794 break; 795 case 2: 796 break; 797 } 798 799 pos = str_macaddr(&mac_text[4], sizeof(mac_text) - 4, mac_addr, 0); 800 mac_text[pos + 4] = '\0'; 801 lcd_drawString(&lcd, mac_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 11), ST7735_BLACK, ST7735_WHITE); 802 803 ip4_addr = in4_get_ifaddr(0); 804 pos = str_ipv4addr(&ipaddr_text[6], sizeof(ipaddr_text) - 6, ip4_addr, 0); 805 ipaddr_text[pos + 6] = '\0'; 806 lcd_drawString(&lcd, ipaddr_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 12), ST7735_BLACK, ST7735_WHITE); 782 807 break; 783 808 } 784 809 785 810 /* 運転モードが送風の場合、温度によらずFANをON */ 786 if (*brkdat == 0xB0) { 787 bool_t prev = main_ctl_fan_on; 811 switch (*brkdat) { 812 case 0x80: 813 if (main_ctl_fan_on) { 814 /* リレー出力をON/OFF */ 815 main_rly_onoff(home_air_conditioner_data.property80 == 0x30); 816 } 817 break; 818 case 0xB0: 819 prev = main_ctl_fan_on; 788 820 main_ctl_fan_on = home_air_conditioner_data.propertyB0 == 0x45; 789 821 790 822 if (prev != main_ctl_fan_on) { 791 823 if (main_ctl_fan_on) { 792 /* リレー出力をON */ 793 if (!main_tmp_fan_on) 794 main_rly_onoff(true); 824 /* リレー出力をON/OFF */ 825 main_rly_onoff(home_air_conditioner_data.property80 == 0x30); 795 826 } 796 827 else { 797 /* リレー出力をOFF */ 798 if (!main_tmp_fan_on) 799 main_rly_onoff(false); 828 /* リレー出力をON/OFF */ 829 main_rly_onoff(main_tmp_fan_on); 800 830 } 801 831 } … … 813 843 static void main_timeout() 814 844 { 815 if (main_timer == 0){845 if (main_timer == 0) { 816 846 main_ontimer(); 817 847 } 818 848 819 if (main_btn_timer == 0){849 if (main_btn_timer == 0) { 820 850 main_btn_ontimer(); 821 851 } 822 852 823 if (main_lcd_timer == 0){853 if (main_lcd_timer == 0) { 824 854 main_lcd_ontimer(); 825 855 } 826 856 827 if (main_rly_timer == 0){857 if (main_rly_timer == 0) { 828 858 main_rly_ontimer(); 829 859 } … … 834 864 static void main_ontimer() 835 865 { 836 switch(main_state){ 866 ER ret; 867 868 switch (main_state) { 869 case main_state_start: 870 /* ECHONETミドルウェアを起動 */ 871 ret = ecn_sta_svc(); 872 if (ret != E_OK) { 873 syslog(LOG_ERROR, "ecn_sta_svc"); 874 } 875 876 /* 1秒後に温度センサーを探す */ 877 main_state = main_state_idle; 878 main_timer = 1000 * 1000; 879 break; 837 880 case main_state_idle: 838 881 case main_state_search: … … 891 934 /* 温度センサー検索 */ 892 935 ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6); 893 if (ret != E_OK){936 if (ret != E_OK) { 894 937 syslog(LOG_ERROR, "ecn_esv_inf_req"); 895 938 return; … … 898 941 /* 電文送信 */ 899 942 ret = ecn_snd_esv(esv); 900 if (ret != E_OK){943 if (ret != E_OK) { 901 944 syslog(LOG_ERROR, "ecn_snd_esv"); 902 945 } … … 919 962 if ((btn == BUTTON_LEFT) && !main_btn1_state) { 920 963 main_btn1_count++; 921 if (main_btn1_count > 10){964 if (main_btn1_count > 10) { 922 965 main_btn1_count = 0; 923 966 main_btn1_state = true; … … 928 971 else if ((btn != BUTTON_LEFT) && main_btn1_state) { 929 972 main_btn1_count++; 930 if (main_btn1_count > 10){973 if (main_btn1_count > 10) { 931 974 main_btn1_count = 0; 932 975 main_btn1_state = false; … … 939 982 if ((btn == BUTTON_RIGHT) && !main_btn2_state) { 940 983 main_btn2_count++; 941 if (main_btn2_count > 10){984 if (main_btn2_count > 10) { 942 985 main_btn2_count = 0; 943 986 main_btn2_state = true; … … 948 991 else if ((btn != BUTTON_RIGHT) && main_btn2_state) { 949 992 main_btn2_count++; 950 if (main_btn2_count > 10){993 if (main_btn2_count > 10) { 951 994 main_btn2_count = 0; 952 995 main_btn2_state = false; … … 963 1006 char temp2[] = "測定温度:+00.0℃"; 964 1007 char mode[] = "運転モード:自動 "; 965 char *mode_texts[] = { " 自動 ", "冷房 ", "暖房 ", "除湿 ", "送風 ", "その他" };1008 char *mode_texts[] = { "その他", "自動 ", "冷房 ", "暖房 ", "除湿 ", "送風 " }; 966 1009 char *btn_texts[] = { "none ", "down ", "left ", "select", "up ", "right " }; 967 1010 int temp, btn; … … 979 1022 power[11] = 'f'; 980 1023 } 981 lcd_drawString(&lcd, &power[9], X_LINE_HALF_TO_PIX(&lcd, 6) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);1024 lcd_drawString(&lcd, &power[9], X_LINE_HALF_TO_PIX(&lcd, 6), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE); 982 1025 main_lcd_state++; 983 1026 break; … … 992 1035 temp = -temp; 993 1036 temp1[17] = '0' + temp; 994 lcd_drawString(&lcd, &temp1[15], X_LINE_HALF_TO_PIX(&lcd, 10) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);1037 lcd_drawString(&lcd, &temp1[15], X_LINE_HALF_TO_PIX(&lcd, 10), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE); 995 1038 main_lcd_state++; 996 1039 break; … … 1009 1052 temp = -temp; 1010 1053 temp2[19] = '0' + temp; 1011 lcd_drawString(&lcd, &temp2[15], X_LINE_HALF_TO_PIX(&lcd, 10) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);1054 lcd_drawString(&lcd, &temp2[15], X_LINE_HALF_TO_PIX(&lcd, 10), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE); 1012 1055 main_lcd_state++; 1013 1056 break; 1014 1057 case 3: 1015 1058 temp = home_air_conditioner_data.propertyB0 - 0x40; 1016 lcd_drawString(&lcd, mode_texts[temp], X_LINE_HALF_TO_PIX(&lcd, 12) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);1059 lcd_drawString(&lcd, mode_texts[temp], X_LINE_HALF_TO_PIX(&lcd, 12), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE); 1017 1060 main_lcd_state++; 1018 1061 break; … … 1023 1066 case 6: 1024 1067 btn = main_read_button(&joystick); 1025 lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 10) + 10, ST7735_BLACK, ST7735_WHITE);1068 lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 9), ST7735_BLACK, ST7735_WHITE); 1026 1069 main_lcd_state++; 1027 1070 break; … … 1030 1073 break; 1031 1074 case 10: 1032 lcd_drawString(&lcd, "エアコン", X_LINE_TO_PIX(&lcd, 9) + 10, Y_ROW_TO_PIX(&lcd, 0) + 10, ST7735_BLACK, ST7735_WHITE);1033 lcd_drawString(&lcd, power, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 0 + 4) + 10, ST7735_BLACK, ST7735_WHITE);1034 lcd_drawString(&lcd, temp1, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 1 + 4) + 10, ST7735_BLACK, ST7735_WHITE);1035 lcd_drawString(&lcd, temp2, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 2 + 4) + 10, ST7735_BLACK, ST7735_WHITE);1036 lcd_drawString(&lcd, mode, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 3 + 4) + 10, ST7735_BLACK, ST7735_WHITE);1075 lcd_drawString(&lcd, "エアコン", X_LINE_TO_PIX(&lcd, 6), Y_ROW_TO_PIX(&lcd, 0), ST7735_BLACK, ST7735_WHITE); 1076 lcd_drawString(&lcd, power, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 0 + 2), ST7735_BLACK, ST7735_WHITE); 1077 lcd_drawString(&lcd, temp1, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 1 + 2), ST7735_BLACK, ST7735_WHITE); 1078 lcd_drawString(&lcd, temp2, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 2 + 2), ST7735_BLACK, ST7735_WHITE); 1079 lcd_drawString(&lcd, mode, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 3 + 2), ST7735_BLACK, ST7735_WHITE); 1037 1080 main_lcd_state = 0; 1038 1081 break; … … 1079 1122 1080 1123 /* 押されて戻った時に処理する */ 1081 if (push)1124 if (push) 1082 1125 return; 1083 1126 1084 1127 /* 設定温度 */ 1085 if (main_templ > 0)1128 if (main_templ > 0) 1086 1129 main_templ--; /* - 1℃ */ 1087 1130 … … 1090 1133 /* プロパティ設定電文作成 */ 1091 1134 ret = ecn_esv_seti(&esv, HOME_AIR_CONDITIONER_EOBJ, 0xB3, 1, p_edt); 1092 if (ret != E_OK){1135 if (ret != E_OK) { 1093 1136 syslog(LOG_ERROR, "ecn_esv_seti"); 1094 1137 return; … … 1096 1139 1097 1140 /* 電文送信 */ 1098 ecn_snd_esv(esv);1099 if (ret != E_OK){1141 ret = ecn_snd_esv(esv); 1142 if (ret != E_OK) { 1100 1143 syslog(LOG_ERROR, "ecn_snd_esv"); 1101 1144 } … … 1112 1155 1113 1156 /* 押されて戻った時に処理する */ 1114 if (push)1157 if (push) 1115 1158 return; 1116 1159 1117 1160 /* 設定温度 */ 1118 if (main_templ < 50)1161 if (main_templ < 50) 1119 1162 main_templ++; /* + 1.0℃ */ 1120 1163 … … 1123 1166 /* プロパティ設定電文作成 */ 1124 1167 ret = ecn_esv_seti(&esv, HOME_AIR_CONDITIONER_EOBJ, 0xB3, 1, p_edt); 1125 if (ret != E_OK){1168 if (ret != E_OK) { 1126 1169 syslog(LOG_ERROR, "ecn_esv_seti"); 1127 1170 return; … … 1129 1172 1130 1173 /* 電文送信 */ 1131 ecn_snd_esv(esv);1132 if (ret != E_OK){1174 ret = ecn_snd_esv(esv); 1175 if (ret != E_OK) { 1133 1176 syslog(LOG_ERROR, "ecn_snd_esv"); 1134 1177 } … … 1137 1180 static void main_rly_onoff(bool_t onoff) 1138 1181 { 1139 if (onoff){1182 if (onoff) { 1140 1183 /* リレー出力をON */ 1141 1184 gpio_write(&relay_sw, 1); 1142 1185 } 1143 else {1186 else { 1144 1187 /* リレー出力をOFF */ 1145 1188 gpio_write(&relay_sw, 0); … … 1159 1202 /* 500msパルス出力 */ 1160 1203 main_rly_state = main_rly_state_on; 1161 main_rly_timer = 500 ;1204 main_rly_timer = 500 * 1000; 1162 1205 } 1163 1206 … … 1167 1210 static void main_rly_ontimer() 1168 1211 { 1169 switch(main_rly_state) 1170 { 1212 switch (main_rly_state) { 1171 1213 case main_rly_state_off: 1172 1214 main_rly_timer = TMO_FEVR; -
asp3_tinet_ecnl_arm/trunk/app4_aircon/src/main.c
r359 r364 79 79 80 80 ID ws_api_mailboxid = MAIN_DATAQUEUE; 81 #ifndef NOUSE_MPF_NET_BUF 81 82 ID ws_mempoolid = MPF_NET_BUF_256; 83 #endif 82 84 83 85 #ifdef IF_ETHER_BTUSB … … 111 113 static void main_timeout(); 112 114 115 extern int ntshell_exit; 116 113 117 int uart_read(char *buf, int cnt, void *extobj) 114 118 { 115 return serial_rea_dat(SIO_PORTID, (char *)buf, cnt); 119 struct main_t *obj = (struct main_t *)extobj; 120 int result; 121 ER ret; 122 int timer; 123 124 obj->prev = obj->now; 125 126 /* タイマー取得 */ 127 timer = main_get_timer(); 128 129 /* 待ち */ 130 ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer); 131 if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) { 132 syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer); 133 ntshell_exit = 1; 134 return -1; 135 } 136 result = (int)ret; 137 138 ret = get_tim(&obj->now); 139 if (ret != E_OK) { 140 syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret)); 141 ntshell_exit = 1; 142 return -1; 143 } 144 145 /* 時間経過 */ 146 int elapse = obj->now - obj->prev; 147 main_progress(elapse); 148 149 /* タイムアウト処理 */ 150 main_timeout(); 151 152 return result; 116 153 } 117 154 … … 119 156 { 120 157 return serial_wri_dat(SIO_PORTID, buf, cnt); 121 }122 123 unsigned char ntstdio_xi(struct ntstdio_t *handle)124 {125 char buf[1];126 if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)127 return -EIO;128 return buf[0];129 }130 131 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)132 {133 char buf[1];134 buf[0] = c;135 serial_wri_dat(SIO_PORTID, buf, 1);