Changeset 364 for asp3_tinet_ecnl_arm


Ignore:
Timestamp:
Feb 1, 2019, 9:57:09 PM (5 years ago)
Author:
coas-nagasima
Message:

TINETとSocket APIなどを更新

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  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <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"/>
    6060                                                        <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"/>
    6262                                                        <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">
    6363                                                                <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"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <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"/>
    165165                                                        <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"/>
    167167                                                        <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">
    168168                                                                <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"/>
     
    232232                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    233233                                <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"/>
    235235                        </storageModule>
    236236                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    269269                                                        <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"/>
    270270                                                        <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"/>
    272272                                                        <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">
    273273                                                                <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"/>
     
    341341                </configuration>
    342342        </storageModule>
     343        <storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
    343344</cproject>
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/Debug/Makefile

    r352 r364  
    182182        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    183183endif
    184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     184CDEFS := $(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
    185185INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    186186        -I$(SRCDIR)/../btstack/include \
     
    196196        -I$(SRCDIR)/../curl-7.57.0 \
    197197        $(INCLUDES)
    198 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     198LDFLAGS := $(LDFLAGS) -L.
    199199LIBS := $(LIBS) $(CXXLIBS)
    200200CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    207207APPL_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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     210APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    210211
    211212#
     
    220221APPL_ASMOBJS :=
    221222ifdef 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
    223224        APPL_COBJS := $(APPL_COBJS)
    224225else
    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
    226227endif
    227228APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
     
    232233endif
    233234
    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
     235ifdef 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
     265endif
    264266
    265267#
     
    294296#  コンフィギュレータに関する定義
    295297#
    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 \
     298ifndef 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)
     302else
     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 \
    298305                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    299306                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    301308                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    302309                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     310endif
    303311CFG_ASMOBJS := $(CFG_ASMOBJS)
    304312CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    446454
    447455#
     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#
    448463#  特別な依存関係の定義
    449464#
     
    454469#
    455470$(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 \
    457472                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    458473                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEnbt/Makefile

    r352 r364  
    182182        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    183183endif
    184 CDEFS := $(CDEFS) -DIF_ETHER_MULTI_NIC -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     184CDEFS := $(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
    185185INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    186186        -I$(SRCDIR)/../btstack/include \
     
    196196        -I$(SRCDIR)/../curl-7.57.0 \
    197197        $(INCLUDES)
    198 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     198LDFLAGS := $(LDFLAGS) -L.
    199199LIBS := $(LIBS) $(CXXLIBS)
    200200CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    207207APPL_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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     210APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    210211
    211212#
     
    220221APPL_ASMOBJS :=
    221222ifdef 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
    223224        APPL_COBJS := $(APPL_COBJS)
    224225else
    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
    226227endif
    227228APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
     
    232233endif
    233234
    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
     235ifdef 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
     265endif
    264266
    265267#
     
    294296#  コンフィギュレータに関する定義
    295297#
    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 \
     298ifndef 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)
     302else
     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 \
    298305                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    299306                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    301308                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    302309                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     310endif
    303311CFG_ASMOBJS := $(CFG_ASMOBJS)
    304312CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    446454
    447455#
     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#
    448463#  特別な依存関係の定義
    449464#
     
    454469#
    455470$(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 \
    457472                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    458473                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/DebugEther/Makefile

    r352 r364  
    182182        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    183183endif
    184 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DHAVE_CONFIG_H -DWOLFSSL_USER_SETTINGS -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     184CDEFS := $(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
    185185INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    186186        -I$(SRCDIR)/../btstack/include \
     
    196196        -I$(SRCDIR)/../curl-7.57.0 \
    197197        $(INCLUDES)
    198 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     198LDFLAGS := $(LDFLAGS) -L.
    199199LIBS := $(LIBS) $(CXXLIBS)
    200200CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    207207APPL_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
    208208APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    209 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     209APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     210APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    210211
    211212#
     
    220221APPL_ASMOBJS :=
    221222ifdef 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
    223224        APPL_COBJS := $(APPL_COBJS)
    224225else
    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
    226227endif
    227228APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o
     
    232233endif
    233234
    234 
    235 #
    236 #  ネットワークサービスの定義
    237 #
    238 NO_USE_TINET_LIBRARY = true
    239 
    240 #  ネットワークインタフェースの選択、何れか一つ選択する。
    241 NET_IF = ether
    242 
    243 #  イーサネット・ディバイスドライバの選択
     235ifdef TINETDIR
     236        #
     237        #  ネットワークサービスの定義
     238        #
     239        NO_USE_TINET_LIBRARY = true
     240
     241        #  ネットワークインタフェースの選択、何れか一つ選択する。
     242        NET_IF = ether
     243
     244        #  イーサネット・ディバイスドライバの選択
    244245        NET_DEV = if_mbed
    245246
    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
     265endif
    264266
    265267#
     
    294296#  コンフィギュレータに関する定義
    295297#
    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 \
     298ifndef 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)
     302else
     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 \
    298305                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    299306                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    301308                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    302309                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     310endif
    303311CFG_ASMOBJS := $(CFG_ASMOBJS)
    304312CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    446454
    447455#
     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#
    448463#  特別な依存関係の定義
    449464#
     
    454469#
    455470$(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 \
    457472                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    458473                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/client.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2016 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
     
    4848#include "ff.h"
    4949#include "util/ntstdio.h"
     50#include "client.h"
     51#include "jsonsl.h"
    5052
    5153#define SKIP_PEER_VERIFICATION
    5254//#define SKIP_HOSTNAME_VERIFICATION
     55
     56const char SCOPE_DRIVE_FILE[] = "https://www.googleapis.com/auth/drive.file";
     57const char GRANT_TYPE_DEVICE[] = "http://oauth.net/grant_type/device/1.0";
     58
    5359char response[80];
    54 extern ntstdio_t ntstdio;
     60char errbuf[CURL_ERROR_SIZE];
     61
     62google_drive_t google_drive;
     63
     64void curl_setopt_common(CURL *curl);
     65int google_drive_error_callback(jsonsl_t jsn, jsonsl_error_t err,
     66        struct jsonsl_state_st *state, char *errat);
     67void google_drive_state_callback(jsonsl_t jsn, jsonsl_action_t action,
     68        struct jsonsl_state_st *state, const char *buf);
    5569
    5670void client_init(void)
    5771{
     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
    5884        //uITRON4_minit(ITRON_POOL_SIZE);
    5985
     
    6187}
    6288
    63 size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp)
    64 {
    65         int rest = size * nmemb;
     89size_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
     107void 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
     181void get_device_id_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     182{
     183}
     184
     185int 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
     238void 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
     312void get_access_token_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     313{
     314}
     315
     316int 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
     373void 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
     438void update_access_token_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     439{
     440}
     441
     442int 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
     498void revoke_device_state_start(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     499{
     500}
     501
     502void revoke_device_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     503{
     504}
     505
     506int 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
     553void 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
     618void upload_file_state_end(google_drive_t *gd, struct jsonsl_state_st *state, const char *buf)
     619{
     620}
     621
     622size_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;
    66633        int len;
    67634
     
    76643                response[len] = '\0';
    77644
    78                 ntstdio_printf(&ntstdio, response);
    79 
    80                 dly_tsk(100 * 1000);
     645                printf(response);
     646
     647                dly_tsk(100);
    81648
    82649                rest -= len;
     
    84651        }
    85652
    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 
    120653        return ret;
    121654}
    122655
    123 char errbuf[CURL_ERROR_SIZE];
     656int 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
     683int 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
     760int 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
     766void 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}
    124808
    125809static void get_logfname(char *fname)
     
    185869        ret = f_open(&file, fname, FA_CREATE_ALWAYS | FA_WRITE);
    186870        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);
    188872                return ret;
    189873        }
     
    232916        f_putc('}', &file);
    233917
    234 file_close:
    235918        f_close(&file);
    236919
     
    238921}
    239922
    240 void client_task(intptr_t exinf)
    241 {
    242         CURL *curl;
     923void curl_setopt_common(CURL *curl)
     924{
    243925        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         }
    272926
    273927        /* 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);
    277929        if (res != CURLE_OK)
    278                 ntstdio_printf(&ntstdio, "CURLOPT_URL failed: %s\n",
     930                printf("CURLOPT_VERBOSE failed: %s\n",
    279931                        curl_easy_strerror(res));
    280932
     
    283935
    284936        /* 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));
    286941
    287942#ifdef SKIP_PEER_VERIFICATION
     
    298953        res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
    299954        if (res != CURLE_OK)
    300                 ntstdio_printf(&ntstdio, "CURLOPT_SSL_VERIFYPEER failed: %s\n",
     955                printf("CURLOPT_SSL_VERIFYPEER failed: %s\n",
    301956                        curl_easy_strerror(res));
    302957#else
    303958        res = curl_easy_setopt(curl, CURLOPT_CAINFO, "0:/certs/ca-cert.pem");
    304959        if (res != CURLE_OK)
    305                 ntstdio_printf(&ntstdio, "CURLOPT_CAINFO failed: %s\n",
     960                printf("CURLOPT_CAINFO failed: %s\n",
    306961                        curl_easy_strerror(res));
    307962
    308963        res = curl_easy_setopt(curl, CURLOPT_SSLCERT, "0:/certs/client-cert.pem");
    309964        if (res != CURLE_OK)
    310                 ntstdio_printf(&ntstdio, "CURLOPT_SSLCERT failed: %s\n",
     965                printf("CURLOPT_SSLCERT failed: %s\n",
    311966                        curl_easy_strerror(res));
    312967
    313968        res = curl_easy_setopt(curl, CURLOPT_SSLKEY, "0:/certs/client-key.pem");
    314969        if (res != CURLE_OK)
    315                 ntstdio_printf(&ntstdio, "CURLOPT_SSLKEY failed: %s\n",
     970                printf("CURLOPT_SSLKEY failed: %s\n",
    316971                        curl_easy_strerror(res));
    317972#endif
     
    326981        res = curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
    327982        if (res != CURLE_OK)
    328                 ntstdio_printf(&ntstdio, "CURLOPT_SSL_VERIFYHOST failed: %s\n",
     983                printf("CURLOPT_SSL_VERIFYHOST failed: %s\n",
    329984                        curl_easy_strerror(res));
    330985#endif
     
    332987        /*res = curl_easy_setopt(curl, CURLOPT_PROXY, "https://proxy.example.com:8080");
    333988        if (res != CURLE_OK)
    334                 ntstdio_printf(&ntstdio, "CURLOPT_PROXY failed: %s\n",
     989                printf("CURLOPT_PROXY failed: %s\n",
    335990                        curl_easy_strerror(res));*/
    336991
    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",
    368995                        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
     1008void 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
     1015void 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
     1022int 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
     1040int 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
     1058int 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
     1075int 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
     1091int 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
     1117void client_final(void)
     1118{
     1119        google_drive_t *gd = &google_drive;
     1120        jsonsl_t jsn = gd->jsn;
     1121
    3831122        curl_global_cleanup();
    384 }
     1123        jsonsl_destroy(jsn);
     1124}
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/client.h

    r352 r364  
    3939#define _CLIENT_H_
    4040
    41 #include <kernel.h>
    42 #include "target_kernel_impl.h"
     41typedef struct client_info_t {
     42        char client_id[80];
     43        char client_secret[32];
     44} client_info_t;
    4345
    44 #define CLIENT_PRIORITY         4               /* クライアントタスクの優先度 */
     46typedef 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;
    4557
    46 #define CLIENT_STACK_SIZE       6144    /* スタック領域のサイズ */
     58typedef struct error_response_t {
     59        char error[64];
     60        char error_description[64];
     61} error_response_t;
    4762
    48 extern void client_init(void);
    49 extern void client_task(intptr_t exinf);
    50 extern void client_fin(void);
     63typedef 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
     70typedef 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
     89struct jsonsl_st;
     90typedef struct jsonsl_st *jsonsl_t;
     91
     92typedef void (*parser_callback_t)(struct google_drive_t *gd, struct jsonsl_state_st *state, const char *buf);
     93
     94typedef 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
     108extern google_drive_t google_drive;
     109
     110void client_init(void);
     111void client_final(void);
     112
     113void client_set_client_id(const char *client_id);
     114void client_set_client_secret(const char *client_secret);
     115int client_get_device_id(int argc, char **argv);
     116int client_get_access_token(int argc, char **argv);
     117int client_update_access_token(int argc, char **argv);
     118int client_revoke(int argc, char **argv);
     119int client_upload_file(int argc, char **argv);
    51120
    52121#endif /* _CLIENT_H_ */
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2016-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    164164{
    165165        /* サイズが1以外は受け付けない */
    166         if(size != 1)
     166        if (size != 1)
    167167                return 0;
    168168
    169169        *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src);
    170170
    171         switch(*(uint8_t *)src){
     171        switch (*(uint8_t *)src) {
    172172        /* ONの場合 */
    173173        case 0x30:
     
    196196{
    197197        /* サイズが1以外は受け付けない */
    198         if(size != 1)
     198        if (size != 1)
    199199                return 0;
    200200
    201201        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    202202
    203         switch(*(uint8_t *)src){
     203        switch (*(uint8_t *)src) {
    204204        /* 異常発生ありの場合 */
    205205        case 0x41:
     
    271271int date_prop_set(const EPRPINIB *item, const void *src, int size, bool_t *anno)
    272272{
    273         uint8_t *p_src;
     273        const uint8_t *p_src;
    274274        time_t temp;
    275275        struct tm _tm;
     
    283283        /* 年月日設定 */
    284284        p_src = (uint8_t *)src;
    285         _tm.tm_year = (*(p_src++) * 100) + *p_src++;
     285        _tm.tm_year = (*p_src++ * 100) + *p_src++;
    286286        _tm.tm_mon = (*p_src++) - 1;
    287287        _tm.tm_mday = *p_src++;
     
    325325
    326326        /* サイズが4以外は受け付けない */
    327         if(size != 4)
     327        if (size != 4)
    328328                return 0;
    329329
     
    345345
    346346        len = 48 - meter->current_pos;
    347         if(len > 0)
     347        if (len > 0)
    348348                memcpy(dst, &meter->integral_electric_energy_measurement_log[meter->current_pos], sizeof(uint32_t) * len);
    349349        dst = &((uint8_t *)dst)[len];
     
    404404
    405405        ret2 = get_tim(&now);
    406         if (ret2 != E_OK){
     406        if (ret2 != E_OK) {
    407407                syslog(LOG_ERROR, "get_tim");
    408408                return;
    409409        }
    410410
    411         for(;;){
     411        for (;;) {
    412412                prev = now;
    413413
     
    417417                /* 応答電文待ち */
    418418                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)) {
    420420                        syslog(LOG_ERROR, "ecn_trcv_esv");
    421421                        break;
     
    423423
    424424                ret2 = get_tim(&now);
    425                 if (ret2 != E_OK){
     425                if (ret2 != E_OK) {
    426426                        syslog(LOG_ERROR, "get_tim");
    427427                        break;
     
    438438                        /* 領域解放 */
    439439                        ret = ecn_rel_esv(esv);
    440                         if (ret != E_OK){
     440                        if (ret != E_OK) {
    441441                                syslog(LOG_ERROR, "ecn_rel_esv");
    442442                                break;
     
    447447                        /* 応答電文待ちの割り込みデータ取得 */
    448448                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    449                         if (ret != E_OK){
     449                        if (ret != E_OK) {
    450450                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    451451                                break;
     
    457457                        /* 領域解放 */
    458458                        ret = ecn_rel_esv(esv);
    459                         if (ret != E_OK){
     459                        if (ret != E_OK) {
    460460                                syslog(LOG_ERROR, "ecn_rel_esv");
    461461                                break;
     
    468468}
    469469
    470 bool_t started = false;
    471 
    472470void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    473471{
     
    477475                return;
    478476
    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                }
    489483        }
    490484
     
    500494}
    501495
    502 enum main_state_t{
     496enum main_state_t {
     497        main_state_start,
    503498        main_state_idle,
    504499};
    505500
    506501int main_timer = TMO_FEVR;
    507 enum main_state_t main_state = main_state_idle;
     502enum main_state_t main_state = main_state_start;
    508503int main_lcd_state = 0;
    509504int main_lcd_timer = TMO_FEVR;
     
    557552        analogin_init(&joystick, P1_12);
    558553
    559         /* 10ms後にボタン状態を確認 */
    560         main_timer = 10 * 1000;
    561 
    562         /* ボタン状態読み込み */
     554        /* ECHONETミドルウェアを起動するのを待つ */
     555        main_state = main_state_start;
     556        main_timer = 1000 * 1000;
     557
    563558        btn = main_read_button(&joystick);
    564559        main_btn1_state = btn == BUTTON_LEFT;
     
    568563        spi_init(&lcd.hspi, P10_14, P10_15, P10_12, NC);
    569564        spi_format(&lcd.hspi, 8, 0, 0);
    570         spi_frequency(&lcd.hspi, 1000000);
     565        spi_frequency(&lcd.hspi, 4000000);
    571566
    572567        gpio_init_out(&lcd.cs_pin, P10_13);
     
    590585        main_adv_timer = 1000 * 1000;
    591586
     587        /* メインタスクを起動 */
    592588        ER ret = act_tsk(MAIN_TASK);
    593589        if (ret != E_OK) {
     
    603599        int result = main_timer;
    604600
    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))) {
    607603                result = main_lcd_timer;
    608604        }
     
    621617static void main_progress(int interval)
    622618{
    623         if(main_timer != TMO_FEVR){
     619        if (main_timer != TMO_FEVR) {
    624620                main_timer -= interval;
    625                 if(main_timer < 0){
     621                if (main_timer < 0) {
    626622                        main_timer = 0;
    627623                }
    628624        }
    629625
    630         if(main_lcd_timer != TMO_FEVR){
     626        if (main_lcd_timer != TMO_FEVR) {
    631627                main_lcd_timer -= interval;
    632                 if(main_lcd_timer < 0){
     628                if (main_lcd_timer < 0) {
    633629                        main_lcd_timer = 0;
    634630                }
     
    655651
    656652        ret = ecn_itr_ini(&enm, esv);
    657         if(ret != E_OK){
     653        if (ret != E_OK) {
    658654                syslog(LOG_ERROR, "ecn_itr_ini");
    659655                return;
    660656        }
    661657
    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) {
    664660                        switch (epc) {
    665661                        case 0x80:
     
    669665                        }
    670666                }
    671                 if(ret != E_BOVR){
     667                if (ret != E_BOVR) {
    672668                        syslog(LOG_ERROR, "ecn_itr_nxt");
    673669                        break;
    674670                }
    675                 if(enm.is_eof)
     671                if (enm.is_eof)
    676672                        break;
    677673        }
     
    684680{
    685681        char mac_text[30] = "mac: ";
    686         char ipaddr_text[30] = "ipaddr: ";
    687         T_IN4_ADDR *ip4_addr;
     682        char ipaddr_text[30] = "ipadr: ";
     683        const T_IN4_ADDR *ip4_addr;
    688684        int pos;
    689685
    690         switch(main_state){
     686        switch (main_state) {
    691687        case main_state_idle:
    692688                if (len == 0)
     
    704700                        pos = str_macaddr(&mac_text[4], sizeof(mac_text) - 4, mac_addr, 0);
    705701                        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);
    707703
    708704                        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);
    712708                }
    713709                break;
     
    724720static void main_timeout()
    725721{
    726         if(main_timer == 0){
     722        if (main_timer == 0) {
    727723                main_ontimer();
    728724        }
    729725
    730         if(main_lcd_timer == 0){
     726        if (main_lcd_timer == 0) {
    731727                main_lcd_ontimer();
    732728        }
     
    746742        int port_no, btn;
    747743
    748         switch(main_lcd_state) {
     744        switch (main_lcd_state) {
    749745        case 0:
    750746        case 1:
     
    757753                text[16] = '0' + main_7seg[port_no][2];
    758754                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);
    760756                main_lcd_state++;
    761757                break;
    762758        case 6:
    763759                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);
    765761                main_lcd_state++;
    766762                break;
     
    769765                break;
    770766        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);
    772768                for (port_no = 0; port_no < 6; port_no++) {
    773769                        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);
    775771                }
    776772                main_lcd_state = 0;
     
    802798static void main_ontimer()
    803799{
     800        ER ret;
    804801        uint8_t btn;
    805802        uint16_t ad_value;
    806803
    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;
    808816        case main_state_idle:
    809817                /* 10ms後にボタン状態を確認 */
     
    845853
    846854                /* ボタン1の処理 */
    847                 if((btn == BUTTON_LEFT) && !main_btn1_state){
     855                if ((btn == BUTTON_LEFT) && !main_btn1_state) {
    848856                        main_btn1_count++;
    849                         if(main_btn1_count > 10){
     857                        if (main_btn1_count > 10) {
    850858                                main_btn1_count = 0;
    851859                                main_btn1_state = true;
     
    854862                        }
    855863                }
    856                 else if((btn != BUTTON_LEFT) && main_btn1_state){
     864                else if ((btn != BUTTON_LEFT) && main_btn1_state) {
    857865                        main_btn1_count++;
    858                         if(main_btn1_count > 10){
     866                        if (main_btn1_count > 10) {
    859867                                main_btn1_count = 0;
    860868                                main_btn1_state = false;
     
    865873
    866874                /* ボタン2の処理 */
    867                 if((btn == BUTTON_RIGHT) && !main_btn2_state){
     875                if ((btn == BUTTON_RIGHT) && !main_btn2_state) {
    868876                        main_btn2_count++;
    869                         if(main_btn2_count > 10){
     877                        if (main_btn2_count > 10) {
    870878                                main_btn2_count = 0;
    871879                                main_btn2_state = true;
     
    874882                        }
    875883                }
    876                 else if((btn != BUTTON_RIGHT) && main_btn2_state){
     884                else if ((btn != BUTTON_RIGHT) && main_btn2_state) {
    877885                        main_btn2_count++;
    878                         if(main_btn2_count > 10){
     886                        if (main_btn2_count > 10) {
    879887                                main_btn2_count = 0;
    880888                                main_btn2_state = false;
     
    897905static uint8_t main_read_button(analogin_t *obj)
    898906{
    899     float a = analogin_read(obj);
    900 
    901     a *= 5.0;
    902 
    903     //printf("Button read analog = %f\r\n",a);
    904     if (a < 0.2)
    905         return BUTTON_DOWN;
    906     if (a < 1.0)
    907         return BUTTON_RIGHT;
    908     if (a < 1.7)
    909         return BUTTON_SELECT;
    910     if (a < 2.6)
    911         return BUTTON_UP;
    912     if (a < 4.6)
    913         return BUTTON_LEFT;
    914     else
    915         return BUTTON_NONE;
     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;
    916924}
    917925
     
    924932{
    925933        /* 押されて戻った時に処理する */
    926         if(push)
     934        if (push)
    927935                return;
    928936
    929937        /* 表示ポート番号 */
    930         if(!main_rev){
     938        if (!main_rev) {
    931939                main_port_no--;
    932                 if(main_port_no < 1){
     940                if (main_port_no < 1) {
    933941                        main_port_no = 1;
    934942                        main_rev = true;
     
    936944                }
    937945        }
    938         else{
     946        else {
    939947                main_port_no++;
    940                 if(main_port_no > main_ad_count){
     948                if (main_port_no > main_ad_count) {
    941949                        main_port_no = main_ad_count;
    942950                        main_rev = false;
     
    952960{
    953961        /* 押されて戻った時に処理する */
    954         if(push)
     962        if (push)
    955963                return;
    956964
     
    961969
    962970        /* 表示ポート番号 */
    963         if(!main_rev){
     971        if (!main_rev) {
    964972                main_port_no++;
    965                 if(main_port_no > main_ad_count){
     973                if (main_port_no > main_ad_count) {
    966974                        main_port_no = main_ad_count;
    967975                        main_rev = false;
     
    969977                }
    970978        }
    971         else{
     979        else {
    972980                main_port_no--;
    973                 if(main_port_no < 1){
     981                if (main_port_no < 1) {
    974982                        main_port_no = 1;
    975983                        main_rev = true;
     
    988996
    989997        main_port_no++;
    990         if(main_port_no > main_ad_count)
     998        if (main_port_no > main_ad_count)
    991999                main_port_no = 1;
    9921000
  • asp3_tinet_ecnl_arm/trunk/app1_usb_watt_meter/src/main.c

    r359 r364  
    4545#include <sil.h>
    4646#include <setjmp.h>
     47#include <stdlib.h>
    4748#include <string.h>
    4849#include "syssvc/serial.h"
     
    8081
    8182ID ws_api_mailboxid = MAIN_DATAQUEUE;
     83#ifndef NOUSE_MPF_NET_BUF
    8284ID ws_mempoolid = MPF_NET_BUF_256;
     85#endif
    8386
    8487#if defined(IF_ETHER_BTUSB) || defined(IF_ETHER_ENBT)
     
    114117static void main_timeout();
    115118
     119extern int ntshell_exit;
     120
    116121int uart_read(char *buf, int cnt, void *extobj)
    117122{
    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;
    119157}
    120158
     
    122160{
    123161        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);
    139162}
    140163
     
    156179        main_initialize();
    157180
    158         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     181        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    159182        ntshell_set_prompt(&ntshell, "NTShell>");
    160183        ntshell_execute(&ntshell);
     
    176199        ER ret;
    177200
     201#ifdef TOPPERS_OMIT_TECS
     202        serial_opn_por(SIO_PORTID);
     203#endif
     204        serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
     205
    178206        //wolfSSL_Debugging_ON();
    179207
    180         ntshell_task_init();
     208        ntshell_task_init(uart_read, uart_write, &main_obj);
    181209
    182210        main_obj.timer = TMO_FEVR;
     
    313341}
    314342
     343int 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
     355int 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
    315367int cmd_logupload(int argc, char **argv)
    316368{
    317         client_task(0);
    318         return 0;
     369        return client_upload_file(argc, argv);
    319370}
    320371
     
    335386        {"dnsc", "DNS client", usrcmd_dnsc },
    336387        {"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},
    337395        {"logupload", "Upload log to server", cmd_logupload},
    338396        {"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  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app2_light/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <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"/>
    6060                                                        <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"/>
    6262                                                        <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">
    6363                                                                <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"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <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"/>
    165165                                                        <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"/>
    167167                                                        <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">
    168168                                                                <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  
    173173        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    174174endif
    175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     175CDEFS := $(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
    176176INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    177177        -I$(SRCDIR)/../btstack/include \
     
    181181        -I$(SRCDIR)/../usbhost/src \
    182182        $(INCLUDES)
    183 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     183LDFLAGS := $(LDFLAGS) -L.
    184184LIBS := $(LIBS) $(CXXLIBS)
    185185CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    215215endif
    216216
    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
     217ifdef 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
     247endif
    247248
    248249#
     
    277278#  コンフィギュレータに関する定義
    278279#
    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 \
     280ifndef 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)
     284else
     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 \
    281287                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    282288                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    284290                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    285291                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     292endif
    286293CFG_ASMOBJS := $(CFG_ASMOBJS)
    287294CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    429436
    430437#
     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#
    431445#  特別な依存関係の定義
    432446#
     
    437451#
    438452$(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 \
    440454                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    441455                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app2_light/DebugEther/Makefile

    r352 r364  
    171171        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    172172endif
    173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     173CDEFS := $(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
    174174INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    175175        -I$(SRCDIR)/../btstack/include \
     
    179179        -I$(SRCDIR)/../usbhost/src \
    180180        $(INCLUDES)
    181 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     181LDFLAGS := $(LDFLAGS) -L.
    182182LIBS := $(LIBS) $(CXXLIBS)
    183183CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    213213endif
    214214
    215 
    216 #
    217 #  ネットワークサービスの定義
    218 #
    219 NO_USE_TINET_LIBRARY = true
    220 
    221 #  ネットワークインタフェースの選択、何れか一つ選択する。
    222 NET_IF = ether
    223 
    224 #  イーサネット・ディバイスドライバの選択
     215ifdef TINETDIR
     216        #
     217        #  ネットワークサービスの定義
     218        #
     219        NO_USE_TINET_LIBRARY = true
     220
     221        #  ネットワークインタフェースの選択、何れか一つ選択する。
     222        NET_IF = ether
     223
     224        #  イーサネット・ディバイスドライバの選択
    225225        NET_DEV = if_mbed
    226226
    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
     245endif
    245246
    246247#
     
    275276#  コンフィギュレータに関する定義
    276277#
    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 \
     278ifndef 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)
     282else
     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 \
    279285                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    280286                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    282288                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    283289                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     290endif
    284291CFG_ASMOBJS := $(CFG_ASMOBJS)
    285292CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    427434
    428435#
     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#
    429443#  特別な依存関係の定義
    430444#
     
    435449#
    436450$(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 \
    438452                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    439453                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app2_light/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    127127{
    128128        /* サイズが1以外は受け付けない */
    129         if(size != 1)
     129        if (size != 1)
    130130                return 0;
    131131
    132132        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    133133
    134         switch(*(uint8_t *)src){
     134        switch (*(uint8_t *)src) {
    135135        /* ONの場合 */
    136136        case 0x30:
     
    163163{
    164164        /* サイズが1以外は受け付けない */
    165         if(size != 1)
     165        if (size != 1)
    166166                return 0;
    167167
    168168        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    169169
    170         switch(*(uint8_t *)src){
     170        switch (*(uint8_t *)src) {
    171171        /* 異常発生ありの場合 */
    172172        case 0x41:
     
    189189{
    190190        /* サイズが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) {
    195195        /* 自動の場合 */
    196196        case 0x41:
     
    241241        uint8_t data[2];
    242242
    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) {
    247247        /* 人体検出ありの場合 */
    248248        case 0x41:
     
    253253                data[1] = *(uint8_t *)src;
    254254                ret = ecn_brk_wai(data, sizeof(data));
    255                 if(ret != E_OK){
     255                if (ret != E_OK) {
    256256                        syslog(LOG_ERROR, "ecn_brk_wai");
    257257                        return 1;
     
    266266                data[1] = *(uint8_t *)src;
    267267                ret = ecn_brk_wai(data, sizeof(data));
    268                 if(ret != E_OK){
     268                if (ret != E_OK) {
    269269                        syslog(LOG_ERROR, "ecn_brk_wai");
    270270                        return 1;
     
    288288        struct tm _tm;
    289289
    290         if(size != 2)
     290        if (size != 2)
    291291                return 0;
    292292
     
    315315        struct tm _tm;
    316316
    317         if(size != 2)
     317        if (size != 2)
    318318                return 0;
    319319
     
    338338        struct tm _tm;
    339339
    340         if(size != 4)
     340        if (size != 4)
    341341                return 0;
    342342
     
    365365        struct tm _tm;
    366366
    367         if(size != 4)
     367        if (size != 4)
    368368                return 0;
    369369
     
    403403
    404404        ret2 = get_tim(&now);
    405         if (ret2 != E_OK){
     405        if (ret2 != E_OK) {
    406406                syslog(LOG_ERROR, "get_tim");
    407407                return;
    408408        }
    409409
    410         for(;;){
     410        for (;;) {
    411411                prev = now;
    412412
     
    416416                /* 応答電文待ち */
    417417                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)) {
    419419                        syslog(LOG_ERROR, "ecn_trcv_esv");
    420420                        break;
     
    422422
    423423                ret2 = get_tim(&now);
    424                 if (ret2 != E_OK){
     424                if (ret2 != E_OK) {
    425425                        syslog(LOG_ERROR, "get_tim");
    426426                        break;
     
    437437                        /* 領域解放 */
    438438                        ret = ecn_rel_esv(esv);
    439                         if (ret != E_OK){
     439                        if (ret != E_OK) {
    440440                                syslog(LOG_ERROR, "ecn_rel_esv");
    441441                                break;
     
    446446                        /* 応答電文待ちの割り込みデータ取得 */
    447447                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    448                         if (ret != E_OK){
     448                        if (ret != E_OK) {
    449449                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    450450                                break;
     
    456456                        /* 領域解放 */
    457457                        ret = ecn_rel_esv(esv);
    458                         if (ret != E_OK){
     458                        if (ret != E_OK) {
    459459                                syslog(LOG_ERROR, "ecn_rel_esv");
    460460                                break;
     
    467467}
    468468
    469 bool_t started = false;
    470 
    471469void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    472470{
     
    476474                return;
    477475
    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                }
    488482        }
    489483
     
    499493}
    500494
    501 enum main_state_t{
     495enum main_state_t {
     496        main_state_start,
    502497        main_state_idle,
    503498        main_state_search,
     
    506501int main_timer = TMO_FEVR;
    507502int main_btn_timer = TMO_FEVR;
    508 enum main_state_t main_state = main_state_idle;
     503enum main_state_t main_state = main_state_start;
    509504bool_t main_btn1_state;
    510505int main_btn1_count = 0;
     
    535530        gpio_write(&led_red, 0);
    536531
    537         /* 1秒後に人体検知センサを検索 */
    538         main_state = main_state_search;
     532        /* ECHONETミドルウェアを起動するのを待つ */
     533        main_state = main_state_start;
    539534        main_timer = 1000 * 1000;
    540535
     
    548543        main_btn2_state = btn2 != 0;
    549544
     545        /* メインタスクを起動 */
    550546        ER ret = act_tsk(MAIN_TASK);
    551547        if (ret != E_OK) {
     
    561557        int result = main_timer;
    562558
    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))) {
    565561                result = main_btn_timer;
    566562        }
     
    574570static void main_progress(int interval)
    575571{
    576         if(main_timer != TMO_FEVR){
     572        if (main_timer != TMO_FEVR) {
    577573                main_timer -= interval;
    578                 if(main_timer < 0){
     574                if (main_timer < 0) {
    579575                        main_timer = 0;
    580576                }
    581577        }
    582578
    583         if(main_btn_timer != TMO_FEVR){
     579        if (main_btn_timer != TMO_FEVR) {
    584580                main_btn_timer -= interval;
    585                 if(main_btn_timer < 0){
     581                if (main_btn_timer < 0) {
    586582                        main_btn_timer = 0;
    587583                }
     
    602598
    603599        eobjid = ecn_get_eobj(esv);
    604         if(eobjid == EOBJ_NULL){
     600        if (eobjid == EOBJ_NULL) {
    605601                syslog(LOG_ERROR, "ecn_get_eobj");
    606602        }
    607603
    608604        ret = ecn_itr_ini(&enm, esv);
    609         if(ret != E_OK){
     605        if (ret != E_OK) {
    610606                syslog(LOG_ERROR, "ecn_itr_ini");
    611607                return;
    612608        }
    613609
    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) {
    616612                        switch (epc) {
    617613                        case 0xD6:
    618                                 switch(main_state){
     614                                switch (main_state) {
    619615                                case main_state_search:
    620616                                        if (eobjid == HUMAN_DETECTION_SENSER_ENOD) {
     
    628624                        }
    629625                }
    630                 if(ret != E_BOVR){
     626                if (ret != E_BOVR) {
    631627                        syslog(LOG_ERROR, "ecn_itr_nxt");
    632628                        break;
    633629                }
    634                 if(enm.is_eof)
     630                if (enm.is_eof)
    635631                        break;
    636632        }
     
    646642        ER ret;
    647643
    648         switch(main_state){
     644        switch (main_state) {
    649645        case main_state_idle:
    650646                if (len < 2)
     
    670666static void main_timeout()
    671667{
    672         if(main_timer == 0){
     668        if (main_timer == 0) {
    673669                main_ontimer();
    674670        }
    675671
    676         if(main_btn_timer == 0){
     672        if (main_btn_timer == 0) {
    677673                main_btn_ontimer();
    678674        }
     
    683679static void main_ontimer()
    684680{
    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;
    686695        case main_state_search:
    687696                /* 人体検知センサ再検索 */
     
    700709        /* 人体検知センサ検索 */
    701710        ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6);
    702         if(ret != E_OK){
     711        if (ret != E_OK) {
    703712                syslog(LOG_ERROR, "ecn_esv_inf_req");
    704713                return;
     
    707716        /* 電文送信 */
    708717        ret = ecn_snd_esv(esv);
    709         if(ret != E_OK){
     718        if (ret != E_OK) {
    710719                syslog(LOG_ERROR, "ecn_snd_esv");
    711720        }
     
    730739
    731740        /* ボタン1の処理 */
    732         if((btn1 != 0) && !main_btn1_state){
     741        if ((btn1 != 0) && !main_btn1_state) {
    733742                main_btn1_count++;
    734                 if(main_btn1_count > 10){
     743                if (main_btn1_count > 10) {
    735744                        main_btn1_count = 0;
    736745                        main_btn1_state = true;
     
    739748                }
    740749        }
    741         else if((btn1 == 0) && main_btn1_state){
     750        else if ((btn1 == 0) && main_btn1_state) {
    742751                main_btn1_count++;
    743                 if(main_btn1_count > 10){
     752                if (main_btn1_count > 10) {
    744753                        main_btn1_count = 0;
    745754                        main_btn1_state = false;
     
    750759
    751760        /* ボタン2の処理 */
    752         if((btn2 != 0) && !main_btn2_state){
     761        if ((btn2 != 0) && !main_btn2_state) {
    753762                main_btn2_count++;
    754                 if(main_btn2_count > 10){
     763                if (main_btn2_count > 10) {
    755764                        main_btn2_count = 0;
    756765                        main_btn2_state = true;
     
    759768                }
    760769        }
    761         else if((btn2 == 0) && main_btn2_state){
     770        else if ((btn2 == 0) && main_btn2_state) {
    762771                main_btn2_count++;
    763                 if(main_btn2_count > 10){
     772                if (main_btn2_count > 10) {
    764773                        main_btn2_count = 0;
    765774                        main_btn2_state = false;
     
    770779}
    771780
    772 enum lighting_mode_t{
     781enum lighting_mode_t {
    773782        lighting_mode_auto,             /* 自動の場合 */
    774783        lighting_mode_normal,   /* 通常灯の場合 */
     
    789798
    790799        /* 押されて戻った時に処理する */
    791         if(push)
     800        if (push)
    792801                return;
    793802
     
    798807        /* プロパティ設定電文作成 */
    799808        ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0x80, 1, p_edt);
    800         if(ret != E_OK){
     809        if (ret != E_OK) {
    801810                syslog(LOG_ERROR, "ecn_esv_setc");
    802811                return;
     
    817826
    818827        /* 押されて戻った時に処理する */
    819         if(push)
     828        if (push)
    820829                return;
    821830
    822831        /* 点灯モードの切り替え */
    823         switch(main_mode){
     832        switch (main_mode) {
    824833        /* 自動の場合 */
    825834        case lighting_mode_auto:
     
    851860        /* プロパティ設定電文作成 */
    852861        ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0xB6, 1, p_edt);
    853         if(ret != E_OK){
     862        if (ret != E_OK) {
    854863                syslog(LOG_ERROR, "ecn_esv_setc");
    855864                return;
     
    867876
    868877        /* 照明がOFFで人体検出ありの場合 */
    869         if(!main_on && state == 0x41){
     878        if (!main_on && state == 0x41) {
    870879                /* 照明をON */
    871880                main_on = true;
    872881        }
    873882        /* 照明がOFFで人体検出ありの場合 */
    874         else if(main_on && state == 0x42){
     883        else if (main_on && state == 0x42) {
    875884                /* 照明をOFF */
    876885                main_on = false;
     
    883892        /* プロパティ設定電文作成 */
    884893        ret = ecn_esv_setc(&esv, GENERAL_LIGHTING_CLASS_EOBJ, 0x80, 1, p_edt);
    885         if(ret != E_OK){
     894        if (ret != E_OK) {
    886895                syslog(LOG_ERROR, "ecn_esv_setc");
    887896                return;
  • asp3_tinet_ecnl_arm/trunk/app2_light/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app2_light/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <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"/>
    6060                                                        <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"/>
    6262                                                        <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">
    6363                                                                <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"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <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"/>
    165165                                                        <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"/>
    167167                                                        <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">
    168168                                                                <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  
    173173        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    174174endif
    175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     175CDEFS := $(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
    176176INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    177177        -I$(SRCDIR)/../btstack/include \
     
    181181        -I$(SRCDIR)/../usbhost/src \
    182182        $(INCLUDES)
    183 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     183LDFLAGS := $(LDFLAGS) -L.
    184184LIBS := $(LIBS) $(CXXLIBS)
    185185CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    215215endif
    216216
    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
     217ifdef 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
     247endif
    247248
    248249#
     
    277278#  コンフィギュレータに関する定義
    278279#
    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 \
     280ifndef 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)
     284else
     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 \
    281287                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    282288                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    284290                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    285291                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     292endif
    286293CFG_ASMOBJS := $(CFG_ASMOBJS)
    287294CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    429436
    430437#
     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#
    431445#  特別な依存関係の定義
    432446#
     
    437451#
    438452$(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 \
    440454                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    441455                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/DebugEther/Makefile

    r352 r364  
    171171        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    172172endif
    173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     173CDEFS := $(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
    174174INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    175175        -I$(SRCDIR)/../btstack/include \
     
    179179        -I$(SRCDIR)/../usbhost/src \
    180180        $(INCLUDES)
    181 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     181LDFLAGS := $(LDFLAGS) -L.
    182182LIBS := $(LIBS) $(CXXLIBS)
    183183CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    213213endif
    214214
    215 
    216 #
    217 #  ネットワークサービスの定義
    218 #
    219 NO_USE_TINET_LIBRARY = true
    220 
    221 #  ネットワークインタフェースの選択、何れか一つ選択する。
    222 NET_IF = ether
    223 
    224 #  イーサネット・ディバイスドライバの選択
     215ifdef TINETDIR
     216        #
     217        #  ネットワークサービスの定義
     218        #
     219        NO_USE_TINET_LIBRARY = true
     220
     221        #  ネットワークインタフェースの選択、何れか一つ選択する。
     222        NET_IF = ether
     223
     224        #  イーサネット・ディバイスドライバの選択
    225225        NET_DEV = if_mbed
    226226
    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
     245endif
    245246
    246247#
     
    275276#  コンフィギュレータに関する定義
    276277#
    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 \
     278ifndef 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)
     282else
     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 \
    279285                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    280286                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    282288                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    283289                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     290endif
    284291CFG_ASMOBJS := $(CFG_ASMOBJS)
    285292CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    427434
    428435#
     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#
    429443#  特別な依存関係の定義
    430444#
     
    435449#
    436450$(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 \
    438452                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    439453                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    9494{
    9595        /* サイズが1以外は受け付けない */
    96         if(size != 1)
     96        if (size != 1)
    9797                return 0;
    9898
    9999        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    100100
    101         switch(*(uint8_t *)src){
     101        switch (*(uint8_t *)src) {
    102102        /* ONの場合 */
    103103        case 0x30:
     
    126126{
    127127        /* サイズが1以外は受け付けない */
    128         if(size != 1)
     128        if (size != 1)
    129129                return 0;
    130130
    131131        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    132132
    133         switch(*(uint8_t *)src){
     133        switch (*(uint8_t *)src) {
    134134        /* 異常発生ありの場合 */
    135135        case 0x41:
     
    152152{
    153153        /* サイズが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)) {
    158158                *((uint8_t *)item->exinf) = *((uint8_t *)src);
    159159        }
    160160        /* 上記以外は受け付けない */
    161         else{
     161        else {
    162162                return 0;
    163163        }
     
    180180
    181181        /* サイズが1以外は受け付けない */
    182         if(size != 1)
     182        if (size != 1)
    183183                return 0;
    184184
    185185        *anno = false;
    186186
    187         if((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)){
     187        if ((*(uint8_t *)src >= 0x31) && (*(uint8_t *)src <= 0x38)) {
    188188                /* 以前の検知レベルを保存 */
    189189                prev_state = eobj->state;
     
    197197
    198198                /* 人体検知状態に変化があった場合 */
    199                 if((prev_state < eobj->threshold) != (eobj->state < eobj->threshold))
    200                 {
     199                if ((prev_state < eobj->threshold) != (eobj->state < eobj->threshold)) {
    201200                        /* プロパティ通知 */
    202201                        *anno = true;
     
    204203        }
    205204        /* 上記以外は受け付けない */
    206         else{
     205        else {
    207206                return 0;
    208207        }
     
    211210}
    212211
    213 /* 
     212/*
    214213 * 人体検知状態取得関数
    215214 */
     
    219218
    220219        /* 閾値より検知レベルが低い場合 */
    221         if(eobj->state < eobj->threshold){
     220        if (eobj->state < eobj->threshold) {
    222221                /* 人体検知なし */
    223222                ((uint8_t *)dst)[0] = 0x42;
    224223        }
    225224        /* 閾値より検知レベルが高い場合 */
    226         else{
     225        else {
    227226                /* 人体検知あり */
    228227                ((uint8_t *)dst)[0] = 0x41;
     
    255254
    256255        ret2 = get_tim(&now);
    257         if (ret2 != E_OK){
     256        if (ret2 != E_OK) {
    258257                syslog(LOG_ERROR, "get_tim");
    259258                return;
    260259        }
    261260
    262         for(;;){
     261        for (;;) {
    263262                prev = now;
    264263
     
    268267                /* 応答電文待ち */
    269268                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)) {
    271270                        syslog(LOG_ERROR, "ecn_trcv_esv");
    272271                        break;
     
    274273
    275274                ret2 = get_tim(&now);
    276                 if (ret2 != E_OK){
     275                if (ret2 != E_OK) {
    277276                        syslog(LOG_ERROR, "get_tim");
    278277                        break;
     
    289288                        /* 領域解放 */
    290289                        ret = ecn_rel_esv(esv);
    291                         if (ret != E_OK){
     290                        if (ret != E_OK) {
    292291                                syslog(LOG_ERROR, "ecn_rel_esv");
    293292                                break;
     
    298297                        /* 応答電文待ちの割り込みデータ取得 */
    299298                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    300                         if (ret != E_OK){
     299                        if (ret != E_OK) {
    301300                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    302301                                break;
     
    308307                        /* 領域解放 */
    309308                        ret = ecn_rel_esv(esv);
    310                         if (ret != E_OK){
     309                        if (ret != E_OK) {
    311310                                syslog(LOG_ERROR, "ecn_rel_esv");
    312311                                break;
     
    319318}
    320319
    321 bool_t started = false;
    322 
    323320void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    324321{
     
    328325                return;
    329326
    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                }
    340333        }
    341334
     
    351344}
    352345
    353 enum main_state_t{
     346enum main_state_t {
     347        main_state_start,
    354348        main_state_idle,
    355349};
    356350
    357351int main_timer = TMO_FEVR;
    358 enum main_state_t main_state = main_state_idle;
     352enum main_state_t main_state = main_state_start;
    359353bool_t main_btn1_state;
    360354int main_btn1_count = 0;
     
    386380        gpio_write(&led_red, 0);
    387381
    388         /* 10ms後にボタン状態を確認 */
    389         main_timer = 10 * 1000;
     382        /* ECHONETミドルウェアを起動するのを待つ */
     383        main_state = main_state_start;
     384        main_timer = 1000 * 1000;
    390385
    391386        /* アナログ入力の初期化 */
     
    398393        main_btn2_state = btn2 != 0;
    399394
     395        /* メインタスクを起動 */
    400396        ER ret = act_tsk(MAIN_TASK);
    401397        if (ret != E_OK) {
     
    417413static void main_progress(int interval)
    418414{
    419         if(main_timer == TMO_FEVR)
     415        if (main_timer == TMO_FEVR)
    420416                return;
    421417
    422418        main_timer -= interval;
    423         if(main_timer < 0){
     419        if (main_timer < 0) {
    424420                main_timer = 0;
    425421        }
     
    438434
    439435        ret = ecn_itr_ini(&enm, esv);
    440         if(ret != E_OK){
     436        if (ret != E_OK) {
    441437                syslog(LOG_ERROR, "ecn_itr_ini");
    442438                return;
    443439        }
    444440
    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) {
    447443                        switch (epc) {
    448444                        case 0x80:
     
    452448                        }
    453449                }
    454                 if(ret != E_BOVR){
     450                if (ret != E_BOVR) {
    455451                        syslog(LOG_ERROR, "ecn_itr_nxt");
    456452                        break;
    457453                }
    458                 if(enm.is_eof)
     454                if (enm.is_eof)
    459455                        break;
    460456        }
     
    466462static void main_break_wait(uint8_t *brkdat, int32_t len)
    467463{
    468         switch(main_state){
     464        switch (main_state) {
    469465        case main_state_idle:
    470466                break;
     
    488484static void main_timeout()
    489485{
     486        ER ret;
    490487        uint8_t btn1, btn2;
    491488        uint16_t ad_value;
    492489        uint8_t ad_level;
    493490
    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;
    498506        case main_state_idle:
    499507                /* 10ms後にボタン状態を確認 */
     
    507515
    508516                main_ad_pos++;
    509                 if(main_ad_pos >= main_ad_table_count){
     517                if (main_ad_pos >= main_ad_table_count) {
    510518                        main_ad_pos = 0;
    511519                }
    512520
    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) {
    515523                        /* 1秒変化が続いたら */
    516                         if(main_count < 100){
     524                        if (main_count < 100) {
    517525                                main_count++;
    518526                        }
    519                         else{
     527                        else {
    520528                                main_ad_level = ad_level;
    521529
     
    524532                        }
    525533                }
    526                 else{
     534                else {
    527535                        main_count = 0;
    528536                }
     
    533541
    534542                /* ボタン1の処理 */
    535                 if((btn1 != 0) && !main_btn1_state){
     543                if ((btn1 != 0) && !main_btn1_state) {
    536544                        main_btn1_count++;
    537                         if(main_btn1_count > 10){
     545                        if (main_btn1_count > 10) {
    538546                                main_btn1_count = 0;
    539547                                main_btn1_state = true;
     
    542550                        }
    543551                }
    544                 else if((btn1 == 0) && main_btn1_state){
     552                else if ((btn1 == 0) && main_btn1_state) {
    545553                        main_btn1_count++;
    546                         if(main_btn1_count > 10){
     554                        if (main_btn1_count > 10) {
    547555                                main_btn1_count = 0;
    548556                                main_btn1_state = false;
     
    553561
    554562                /* ボタン2の処理 */
    555                 if((btn2 != 0) && !main_btn2_state){
     563                if ((btn2 != 0) && !main_btn2_state) {
    556564                        main_btn2_count++;
    557                         if(main_btn2_count > 10){
     565                        if (main_btn2_count > 10) {
    558566                                main_btn2_count = 0;
    559567                                main_btn2_state = true;
     
    562570                        }
    563571                }
    564                 else if((btn2 == 0) && main_btn2_state){
     572                else if ((btn2 == 0) && main_btn2_state) {
    565573                        main_btn2_count++;
    566                         if(main_btn2_count > 10){
     574                        if (main_btn2_count > 10) {
    567575                                main_btn2_count = 0;
    568576                                main_btn2_state = false;
     
    588596        /* プロパティ設定電文作成 */
    589597        ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt);
    590         if(ret != E_OK){
     598        if (ret != E_OK) {
    591599                syslog(LOG_ERROR, "ecn_esv_setc");
    592600                return;
     
    610618
    611619        /* 押されて戻った時に処理する */
    612         if(push)
     620        if (push)
    613621                return;
    614622
    615623        /* 人体検知状態 */
    616         if(!main_rev){
     624        if (!main_rev) {
    617625                main_level--;
    618                 if(main_level < 1){
     626                if (main_level < 1) {
    619627                        main_level = 1;
    620628                        main_rev = true;
    621629                }
    622630        }
    623         else{
     631        else {
    624632                main_level++;
    625                 if(main_level > 8){
     633                if (main_level > 8) {
    626634                        main_level = 8;
    627635                        main_rev = false;
     
    633641        /* プロパティ設定電文作成 */
    634642        ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt);
    635         if(ret != E_OK){
     643        if (ret != E_OK) {
    636644                syslog(LOG_ERROR, "ecn_esv_setc");
    637645                return;
     
    652660
    653661        /* 押されて戻った時に処理する */
    654         if(push)
     662        if (push)
    655663                return;
    656664
    657665        /* 人体検知状態 */
    658         if(!main_rev){
     666        if (!main_rev) {
    659667                main_level++;
    660                 if(main_level > 8){
     668                if (main_level > 8) {
    661669                        main_level = 8;
    662670                        main_rev = false;
    663671                }
    664672        }
    665         else{
     673        else {
    666674                main_level--;
    667                 if(main_level < 1){
     675                if (main_level < 1) {
    668676                        main_level = 1;
    669677                        main_rev = true;
     
    675683        /* プロパティ設定電文作成 */
    676684        ret = ecn_esv_setc(&esv, HUMAN_DETECTION_SENSOR_EOBJ, 0xB1, 1, p_edt);
    677         if(ret != E_OK){
     685        if (ret != E_OK) {
    678686                syslog(LOG_ERROR, "ecn_esv_setc");
    679687                return;
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app3_human_detec/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <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"/>
    6060                                                        <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"/>
    6262                                                        <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">
    6363                                                                <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"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <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"/>
    165165                                                        <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"/>
    167167                                                        <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">
    168168                                                                <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  
    179179        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    180180endif
    181 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     181CDEFS := $(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
    182182INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    183183        -I$(SRCDIR)/../btstack/include \
     
    187187        -I$(SRCDIR)/../usbhost/src \
    188188        $(INCLUDES)
    189 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     189LDFLAGS := $(LDFLAGS) -L.
    190190LIBS := $(LIBS) $(CXXLIBS)
    191191CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    198198APPL_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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     201APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    201202
    202203#
     
    223224endif
    224225
    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
     226ifdef 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
     256endif
    255257
    256258#
     
    285287#  コンフィギュレータに関する定義
    286288#
    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 \
     289ifndef 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)
     293else
     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 \
    289296                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    290297                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    292299                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    293300                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     301endif
    294302CFG_ASMOBJS := $(CFG_ASMOBJS)
    295303CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    437445
    438446#
     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#
    439454#  特別な依存関係の定義
    440455#
     
    445460#
    446461$(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 \
    448463                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    449464                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/DebugEther/Makefile

    r352 r364  
    177177        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    178178endif
    179 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     179CDEFS := $(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
    180180INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    181181        -I$(SRCDIR)/../btstack/include \
     
    185185        -I$(SRCDIR)/../usbhost/src \
    186186        $(INCLUDES)
    187 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     187LDFLAGS := $(LDFLAGS) -L.
    188188LIBS := $(LIBS) $(CXXLIBS)
    189189CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    196196APPL_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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     199APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    199200
    200201#
     
    221222endif
    222223
    223 
    224 #
    225 #  ネットワークサービスの定義
    226 #
    227 NO_USE_TINET_LIBRARY = true
    228 
    229 #  ネットワークインタフェースの選択、何れか一つ選択する。
    230 NET_IF = ether
    231 
    232 #  イーサネット・ディバイスドライバの選択
     224ifdef TINETDIR
     225        #
     226        #  ネットワークサービスの定義
     227        #
     228        NO_USE_TINET_LIBRARY = true
     229
     230        #  ネットワークインタフェースの選択、何れか一つ選択する。
     231        NET_IF = ether
     232
     233        #  イーサネット・ディバイスドライバの選択
    233234        NET_DEV = if_mbed
    234235
    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
     254endif
    253255
    254256#
     
    283285#  コンフィギュレータに関する定義
    284286#
    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 \
     287ifndef 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)
     291else
     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 \
    287294                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    288295                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    290297                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    291298                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     299endif
    292300CFG_ASMOBJS := $(CFG_ASMOBJS)
    293301CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    435443
    436444#
     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#
    437452#  特別な依存関係の定義
    438453#
     
    443458#
    444459$(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 \
    446461                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    447462                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    5555#include "adafruit_st7735.h"
    5656#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
     64extern uint8_t mac_addr[6];
    5765
    5866/* TODO: メーカーコードを設定 */
     
    184192
    185193        /* サイズが1以外は受け付けない */
    186         if(size != 1)
     194        if (size != 1)
    187195                return 0;
    188196
    189197        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    190198
    191         switch(*(uint8_t *)src){
     199        switch (*(uint8_t *)src) {
    192200        /* ONの場合 */
    193201        case 0x30:
     
    198206                data[0] = 0x80;
    199207                ret = ecn_brk_wai(data, sizeof(data));
    200                 if(ret != E_OK){
     208                if (ret != E_OK) {
    201209                        syslog(LOG_ERROR, "ecn_brk_wai");
    202210                        return 2;
     
    217225{
    218226        /* サイズが1以外は受け付けない */
    219         if(size != 1)
     227        if (size != 1)
    220228                return 0;
    221229
    222230        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    223231
    224         switch(*(uint8_t *)src){
     232        switch (*(uint8_t *)src) {
    225233        /* 異常発生ありの場合 */
    226234        case 0x41:
     
    246254
    247255        /* サイズが1以外は受け付けない */
    248         if(size != 1)
     256        if (size != 1)
    249257                return 0;
    250258
    251         switch(*(uint8_t *)src){
     259        switch (*(uint8_t *)src) {
    252260        /* 自動の場合 */
    253261        case 0x41:
     
    266274                data[0] = 0xB0;
    267275                ret = ecn_brk_wai(data, sizeof(data));
    268                 if(ret != E_OK){
     276                if (ret != E_OK) {
    269277                        syslog(LOG_ERROR, "ecn_brk_wai");
    270278                        return 2;
     
    288296
    289297        /* サイズが1以外は受け付けない */
    290         if(size != 1)
     298        if (size != 1)
    291299                return 0;
    292300
    293301        /* 0℃~50℃ */
    294         if((*(uint8_t *)src >= 0x00) && (*(uint8_t *)src <= 0x32)){
     302        if ((*(uint8_t *)src >= 0x00) && (*(uint8_t *)src <= 0x32)) {
    295303                *((uint8_t *)item->exinf) = *((uint8_t *)src);
    296304                /* メインタスクに通知 */
    297305                data[0] = 0xB3;
    298306                ret = ecn_brk_wai(data, sizeof(data));
    299                 if(ret != E_OK){
     307                if (ret != E_OK) {
    300308                        syslog(LOG_ERROR, "ecn_brk_wai");
    301309                        return 2;
     
    303311        }
    304312        /* 上記以外は受け付けない */
    305         else{
     313        else {
    306314                return 0;
    307315        }
     
    333341
    334342        ret2 = get_tim(&now);
    335         if (ret2 != E_OK){
     343        if (ret2 != E_OK) {
    336344                syslog(LOG_ERROR, "get_tim");
    337345                return;
    338346        }
    339347
    340         for(;;){
     348        for (;;) {
    341349                prev = now;
    342350
     
    346354                /* 応答電文待ち */
    347355                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)) {
    349357                        syslog(LOG_ERROR, "ecn_trcv_esv");
    350358                        break;
     
    352360
    353361                ret2 = get_tim(&now);
    354                 if (ret2 != E_OK){
     362                if (ret2 != E_OK) {
    355363                        syslog(LOG_ERROR, "get_tim");
    356364                        break;
     
    367375                        /* 領域解放 */
    368376                        ret = ecn_rel_esv(esv);
    369                         if (ret != E_OK){
     377                        if (ret != E_OK) {
    370378                                syslog(LOG_ERROR, "ecn_rel_esv");
    371379                                break;
     
    376384                        /* 応答電文待ちの割り込みデータ取得 */
    377385                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    378                         if (ret != E_OK){
     386                        if (ret != E_OK) {
    379387                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    380388                                break;
     
    386394                        /* 領域解放 */
    387395                        ret = ecn_rel_esv(esv);
    388                         if (ret != E_OK){
     396                        if (ret != E_OK) {
    389397                                syslog(LOG_ERROR, "ecn_rel_esv");
    390398                                break;
     
    397405}
    398406
    399 bool_t started = false;
    400 
    401407void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    402408{
     
    406412                return;
    407413
    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                }
    418420        }
    419421
     
    421423        uint8_t data[2];
    422424        data[0] = 0x01;
    423         data[1] = up ? 0x01 : 0x02;
     425        data[1] = (up ? 0x01 : 0x02) | (link_up ? 0x10 : 0x20);
    424426        ret = ecn_brk_wai(data, sizeof(data));
    425427        if (ret != E_OK) {
     
    429431}
    430432
    431 enum main_state_t{
     433enum main_state_t {
     434        main_state_start,
    432435        main_state_idle,
    433436        main_state_search,
     
    440443
    441444int main_timer = TMO_FEVR;
    442 enum main_state_t main_state = main_state_idle;
     445enum main_state_t main_state = main_state_start;
    443446int16_t main_ave_templ;
    444447bool_t main_tmp_fan_on;
     
    470473LCD_DrawProp_t drawProp;
    471474
    472 enum main_rly_state_t{
     475enum main_rly_state_t {
    473476        main_rly_state_off,
    474477        main_rly_state_on
     
    486489        uint8_t btn;
    487490
    488         /* 1秒後に温度センサーを探す */
     491        /* ECHONETミドルウェアを起動するのを待つ */
     492        main_state = main_state_start;
    489493        main_timer = 1000 * 1000;
    490494
     
    505509        spi_init(&lcd.hspi, P10_14, P10_15, P10_12, NC);
    506510        spi_format(&lcd.hspi, 8, 0, 0);
    507         spi_frequency(&lcd.hspi, 1000000);
     511        spi_frequency(&lcd.hspi, 4000000);
    508512
    509513        gpio_init_out(&lcd.cs_pin, P10_13);
     
    524528        main_lcd_timer = 1000 * 1000;
    525529
     530        /* メインタスクを起動 */
    526531        ER ret = act_tsk(MAIN_TASK);
    527532        if (ret != E_OK) {
     
    537542        int result = main_timer;
    538543
    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))) {
    541546                result = main_btn_timer;
    542547        }
    543548
    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))) {
    546551                result = main_lcd_timer;
    547552        }
    548553
    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))) {
    551556                result = main_rly_timer;
    552557        }
     
    560565static void main_progress(int interval)
    561566{
    562         if(main_timer != TMO_FEVR){
     567        if (main_timer != TMO_FEVR) {
    563568                main_timer -= interval;
    564                 if(main_timer < 0){
     569                if (main_timer < 0) {
    565570                        main_timer = 0;
    566571                }
    567572        }
    568573
    569         if(main_btn_timer != TMO_FEVR){
     574        if (main_btn_timer != TMO_FEVR) {
    570575                main_btn_timer -= interval;
    571                 if(main_btn_timer < 0){
     576                if (main_btn_timer < 0) {
    572577                        main_btn_timer = 0;
    573578                }
    574579        }
    575580
    576         if(main_lcd_timer != TMO_FEVR){
     581        if (main_lcd_timer != TMO_FEVR) {
    577582                main_lcd_timer -= interval;
    578                 if(main_lcd_timer < 0){
     583                if (main_lcd_timer < 0) {
    579584                        main_lcd_timer = 0;
    580585                }
    581586        }
    582587
    583         if(main_rly_timer != TMO_FEVR){
     588        if (main_rly_timer != TMO_FEVR) {
    584589                main_rly_timer -= interval;
    585                 if(main_rly_timer < 0){
     590                if (main_rly_timer < 0) {
    586591                        main_rly_timer = 0;
    587592                }
     
    605610
    606611        eobjid = ecn_get_eobj(esv);
    607         if(eobjid == EOBJ_NULL){
     612        if (eobjid == EOBJ_NULL) {
    608613                syslog(LOG_ERROR, "ecn_get_eobj");
    609614        }
    610615
    611616        ret = ecn_itr_ini(&enm, esv);
    612         if(ret != E_OK){
     617        if (ret != E_OK) {
    613618                syslog(LOG_ERROR, "ecn_itr_ini");
    614619                return;
    615620        }
    616621
    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) {
    619624                        switch (epc) {
    620625                        case 0xD6:
    621                                 switch(main_state){
     626                                switch (main_state) {
    622627                                case main_state_idle:
    623628                                case main_state_search:
     
    630635                                break;
    631636                        case 0xE0:
    632                                 switch(main_state){
     637                                switch (main_state) {
    633638                                case main_state_survey_01:
    634639                                        /* 温度センサー2温度監視 */
     
    660665                        }
    661666                }
    662                 if(ret != E_BOVR){
     667                if (ret != E_BOVR) {
    663668                        syslog(LOG_ERROR, "ecn_itr_nxt");
    664669                        break;
    665670                }
    666                 if(enm.is_eof)
     671                if (enm.is_eof)
    667672                        break;
    668673        }
     
    685690        /* 温度センサー動作状態取得電文作成 */
    686691        ret = ecn_esv_get(&esv, senserids[no - 1], 0x80);
    687         if(ret != E_OK){
     692        if (ret != E_OK) {
    688693                syslog(LOG_ERROR, "ecn_esv_get");
    689694                return;
     
    692697        /* 温度計測値取得追加 */
    693698        ret = ecn_add_epc(esv, 0xE0);
    694         if(ret != E_OK){
     699        if (ret != E_OK) {
    695700                syslog(LOG_ERROR, "ecn_add_epc");
    696701
    697702                ret = ecn_rel_esv(esv);
    698                 if(ret != E_OK){
     703                if (ret != E_OK) {
    699704                        syslog(LOG_ERROR, "ecn_rel_esv");
    700705                }
     
    704709        /* 電文送信 */
    705710        ret = ecn_snd_esv(esv);
    706         if(ret != E_OK){
     711        if (ret != E_OK) {
    707712                syslog(LOG_ERROR, "ecn_snd_esv");
    708713        }
     
    717722        int templ = 0;
    718723
    719         if(temp_sensor_01_data.property80 == 0x30){
     724        if (temp_sensor_01_data.property80 == 0x30) {
    720725                templ += ((((uint16_t)temp_sensor_01_data.propertyE0) & 0xFF) << 8)
    721726                        | ((((uint16_t)temp_sensor_01_data.propertyE0) & 0xFF00) >> 8);
    722727                count++;
    723728        }
    724         if(temp_sensor_02_data.property80 == 0x30){
     729        if (temp_sensor_02_data.property80 == 0x30) {
    725730                templ += ((((uint16_t)temp_sensor_02_data.propertyE0) & 0xFF) << 8)
    726731                        | ((((uint16_t)temp_sensor_02_data.propertyE0) & 0xFF00) >> 8);
    727732                count++;
    728733        }
    729         if(temp_sensor_03_data.property80 == 0x30){
     734        if (temp_sensor_03_data.property80 == 0x30) {
    730735                templ += ((((uint16_t)temp_sensor_03_data.propertyE0) & 0xFF) << 8)
    731736                        | ((((uint16_t)temp_sensor_03_data.propertyE0) & 0xFF00) >> 8);
    732737                count++;
    733738        }
    734         if(temp_sensor_04_data.property80 == 0x30){
     739        if (temp_sensor_04_data.property80 == 0x30) {
    735740                templ += ((((uint16_t)temp_sensor_04_data.propertyE0) & 0xFF) << 8)
    736741                        | ((((uint16_t)temp_sensor_04_data.propertyE0) & 0xFF00) >> 8);
     
    738743        }
    739744
    740         if(count > 0){
     745        if (count > 0) {
    741746                templ = templ / count;
    742                 if(templ < -2732)
     747                if (templ < -2732)
    743748                        main_ave_templ = 0x8000;
    744                 else if(templ > 32766)
     749                else if (templ > 32766)
    745750                        main_ave_templ = 0x7FFF;
    746751                else
     
    748753
    749754                /* 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)) {
    752757                                main_tmp_fan_on = true;
    753758
     
    758763                }
    759764                /* 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)) {
    762767                                main_tmp_fan_on = false;
    763768
     
    777782static void main_break_wait(uint8_t *brkdat, int32_t len)
    778783{
     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
    779790        switch (brkdat[0]) {
    780791        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);
    782807                break;
    783808        }
    784809
    785810        /* 運転モードが送風の場合、温度によらず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;
    788820                main_ctl_fan_on = home_air_conditioner_data.propertyB0 == 0x45;
    789821
    790822                if (prev != main_ctl_fan_on) {
    791823                        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);
    795826                        }
    796827                        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);
    800830                        }
    801831                }
     
    813843static void main_timeout()
    814844{
    815         if(main_timer == 0){
     845        if (main_timer == 0) {
    816846                main_ontimer();
    817847        }
    818848
    819         if(main_btn_timer == 0){
     849        if (main_btn_timer == 0) {
    820850                main_btn_ontimer();
    821851        }
    822852
    823         if(main_lcd_timer == 0){
     853        if (main_lcd_timer == 0) {
    824854                main_lcd_ontimer();
    825855        }
    826856
    827         if(main_rly_timer == 0){
     857        if (main_rly_timer == 0) {
    828858                main_rly_ontimer();
    829859        }
     
    834864static void main_ontimer()
    835865{
    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;
    837880        case main_state_idle:
    838881        case main_state_search:
     
    891934        /* 温度センサー検索 */
    892935        ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6);
    893         if(ret != E_OK){
     936        if (ret != E_OK) {
    894937                syslog(LOG_ERROR, "ecn_esv_inf_req");
    895938                return;
     
    898941        /* 電文送信 */
    899942        ret = ecn_snd_esv(esv);
    900         if(ret != E_OK){
     943        if (ret != E_OK) {
    901944                syslog(LOG_ERROR, "ecn_snd_esv");
    902945        }
     
    919962        if ((btn == BUTTON_LEFT) && !main_btn1_state) {
    920963                main_btn1_count++;
    921                 if(main_btn1_count > 10){
     964                if (main_btn1_count > 10) {
    922965                        main_btn1_count = 0;
    923966                        main_btn1_state = true;
     
    928971        else if ((btn != BUTTON_LEFT) && main_btn1_state) {
    929972                main_btn1_count++;
    930                 if(main_btn1_count > 10){
     973                if (main_btn1_count > 10) {
    931974                        main_btn1_count = 0;
    932975                        main_btn1_state = false;
     
    939982        if ((btn == BUTTON_RIGHT) && !main_btn2_state) {
    940983                main_btn2_count++;
    941                 if(main_btn2_count > 10){
     984                if (main_btn2_count > 10) {
    942985                        main_btn2_count = 0;
    943986                        main_btn2_state = true;
     
    948991        else if ((btn != BUTTON_RIGHT) && main_btn2_state) {
    949992                main_btn2_count++;
    950                 if(main_btn2_count > 10){
     993                if (main_btn2_count > 10) {
    951994                        main_btn2_count = 0;
    952995                        main_btn2_state = false;
     
    9631006        char temp2[] = "測定温度:+00.0℃";
    9641007        char mode[] = "運転モード:自動  ";
    965         char *mode_texts[] = { "自動  ", "冷房  ", "暖房  ", "除湿  ", "送風  ", "その他" };
     1008        char *mode_texts[] = { "その他", "自動  ", "冷房  ", "暖房  ", "除湿  ", "送風  " };
    9661009        char *btn_texts[] = { "none  ", "down  ", "left  ", "select", "up    ", "right " };
    9671010        int temp, btn;
     
    9791022                        power[11] = 'f';
    9801023                }
    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);
    9821025                main_lcd_state++;
    9831026                break;
     
    9921035                        temp = -temp;
    9931036                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);
    9951038                main_lcd_state++;
    9961039                break;
     
    10091052                        temp = -temp;
    10101053                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);
    10121055                main_lcd_state++;
    10131056                break;
    10141057        case 3:
    10151058                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);
    10171060                main_lcd_state++;
    10181061                break;
     
    10231066        case 6:
    10241067                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);
    10261069                main_lcd_state++;
    10271070                break;
     
    10301073                break;
    10311074        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);
    10371080                main_lcd_state = 0;
    10381081                break;
     
    10791122
    10801123        /* 押されて戻った時に処理する */
    1081         if(push)
     1124        if (push)
    10821125                return;
    10831126
    10841127        /* 設定温度 */
    1085         if(main_templ > 0)
     1128        if (main_templ > 0)
    10861129                main_templ--;   /* - 1℃ */
    10871130
     
    10901133        /* プロパティ設定電文作成 */
    10911134        ret = ecn_esv_seti(&esv, HOME_AIR_CONDITIONER_EOBJ, 0xB3, 1, p_edt);
    1092         if(ret != E_OK){
     1135        if (ret != E_OK) {
    10931136                syslog(LOG_ERROR, "ecn_esv_seti");
    10941137                return;
     
    10961139
    10971140        /* 電文送信 */
    1098         ecn_snd_esv(esv);
    1099         if(ret != E_OK){
     1141        ret = ecn_snd_esv(esv);
     1142        if (ret != E_OK) {
    11001143                syslog(LOG_ERROR, "ecn_snd_esv");
    11011144        }
     
    11121155
    11131156        /* 押されて戻った時に処理する */
    1114         if(push)
     1157        if (push)
    11151158                return;
    11161159
    11171160        /* 設定温度 */
    1118         if(main_templ < 50)
     1161        if (main_templ < 50)
    11191162                main_templ++;   /* + 1.0℃ */
    11201163
     
    11231166        /* プロパティ設定電文作成 */
    11241167        ret = ecn_esv_seti(&esv, HOME_AIR_CONDITIONER_EOBJ, 0xB3, 1, p_edt);
    1125         if(ret != E_OK){
     1168        if (ret != E_OK) {
    11261169                syslog(LOG_ERROR, "ecn_esv_seti");
    11271170                return;
     
    11291172
    11301173        /* 電文送信 */
    1131         ecn_snd_esv(esv);
    1132         if(ret != E_OK){
     1174        ret = ecn_snd_esv(esv);
     1175        if (ret != E_OK) {
    11331176                syslog(LOG_ERROR, "ecn_snd_esv");
    11341177        }
     
    11371180static void main_rly_onoff(bool_t onoff)
    11381181{
    1139         if(onoff){
     1182        if (onoff) {
    11401183                /* リレー出力をON */
    11411184                gpio_write(&relay_sw, 1);
    11421185        }
    1143         else{
     1186        else {
    11441187                /* リレー出力をOFF */
    11451188                gpio_write(&relay_sw, 0);
     
    11591202        /* 500msパルス出力 */
    11601203        main_rly_state = main_rly_state_on;
    1161         main_rly_timer = 500;
     1204        main_rly_timer = 500 * 1000;
    11621205}
    11631206
     
    11671210static void main_rly_ontimer()
    11681211{
    1169         switch(main_rly_state)
    1170         {
     1212        switch (main_rly_state) {
    11711213        case main_rly_state_off:
    11721214                main_rly_timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app4_aircon/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.1852970779" 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"/>
    6060                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.852559143" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    61                                                         <builder buildPath="${workspace_loc:/app5_temp_sensor}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.394642308" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     61                                                        <builder buildPath="${workspace_loc:/app5_temp_sensor}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.394642308" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    6262                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.589273516" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    6363                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.462582981" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.512694190" 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"/>
    165165                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1203540506" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    166                                                         <builder buildPath="${workspace_loc:/app5_temp_sensor}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.730173267" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     166                                                        <builder buildPath="${workspace_loc:/app5_temp_sensor}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.730173267" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    167167                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1443620921" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    168168                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1975708208" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/Debug/Makefile

    r352 r364  
    179179        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    180180endif
    181 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     181CDEFS := $(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
    182182INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    183183        -I$(SRCDIR)/../btstack/include \
     
    187187        -I$(SRCDIR)/../usbhost/src \
    188188        $(INCLUDES)
    189 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     189LDFLAGS := $(LDFLAGS) -L.
    190190LIBS := $(LIBS) $(CXXLIBS)
    191191CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    198198APPL_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
    199199APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    200 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     200APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     201APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    201202
    202203#
     
    223224endif
    224225
    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
     226ifdef 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
     256endif
    255257
    256258#
     
    285287#  コンフィギュレータに関する定義
    286288#
    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 \
     289ifndef 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)
     293else
     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 \
    289296                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    290297                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    292299                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    293300                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     301endif
    294302CFG_ASMOBJS := $(CFG_ASMOBJS)
    295303CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    437445
    438446#
     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#
    439454#  特別な依存関係の定義
    440455#
     
    445460#
    446461$(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 \
    448463                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    449464                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/DebugEther/Makefile

    r352 r364  
    177177        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    178178endif
    179 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     179CDEFS := $(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
    180180INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    181181        -I$(SRCDIR)/../btstack/include \
     
    185185        -I$(SRCDIR)/../usbhost/src \
    186186        $(INCLUDES)
    187 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     187LDFLAGS := $(LDFLAGS) -L.
    188188LIBS := $(LIBS) $(CXXLIBS)
    189189CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    196196APPL_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
    197197APPLDIRS := $(APPLDIRS) ../../ntshell/lcd
    198 APPL_COBJS := $(APPL_COBJS) draw_font.o misaki_font.o
     198APPL_COBJS := $(APPL_COBJS) draw_font.o shnm12_font.o
     199APPL_CFLAGS := $(APPL_CFLAGS) -DSHNM12_FONT
    199200
    200201#
     
    221222endif
    222223
    223 
    224 #
    225 #  ネットワークサービスの定義
    226 #
    227 NO_USE_TINET_LIBRARY = true
    228 
    229 #  ネットワークインタフェースの選択、何れか一つ選択する。
    230 NET_IF = ether
    231 
    232 #  イーサネット・ディバイスドライバの選択
     224ifdef TINETDIR
     225        #
     226        #  ネットワークサービスの定義
     227        #
     228        NO_USE_TINET_LIBRARY = true
     229
     230        #  ネットワークインタフェースの選択、何れか一つ選択する。
     231        NET_IF = ether
     232
     233        #  イーサネット・ディバイスドライバの選択
    233234        NET_DEV = if_mbed
    234235
    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
     254endif
    253255
    254256#
     
    283285#  コンフィギュレータに関する定義
    284286#
    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 \
     287ifndef 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)
     291else
     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 \
    287294                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    288295                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    290297                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    291298                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     299endif
    292300CFG_ASMOBJS := $(CFG_ASMOBJS)
    293301CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    435443
    436444#
     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#
    437452#  特別な依存関係の定義
    438453#
     
    443458#
    444459$(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 \
    446461                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    447462                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    5555#include "adafruit_st7735.h"
    5656#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
     64extern uint8_t mac_addr[6];
    5765
    5866/* TODO: メーカーコードを設定 */
     
    111119
    112120        /* サイズが1以外は受け付けない */
    113         if(size != 1)
     121        if (size != 1)
    114122                return 0;
    115123
    116124        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    117125
    118         switch(*(uint8_t *)src){
     126        switch (*(uint8_t *)src) {
    119127        /* ONの場合 */
    120128        case 0x30:
     
    126134                data[1] = *(uint8_t *)src;
    127135                ret = ecn_brk_wai(data, sizeof(data));
    128                 if(ret != E_OK){
     136                if (ret != E_OK) {
    129137                        syslog(LOG_ERROR, "ecn_brk_wai");
    130138                        return 1;
     
    145153{
    146154        /* サイズが1以外は受け付けない */
    147         if(size != 1)
     155        if (size != 1)
    148156                return 0;
    149157
    150158        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    151159
    152         switch(*(uint8_t *)src){
     160        switch (*(uint8_t *)src) {
    153161        /* 異常発生ありの場合 */
    154162        case 0x41:
     
    176184
    177185        /* サイズが2以外は受け付けない */
    178         if(size != 2)
     186        if (size != 2)
    179187                return 0;
    180188
    181189        value = (((uint8_t *)src)[0] << 8) | (((uint8_t *)src)[1] & 0xFF);
    182190
    183         if((value >= -2732) && (value <= 32766)){
     191        if ((value >= -2732) && (value <= 32766)) {
    184192                eobj->propertyE0 = value;
    185193                /* メインタスクに通知 */
    186194                data[0] = 0xE0;
    187195                ret = ecn_brk_wai(data, sizeof(data));
    188                 if(ret != E_OK){
     196                if (ret != E_OK) {
    189197                        syslog(LOG_ERROR, "ecn_brk_wai");
    190198                        return 2;
     
    192200        }
    193201        /* 上記以外は受け付けない */
    194         else{
     202        else {
    195203                return 0;
    196204        }
     
    199207}
    200208
    201 /* 
     209/*
    202210 * 温度計測値取得関数
    203211 */
     
    208216
    209217        /* サイズが2以外は受け付けない */
    210         if(size != 2)
     218        if (size != 2)
    211219                return 0;
    212220
     
    240248
    241249        ret2 = get_tim(&now);
    242         if (ret2 != E_OK){
     250        if (ret2 != E_OK) {
    243251                syslog(LOG_ERROR, "get_tim");
    244252                return;
    245253        }
    246254
    247         for(;;){
     255        for (;;) {
    248256                prev = now;
    249257
     
    253261                /* 応答電文待ち */
    254262                ret = ecn_trcv_esv(&esv, timer);
    255                 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)){
     263                if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {
    256264                        syslog(LOG_ERROR, "ecn_trcv_esv");
    257265                        break;
     
    259267
    260268                ret2 = get_tim(&now);
    261                 if (ret2 != E_OK){
     269                if (ret2 != E_OK) {
    262270                        syslog(LOG_ERROR, "get_tim");
    263271                        break;
     
    274282                        /* 領域解放 */
    275283                        ret = ecn_rel_esv(esv);
    276                         if (ret != E_OK){
     284                        if (ret != E_OK) {
    277285                                syslog(LOG_ERROR, "ecn_rel_esv");
    278286                                break;
     
    283291                        /* 応答電文待ちの割り込みデータ取得 */
    284292                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    285                         if (ret != E_OK){
     293                        if (ret != E_OK) {
    286294                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    287295                                break;
     
    293301                        /* 領域解放 */
    294302                        ret = ecn_rel_esv(esv);
    295                         if (ret != E_OK){
     303                        if (ret != E_OK) {
    296304                                syslog(LOG_ERROR, "ecn_rel_esv");
    297305                                break;
     
    304312}
    305313
    306 bool_t started = false;
    307 
    308314void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    309315{
     
    313319                return;
    314320
    315         if (up && !started) {
    316                 started = true;
    317 
    318                 /* ECHONETミドルウェアを起動 */
    319                 ret = ecn_sta_svc();
    320                 if (ret != E_OK)
    321                         return;
    322 
    323                 /* ECHONETミドルウェアを起動するのを待つ */
    324                 dly_tsk(100);
     321        if (up) {
     322                /* インスタンスリスト通知の送信 */
     323                ret = ecn_ntf_inl();
     324                if (ret != E_OK) {
     325                        syslog(LOG_ERROR, "ecn_ntf_inl");
     326                }
    325327        }
    326328
     
    328330        uint8_t data[2];
    329331        data[0] = 0x01;
    330         data[1] = up ? 0x01 : 0x02;
     332        data[1] = (up ? 0x01 : 0x02) | (link_up ? 0x10 : 0x20);
    331333        ret = ecn_brk_wai(data, sizeof(data));
    332334        if (ret != E_OK) {
     
    336338}
    337339
    338 enum main_state_t{
     340enum main_state_t {
     341        main_state_start,
    339342        main_state_idle,
    340343};
    341344
    342345int main_timer = TMO_FEVR;
    343 enum main_state_t main_state = main_state_idle;
     346enum main_state_t main_state = main_state_start;
    344347
    345348int main_lcd_timer = TMO_FEVR;
     
    386389        analogin_init(&joystick, P1_12);
    387390
    388         /* 10ms後にボタン状態を確認 */
    389         main_timer = 10 * 1000;
     391        /* ECHONETミドルウェアを起動するのを待つ */
     392        main_state = main_state_start;
     393        main_timer = 1000 * 1000;
    390394
    391395        /* ボタン状態読み込み */
     
    397401        spi_init(&lcd.hspi, P10_14, P10_15, P10_12, NC);
    398402        spi_format(&lcd.hspi, 8, 0, 0);
    399         spi_frequency(&lcd.hspi, 1000000);
     403        spi_frequency(&lcd.hspi, 4000000);
    400404
    401405        gpio_init_out(&lcd.cs_pin, P10_13);
     
    416420        main_lcd_timer = 1000 * 1000;
    417421
     422        /* メインタスクを起動 */
    418423        ER ret = act_tsk(MAIN_TASK);
    419424        if (ret != E_OK) {
     
    429434        int result = main_timer;
    430435
    431         if((result == TMO_FEVR)
    432                 || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))){
     436        if ((result == TMO_FEVR)
     437                || ((main_lcd_timer != TMO_FEVR) && (main_lcd_timer < result))) {
    433438                result = main_lcd_timer;
    434439        }
     
    442447static void main_progress(int interval)
    443448{
    444         if(main_timer != TMO_FEVR){
     449        if (main_timer != TMO_FEVR) {
    445450                main_timer -= interval;
    446                 if(main_timer < 0){
     451                if (main_timer < 0) {
    447452                        main_timer = 0;
    448453                }
    449454        }
    450455
    451         if(main_lcd_timer != TMO_FEVR){
     456        if (main_lcd_timer != TMO_FEVR) {
    452457                main_lcd_timer -= interval;
    453                 if(main_lcd_timer < 0){
     458                if (main_lcd_timer < 0) {
    454459                        main_lcd_timer = 0;
    455460                }
     
    472477
    473478        ret = ecn_itr_ini(&enm, esv);
    474         if(ret != E_OK){
     479        if (ret != E_OK) {
    475480                syslog(LOG_ERROR, "ecn_itr_ini");
    476481                return;
    477482        }
    478483
    479         for(;;) {
    480                 while((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
     484        for (;;) {
     485                while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
    481486                        switch (epc) {
    482487                        case 0xE0:
    483                                 if(in_get && (esv->hdr.edata.esv == ESV_SET_GET_RES)){
     488                                if (in_get && (esv->hdr.edata.esv == ESV_SET_GET_RES)) {
    484489                                        check_response(pdc, p_edt);
    485490                                }
     
    487492                        }
    488493                }
    489                 if(ret != E_BOVR){
     494                if (ret != E_BOVR) {
    490495                        syslog(LOG_ERROR, "ecn_itr_nxt");
    491496                        break;
    492497                }
    493                 if(enm.is_eof)
     498                if (enm.is_eof)
    494499                        break;
    495500
     
    504509static void main_break_wait(uint8_t *brkdat, int32_t len)
    505510{
     511        char mac_text[30] = "mac: ";
     512        char ipaddr_text[30] = "ipadr: ";
     513        const T_IN4_ADDR *ip4_addr;
     514        int pos;
     515
    506516        if (brkdat[0] == 0x01) {
    507                 // Link up/down
     517                pos = str_macaddr(&mac_text[4], sizeof(mac_text) - 4, mac_addr, 0);
     518                mac_text[pos + 4] = '\0';
     519                lcd_drawString(&lcd, mac_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 11), ST7735_BLACK, ST7735_WHITE);
     520
     521                ip4_addr = in4_get_ifaddr(0);
     522                pos = str_ipv4addr(&ipaddr_text[6], sizeof(ipaddr_text) - 6, ip4_addr, 0);
     523                ipaddr_text[pos + 6] = '\0';
     524                lcd_drawString(&lcd, ipaddr_text, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 12), ST7735_BLACK, ST7735_WHITE);
    508525                return;
    509526        }
    510527
    511528        if ((len == 2) && (brkdat[0] == 0x80)) {
    512                 switch(brkdat[1]){
     529                switch (brkdat[1]) {
    513530                /* ONの場合 */
    514531                case 0x30:
     
    533550static void main_timeout()
    534551{
    535         if(main_timer == 0){
     552        if (main_timer == 0) {
    536553                main_ontimer();
    537554        }
    538555
    539         if(main_lcd_timer == 0){
     556        if (main_lcd_timer == 0) {
    540557                main_lcd_ontimer();
    541558        }
     
    543560
    544561#define main_ad_count 3
     562#define main_ad_table_count 64
    545563static int16_t main_ad_tempr[main_ad_count] = { 200, 200, 200 };
    546 static uint16_t main_ad_table[64];
    547 #define main_ad_table_count (sizeof(main_ad_table) / sizeof(main_ad_table[0]))
     564static uint16_t main_ad_table[main_ad_count][main_ad_table_count];
    548565static int main_ad_pos = 0;
    549566static uint32_t main_ad_avelage[main_ad_count];
     
    556573static void main_ontimer()
    557574{
     575        ER ret;
    558576        uint8_t btn;
    559577        uint16_t ad_value;
    560578        int16_t ad_tempr;
    561579
    562         switch(main_state){
     580        switch (main_state) {
     581        case main_state_start:
     582                /* ECHONETミドルウェアを起動 */
     583                ret = ecn_sta_svc();
     584                if (ret != E_OK) {
     585                        syslog(LOG_ERROR, "ecn_sta_svc");
     586                }
     587
     588                /* 10ms後にボタン状態を確認 */
     589                main_state = main_state_idle;
     590                main_timer = 10 * 1000;
     591                break;
    563592        case main_state_idle:
    564593                /* 10ms後にボタン状態を確認 */
     
    567596                /* ADCの変換結果取得 */
    568597                for (int i = 0; i < main_ad_count; i++) {
    569                         main_ad_avelage[i] -= main_ad_table[main_ad_pos];
     598                        main_ad_avelage[i] -= main_ad_table[i][main_ad_pos];
    570599                        ad_value = analogin_read_u16(&analogin[i]) >> 4;        // 16bit値取得->12bit
    571                         main_ad_table[main_ad_pos] = ad_value;
     600                        main_ad_table[i][main_ad_pos] = ad_value;
    572601                        main_ad_avelage[i] += ad_value;
    573602                }
    574603
    575604                main_ad_pos++;
    576                 if(main_ad_pos >= main_ad_table_count){
     605                if (main_ad_pos >= main_ad_table_count) {
    577606                        main_ad_pos = 0;
    578607                }
     
    586615                                }
    587616                                else {
     617                                        main_count[i] = 0;
    588618                                        main_ad_tempr[i] = ad_tempr;
    589619
     
    601631
    602632                /* ボタン1の処理 */
    603                 if((btn == BUTTON_LEFT) && !main_btn1_state){
     633                if ((btn == BUTTON_LEFT) && !main_btn1_state) {
    604634                        main_btn1_count++;
    605                         if(main_btn1_count > 10){
     635                        if (main_btn1_count > 10) {
    606636                                main_btn1_count = 0;
    607637                                main_btn1_state = true;
     
    610640                        }
    611641                }
    612                 else if((btn != BUTTON_LEFT) && main_btn1_state){
     642                else if ((btn != BUTTON_LEFT) && main_btn1_state) {
    613643                        main_btn1_count++;
    614                         if(main_btn1_count > 10){
     644                        if (main_btn1_count > 10) {
    615645                                main_btn1_count = 0;
    616646                                main_btn1_state = false;
     
    621651
    622652                /* ボタン2の処理 */
    623                 if((btn == BUTTON_RIGHT) && !main_btn2_state){
     653                if ((btn == BUTTON_RIGHT) && !main_btn2_state) {
    624654                        main_btn2_count++;
    625                         if(main_btn2_count > 10){
     655                        if (main_btn2_count > 10) {
    626656                                main_btn2_count = 0;
    627657                                main_btn2_state = true;
     
    630660                        }
    631661                }
    632                 else if((btn != BUTTON_RIGHT) && main_btn2_state){
     662                else if ((btn != BUTTON_RIGHT) && main_btn2_state) {
    633663                        main_btn2_count++;
    634                         if(main_btn2_count > 10){
     664                        if (main_btn2_count > 10) {
    635665                                main_btn2_count = 0;
    636666                                main_btn2_state = false;
     
    645675static void main_lcd_ontimer()
    646676{
    647         char temp1[] = "温度1:+00.0℃";
    648         char temp2[] = "温度2:+00.0℃";
    649         char humid[] = "湿度 :+00.0%";
     677        char temp1[] = "温度1:+000.0℃";
     678        char temp2[] = "温度2:+000.0℃";
     679        char humid[] = "湿度 :+000.0%";
    650680        char *btn_texts[] = { "none  ", "down  ", "left  ", "select", "up    ", "right " };
    651681        int temp, btn;
     
    653683        switch (main_lcd_state) {
    654684        case 0:
    655                 temp1[9] = (temperature_sensor1_data.propertyE0 >= 0) ? ' ' : '-';
     685                temp1[10] = (temperature_sensor1_data.propertyE0 >= 0) ? ' ' : '-';
    656686                temp = (temperature_sensor1_data.propertyE0 / 1000) % 10;
    657687                if (temp < 0)
    658688                        temp = -temp;
    659                 temp1[10] = '0' + temp;
     689                temp1[11] = '0' + temp;
    660690                temp = (temperature_sensor1_data.propertyE0 / 100) % 10;
    661691                if (temp < 0)
    662692                        temp = -temp;
    663                 temp1[11] = '0' + temp;
     693                temp1[12] = '0' + temp;
    664694                temp = (temperature_sensor1_data.propertyE0 / 10) % 10;
    665695                if (temp < 0)
    666696                        temp = -temp;
    667697                temp1[13] = '0' + temp;
    668                 lcd_drawString(&lcd, &temp1[9], X_LINE_HALF_TO_PIX(&lcd, 8) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);
     698                temp = (temperature_sensor1_data.propertyE0 / 1) % 10;
     699                if (temp < 0)
     700                        temp = -temp;
     701                temp1[15] = '0' + temp;
     702                lcd_drawString(&lcd, &temp1[10], X_LINE_HALF_TO_PIX(&lcd, 7), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE);
    669703                main_lcd_state++;
    670704                break;
    671705        case 1:
    672                 temp2[9] = (temperature_sensor2_data.propertyE0 >= 0) ? ' ' : '-';
     706                temp2[10] = (temperature_sensor2_data.propertyE0 >= 0) ? ' ' : '-';
    673707                temp = (temperature_sensor2_data.propertyE0 / 1000) % 10;
    674708                if (temp < 0)
    675709                        temp = -temp;
    676                 temp2[10] = '0' + temp;
     710                temp2[11] = '0' + temp;
    677711                temp = (temperature_sensor2_data.propertyE0 / 100) % 10;
    678712                if (temp < 0)
    679713                        temp = -temp;
    680                 temp2[11] = '0' + temp;
     714                temp2[12] = '0' + temp;
    681715                temp = (temperature_sensor2_data.propertyE0 / 10) % 10;
    682716                if (temp < 0)
    683717                        temp = -temp;
    684718                temp2[13] = '0' + temp;
    685                 lcd_drawString(&lcd, &temp2[9], X_LINE_HALF_TO_PIX(&lcd, 8) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);
     719                temp = (temperature_sensor2_data.propertyE0 / 1) % 10;
     720                if (temp < 0)
     721                        temp = -temp;
     722                temp2[15] = '0' + temp;
     723                lcd_drawString(&lcd, &temp2[10], X_LINE_HALF_TO_PIX(&lcd, 7), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE);
    686724                main_lcd_state++;
    687725                break;
    688726        case 2:
    689                 humid[9] = ' ';
    690                 temp = (humidity_sensor_data.propertyE0 / 1000) % 10;
    691                 humid[10] = '0' + temp;
     727                humid[10] = ' ';
     728                humid[11] = ' ';
    692729                temp = (humidity_sensor_data.propertyE0 / 100) % 10;
    693                 humid[11] = '0' + temp;
     730                humid[12] = '0' + temp;
    694731                temp = (humidity_sensor_data.propertyE0 / 10) % 10;
    695732                humid[13] = '0' + temp;
    696                 lcd_drawString(&lcd, &humid[9], X_LINE_HALF_TO_PIX(&lcd, 8) + 10, Y_ROW_TO_PIX(&lcd, main_lcd_state + 4) + 10, ST7735_BLACK, ST7735_WHITE);
     733                temp = (humidity_sensor_data.propertyE0 / 1) % 10;
     734                humid[15] = '0' + temp;
     735                lcd_drawString(&lcd, &humid[10], X_LINE_HALF_TO_PIX(&lcd, 7), Y_ROW_TO_PIX(&lcd, main_lcd_state + 2), ST7735_BLACK, ST7735_WHITE);
    697736                main_lcd_state++;
    698737                break;
     
    704743        case 6:
    705744                btn = main_read_button(&joystick);
    706                 lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 10) + 10, ST7735_BLACK, ST7735_WHITE);
     745                lcd_drawString(&lcd, btn_texts[btn], X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 9), ST7735_BLACK, ST7735_WHITE);
    707746                main_lcd_state++;
    708747                break;
     
    711750                break;
    712751        case 10:
    713                 lcd_drawString(&lcd, "温度湿度計", X_LINE_TO_PIX(&lcd, 9) + 10, Y_ROW_TO_PIX(&lcd, 0) + 10, ST7735_BLACK, ST7735_WHITE);
    714                 lcd_drawString(&lcd, temp1, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 0 + 4) + 10, ST7735_BLACK, ST7735_WHITE);
    715                 lcd_drawString(&lcd, temp2, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 1 + 4) + 10, ST7735_BLACK, ST7735_WHITE);
    716                 lcd_drawString(&lcd, humid, X_LINE_TO_PIX(&lcd, 0) + 10, Y_ROW_TO_PIX(&lcd, 2 + 4) + 10, ST7735_BLACK, ST7735_WHITE);
     752                lcd_drawString(&lcd, "温度湿度計", X_LINE_TO_PIX(&lcd, 5), Y_ROW_TO_PIX(&lcd, 0), ST7735_BLACK, ST7735_WHITE);
     753                lcd_drawString(&lcd, temp1, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 0 + 2), ST7735_BLACK, ST7735_WHITE);
     754                lcd_drawString(&lcd, temp2, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 1 + 2), ST7735_BLACK, ST7735_WHITE);
     755                lcd_drawString(&lcd, humid, X_LINE_TO_PIX(&lcd, 0), Y_ROW_TO_PIX(&lcd, 2 + 2), ST7735_BLACK, ST7735_WHITE);
    717756                main_lcd_state = 0;
    718757                break;
     
    755794        /* プロパティ設定電文作成 */
    756795        ret = ecn_esv_setc(&esv, eobj, 0xE0, 2, p_edt);
    757         if(ret != E_OK){
     796        if (ret != E_OK) {
    758797                syslog(LOG_ERROR, "ecn_esv_setc");
    759798                return;
     
    761800
    762801        /* 電文送信 */
    763         ecn_snd_esv(esv);
     802        ret = ecn_snd_esv(esv);
     803        if (ret != E_OK) {
     804                syslog(LOG_ERROR, "ecn_snd_esv");
     805        }
    764806}
    765807
     
    798840
    799841        /* 押されて戻った時に処理する */
    800         if(push)
     842        if (push)
    801843                return;
    802844
    803845        /* 温度計測値 */
    804846        main_tmpr -= 10;        /* - 1.0℃ */
    805         if(main_tmpr < -100)    /* -10.0℃までとする */
     847        if (main_tmpr < -100)   /* -10.0℃までとする */
    806848                main_tmpr = -100;
    807849
     
    811853        /* プロパティ値書き込み・読み出し要求電文作成 */
    812854        ret = ecn_esv_set_get(&esv, TEMP_SENSOR_02_EOBJ, 0xE0, 2, p_edt);
    813         if(ret != E_OK){
     855        if (ret != E_OK) {
    814856                syslog(LOG_ERROR, "ecn_esv_setc");
    815857                return;
     
    820862        /* 書き込みプロパティ追加 */
    821863        ret = ecn_add_edt(esv, 0x80, 1, p_edt);
    822         if(ret) {
     864        if (ret) {
    823865                syslog(LOG_ERROR, "ecn_add_edt");
    824866                goto error;
     
    827869        /* プロパティ値書き込み・読み出し要求電文作成:折り返し指定 */
    828870        ret = ecn_trn_set_get(esv, &trn_pos);
    829         if(ret) {
     871        if (ret) {
    830872                syslog(LOG_ERROR, "ecn_trn_set_get");
    831873                goto error;
     
    834876        /* 読み出しプロパティ追加 */
    835877        ret = ecn_add_epc(esv, 0xE0);
    836         if(ret) {
     878        if (ret) {
    837879                syslog(LOG_ERROR, "ecn_add_epc");
    838880                goto error;
     
    841883        /* プロパティ値書き込み・読み出し要求電文作成:終了指定 */
    842884        ret = ecn_end_set_get(esv, trn_pos);
    843         if(ret) {
     885        if (ret) {
    844886                syslog(LOG_ERROR, "ecn_end_set_get");
    845887                goto error;
     
    848890        /* 電文送信 */
    849891        ret = ecn_snd_esv(esv);
    850         if(ret != E_OK){
     892        if (ret != E_OK) {
    851893                syslog(LOG_ERROR, "ecn_snd_esv");
    852894        }
     
    855897        /* 領域解放 */
    856898        ret = ecn_rel_esv(esv);
    857         if (ret != E_OK){
     899        if (ret != E_OK) {
    858900                syslog(LOG_ERROR, "ecn_rel_esv");
    859901        }
     
    871913
    872914        /* 押されて戻った時に処理する */
    873         if(push)
     915        if (push)
    874916                return;
    875917
    876918        /* 温度計測値 */
    877919        main_tmpr += 10;        /* + 1.0℃ */
    878         if(main_tmpr > 400)     /* +40.0℃までとする */
     920        if (main_tmpr > 400)    /* +40.0℃までとする */
    879921                main_tmpr = 400;
    880922
     
    884926        /* プロパティ値書き込み・読み出し要求電文作成 */
    885927        ret = ecn_esv_set_get(&esv, TEMP_SENSOR_02_EOBJ, 0xE0, 2, p_edt);
    886         if(ret != E_OK){
     928        if (ret != E_OK) {
    887929                syslog(LOG_ERROR, "ecn_esv_setc");
    888930                return;
     
    893935        /* 書き込みプロパティ追加 */
    894936        ret = ecn_add_edt(esv, 0x80, 1, p_edt);
    895         if(ret) {
     937        if (ret) {
    896938                syslog(LOG_ERROR, "ecn_add_edt");
    897939                goto error;
     
    900942        /* プロパティ値書き込み・読み出し要求電文作成:折り返し指定 */
    901943        ret = ecn_trn_set_get(esv, &trn_pos);
    902         if(ret) {
     944        if (ret) {
    903945                syslog(LOG_ERROR, "ecn_trn_set_get");
    904946                goto error;
     
    907949        /* 読み出しプロパティ追加 */
    908950        ret = ecn_add_epc(esv, 0xE0);
    909         if(ret) {
     951        if (ret) {
    910952                syslog(LOG_ERROR, "ecn_add_epc");
    911953                goto error;
     
    914956        /* プロパティ値書き込み・読み出し要求電文作成:終了指定 */
    915957        ret = ecn_end_set_get(esv, trn_pos);
    916         if(ret) {
     958        if (ret) {
    917959                syslog(LOG_ERROR, "ecn_end_set_get");
    918960                goto error;
     
    921963        /* 電文送信 */
    922964        ret = ecn_snd_esv(esv);
    923         if(ret != E_OK){
     965        if (ret != E_OK) {
    924966                syslog(LOG_ERROR, "ecn_snd_esv");
    925967        }
     
    928970        /* 領域解放 */
    929971        ret = ecn_rel_esv(esv);
    930         if (ret != E_OK){
     972        if (ret != E_OK) {
    931973                syslog(LOG_ERROR, "ecn_rel_esv");
    932974        }
     
    938980static bool_t check_response(uint8_t pdc, uint8_t *p_edt)
    939981{
    940         if((pdc != 2)
     982        if ((pdc != 2)
    941983                || (p_edt[0] != ((uint16_t)main_tmpr) >> 8)
    942                 || (p_edt[1] != ((uint16_t)main_tmpr) & 0xFF))
    943         {
     984                || (p_edt[1] != ((uint16_t)main_tmpr) & 0xFF)) {
    944985                syslog(LOG_WARNING, "epc_set_get response NG");
    945986                return false;
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app5_temp_sensor/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/Debug/Makefile

    r352 r364  
    173173        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    174174endif
    175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     175CDEFS := $(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
    176176INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    177177        -I$(SRCDIR)/../btstack/include \
     
    181181        -I$(SRCDIR)/../usbhost/src \
    182182        $(INCLUDES)
    183 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     183LDFLAGS := $(LDFLAGS) -L.
    184184LIBS := $(LIBS) $(CXXLIBS)
    185185CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    215215endif
    216216
    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
     217ifdef 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
     247endif
    247248
    248249#
     
    277278#  コンフィギュレータに関する定義
    278279#
    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 \
     280ifndef 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)
     284else
     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 \
    281287                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    282288                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    284290                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    285291                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     292endif
    286293CFG_ASMOBJS := $(CFG_ASMOBJS)
    287294CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    429436
    430437#
     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#
    431445#  特別な依存関係の定義
    432446#
     
    437451#
    438452$(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 \
    440454                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    441455                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/DebugEther/Makefile

    r352 r364  
    171171        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    172172endif
    173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     173CDEFS := $(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
    174174INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    175175        -I$(SRCDIR)/../btstack/include \
     
    179179        -I$(SRCDIR)/../usbhost/src \
    180180        $(INCLUDES)
    181 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     181LDFLAGS := $(LDFLAGS) -L.
    182182LIBS := $(LIBS) $(CXXLIBS)
    183183CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    213213endif
    214214
    215 
    216 #
    217 #  ネットワークサービスの定義
    218 #
    219 NO_USE_TINET_LIBRARY = true
    220 
    221 #  ネットワークインタフェースの選択、何れか一つ選択する。
    222 NET_IF = ether
    223 
    224 #  イーサネット・ディバイスドライバの選択
     215ifdef TINETDIR
     216        #
     217        #  ネットワークサービスの定義
     218        #
     219        NO_USE_TINET_LIBRARY = true
     220
     221        #  ネットワークインタフェースの選択、何れか一つ選択する。
     222        NET_IF = ether
     223
     224        #  イーサネット・ディバイスドライバの選択
    225225        NET_DEV = if_mbed
    226226
    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
     245endif
    245246
    246247#
     
    275276#  コンフィギュレータに関する定義
    276277#
    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 \
     278ifndef 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)
     282else
     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 \
    279285                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    280286                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    282288                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    283289                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     290endif
    284291CFG_ASMOBJS := $(CFG_ASMOBJS)
    285292CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    427434
    428435#
     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#
    429443#  特別な依存関係の定義
    430444#
     
    435449#
    436450$(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 \
    438452                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    439453                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    113113{
    114114        /* サイズが1以外は受け付けない */
    115         if(size != 1)
     115        if (size != 1)
    116116                return 0;
    117117
    118118        *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src);
    119119
    120         switch(*(uint8_t *)src){
     120        switch (*(uint8_t *)src) {
    121121        /* ONの場合 */
    122122        case 0x30:
     
    145145{
    146146        /* サイズが1以外は受け付けない */
    147         if(size != 1)
     147        if (size != 1)
    148148                return 0;
    149149
    150150        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    151151
    152         switch(*(uint8_t *)src){
     152        switch (*(uint8_t *)src) {
    153153        /* 異常発生ありの場合 */
    154154        case 0x41:
     
    174174
    175175        /* サイズが1以外は受け付けない */
    176         if(size != 1)
     176        if (size != 1)
    177177                return 0;
    178178
    179179        *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src);
    180180
    181         switch(*(uint8_t *)src){
     181        switch (*(uint8_t *)src) {
    182182        /* 湯切れ無しの場合 */
    183183        case 0x40:
     
    200200        data[0] = 0xB1;
    201201        ret = ecn_brk_wai(data, sizeof(data));
    202         if(ret != E_OK){
     202        if (ret != E_OK) {
    203203                syslog(LOG_ERROR, "ecn_brk_wai");
    204204        }
     
    213213{
    214214        /* サイズが1以外は受け付けない */
    215         if(size != 1)
     215        if (size != 1)
    216216                return 0;
    217217
    218218        *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src);
    219219
    220         switch(*(uint8_t *)src){
     220        switch (*(uint8_t *)src) {
    221221        /* 出湯有の場合 */
    222222        case 0x41:
     
    262262
    263263        ret2 = get_tim(&now);
    264         if (ret2 != E_OK){
     264        if (ret2 != E_OK) {
    265265                syslog(LOG_ERROR, "get_tim");
    266266                return;
    267267        }
    268268
    269         for(;;){
     269        for (;;) {
    270270                prev = now;
    271271
     
    275275                /* 応答電文待ち */
    276276                ret = ecn_trcv_esv(&esv, timer);
    277                 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)){
     277                if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {
    278278                        syslog(LOG_ERROR, "ecn_trcv_esv");
    279279                        break;
     
    281281
    282282                ret2 = get_tim(&now);
    283                 if (ret2 != E_OK){
     283                if (ret2 != E_OK) {
    284284                        syslog(LOG_ERROR, "get_tim");
    285285                        break;
     
    296296                        /* 領域解放 */
    297297                        ret = ecn_rel_esv(esv);
    298                         if (ret != E_OK){
     298                        if (ret != E_OK) {
    299299                                syslog(LOG_ERROR, "ecn_rel_esv");
    300300                                break;
     
    305305                        /* 応答電文待ちの割り込みデータ取得 */
    306306                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    307                         if (ret != E_OK){
     307                        if (ret != E_OK) {
    308308                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    309309                                break;
     
    315315                        /* 領域解放 */
    316316                        ret = ecn_rel_esv(esv);
    317                         if (ret != E_OK){
     317                        if (ret != E_OK) {
    318318                                syslog(LOG_ERROR, "ecn_rel_esv");
    319319                                break;
     
    326326}
    327327
    328 bool_t started = false;
    329 
    330328void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    331329{
     
    335333                return;
    336334
    337         if (up && !started) {
    338                 started = true;
    339 
    340                 /* ECHONETミドルウェアを起動 */
    341                 ret = ecn_sta_svc();
    342                 if (ret != E_OK)
    343                         return;
    344 
    345                 /* ECHONETミドルウェアを起動するのを待つ */
    346                 dly_tsk(100);
     335        if (up) {
     336                /* インスタンスリスト通知の送信 */
     337                ret = ecn_ntf_inl();
     338                if (ret != E_OK) {
     339                        syslog(LOG_ERROR, "ecn_ntf_inl");
     340                }
    347341        }
    348342
     
    358352}
    359353
    360 enum main_state_t{
     354enum main_state_t {
     355        main_state_start,
    361356        main_state_idle,
    362357        main_state_search,
     
    365360
    366361int main_timer = TMO_FEVR;
    367 enum main_state_t main_state = main_state_idle;
     362enum main_state_t main_state = main_state_start;
    368363int main_retry;
    369364
     
    397392        gpio_write(&led_red, 0);
    398393
    399         /* 1秒後にブザーを検索 */
    400         main_state = main_state_search;
     394
     395        /* ECHONETミドルウェアを起動するのを待つ */
     396        main_state = main_state_start;
    401397        main_timer = 1000 * 1000;
    402398
     
    410406        main_btn2_state = btn2 != 0;
    411407
     408        /* メインタスクを起動 */
    412409        ER ret = act_tsk(MAIN_TASK);
    413410        if (ret != E_OK) {
     
    423420        int result = main_timer;
    424421
    425         if((result == TMO_FEVR)
    426                 || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))){
     422        if ((result == TMO_FEVR)
     423                || ((main_btn_timer != TMO_FEVR) && (main_btn_timer < result))) {
    427424                result = main_btn_timer;
    428425        }
     
    436433static void main_progress(int interval)
    437434{
    438         if(main_timer != TMO_FEVR){
     435        if (main_timer != TMO_FEVR) {
    439436                main_timer -= interval;
    440                 if(main_timer < 0){
     437                if (main_timer < 0) {
    441438                        main_timer = 0;
    442439                }
    443440        }
    444441
    445         if(main_btn_timer != TMO_FEVR){
     442        if (main_btn_timer != TMO_FEVR) {
    446443                main_btn_timer -= interval;
    447                 if(main_btn_timer < 0){
     444                if (main_btn_timer < 0) {
    448445                        main_btn_timer = 0;
    449446                }
     
    464461
    465462        eobjid = ecn_get_eobj(esv);
    466         if(eobjid == EOBJ_NULL){
     463        if (eobjid == EOBJ_NULL) {
    467464                syslog(LOG_ERROR, "ecn_get_eobj");
    468465                return;
     
    470467
    471468        ret = ecn_itr_ini(&enm, esv);
    472         if(ret != E_OK){
     469        if (ret != E_OK) {
    473470                syslog(LOG_ERROR, "ecn_itr_ini");
    474471                return;
    475472        }
    476473
    477         for(;;) {
    478                 while((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
     474        for (;;) {
     475                while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
    479476                        switch (epc) {
    480477                        case 0xB1:
    481                                 switch(main_state){
     478                                switch (main_state) {
    482479                                /* プロパティ通知応答待ちの場合 */
    483480                                case main_state_wait_res:
    484481                                        /* プロパティ通知応答のみ処理 */
    485                                         if((esv->hdr.edata.esv == ESV_INFC_RES) && (eobjid == BUZZER_NODE_EOBJ)){
     482                                        if ((esv->hdr.edata.esv == ESV_INFC_RES) && (eobjid == BUZZER_NODE_EOBJ)) {
    486483                                                /* 応答受信 */
    487484                                                main_state = main_state_idle;
     
    492489                                break;
    493490                        case 0xD6:
    494                                 switch(main_state){
     491                                switch (main_state) {
    495492                                case main_state_search:
    496493                                        if (eobjid == BUZZER_NODE_EOBJ) {
     
    504501                        }
    505502                }
    506                 if(ret != E_BOVR){
     503                if (ret != E_BOVR) {
    507504                        syslog(LOG_ERROR, "ecn_itr_nxt");
    508505                        break;
    509506                }
    510                 if(enm.is_eof)
     507                if (enm.is_eof)
    511508                        break;
    512509        }
     
    526523        }
    527524
    528         switch(main_state){
     525        switch (main_state) {
    529526        case main_state_idle:
    530527        case main_state_wait_res:
    531                 if((len >= 1) && (*brkdat == 0xB1)){
     528                if ((len >= 1) && (*brkdat == 0xB1)) {
    532529                        /* ブザーに湯切れ警告状態通知 */
    533530                        ret = ecn_esv_infc(&esv, BUZZER_NODE_EOBJ, ELECTRIC_HOT_WATER_POT_EOBJ, 0xB1);
    534                         if(ret != E_OK){
     531                        if (ret != E_OK) {
    535532                                syslog(LOG_ERROR, "ecn_esv_infc");
    536533                                return;
     
    539536                        /* 電文送信 */
    540537                        ret = ecn_snd_esv(esv);
    541                         if(ret != E_OK){
     538                        if (ret != E_OK) {
    542539                                syslog(LOG_ERROR, "ecn_snd_esv");
    543540                        }
     
    560557static void main_timeout()
    561558{
    562         if(main_timer == 0){
     559        if (main_timer == 0) {
    563560                main_ontimer();
    564561        }
    565562
    566         if(main_btn_timer == 0){
     563        if (main_btn_timer == 0) {
    567564                main_btn_ontimer();
    568565        }
     
    576573        T_EDATA *esv;
    577574
    578         switch(main_state){
     575        switch (main_state) {
     576        case main_state_start:
     577                /* ECHONETミドルウェアを起動 */
     578                ret = ecn_sta_svc();
     579                if (ret != E_OK) {
     580                        syslog(LOG_ERROR, "ecn_sta_svc");
     581                }
     582
     583                /* 1秒後にブザーを検索 */
     584                main_state = main_state_search;
     585                main_timer = 1000 * 1000;
     586                break;
    579587        case main_state_idle:
    580588                syslog(LOG_ERROR, "timeout faild on main_state_idle");
     
    589597        case main_state_wait_res:
    590598                /* リトライアウトの場合 */
    591                 if(main_retry == 0){
     599                if (main_retry == 0) {
    592600                        /* あきらめる */
    593601                        main_state = main_state_idle;
     
    598606                /* ブザーに湯切れ警告状態通知を再送 */
    599607                ret = ecn_esv_infc(&esv, BUZZER_NODE_EOBJ, ELECTRIC_HOT_WATER_POT_EOBJ, 0xB1);
    600                 if(ret != E_OK){
     608                if (ret != E_OK) {
    601609                        syslog(LOG_ERROR, "ecn_esv_infc");
    602610                        main_state = main_state_idle;
     
    607615                /* 電文送信 */
    608616                ret = ecn_snd_esv(esv);
    609                 if(ret != E_OK){
     617                if (ret != E_OK) {
    610618                        syslog(LOG_ERROR, "ecn_snd_esv");
    611619                        main_state = main_state_idle;
     
    629637        /* ブザー検索 */
    630638        ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6);
    631         if(ret != E_OK){
     639        if (ret != E_OK) {
    632640                syslog(LOG_ERROR, "ecn_esv_inf_req");
    633641                return;
     
    636644        /* 電文送信 */
    637645        ret = ecn_snd_esv(esv);
    638         if(ret != E_OK){
     646        if (ret != E_OK) {
    639647                syslog(LOG_ERROR, "ecn_snd_esv");
    640648        }
     
    656664
    657665        /* ボタン1の処理 */
    658         if((btn1 != 0) && !main_btn1_state){
     666        if ((btn1 != 0) && !main_btn1_state) {
    659667                main_btn1_count++;
    660                 if(main_btn1_count > 10){
     668                if (main_btn1_count > 10) {
    661669                        main_btn1_count = 0;
    662670                        main_btn1_state = true;
     
    665673                }
    666674        }
    667         else if((btn1 == 0) && main_btn1_state){
     675        else if ((btn1 == 0) && main_btn1_state) {
    668676                main_btn1_count++;
    669                 if(main_btn1_count > 10){
     677                if (main_btn1_count > 10) {
    670678                        main_btn1_count = 0;
    671679                        main_btn1_state = false;
     
    676684
    677685        /* ボタン2の処理 */
    678         if((btn2 != 0) && !main_btn2_state){
     686        if ((btn2 != 0) && !main_btn2_state) {
    679687                main_btn2_count++;
    680                 if(main_btn2_count > 10){
     688                if (main_btn2_count > 10) {
    681689                        main_btn2_count = 0;
    682690                        main_btn2_state = true;
     
    685693                }
    686694        }
    687         else if((btn2 == 0) && main_btn2_state){
     695        else if ((btn2 == 0) && main_btn2_state) {
    688696                main_btn2_count++;
    689                 if(main_btn2_count > 10){
     697                if (main_btn2_count > 10) {
    690698                        main_btn2_count = 0;
    691699                        main_btn2_state = false;
     
    708716
    709717        /* 押されて戻った時に処理する */
    710         if(push)
     718        if (push)
    711719                return;
    712720
     
    718726        /* プロパティ設定電文作成 */
    719727        ret = ecn_esv_seti(&esv, ELECTRIC_HOT_WATER_POT_EOBJ, 0xB1, 1, p_edt);
    720         if(ret != E_OK){
     728        if (ret != E_OK) {
    721729                syslog(LOG_ERROR, "ecn_esv_seti");
    722730                return;
     
    725733        /* 電文送信 */
    726734        ecn_snd_esv(esv);
    727         if(ret != E_OK){
     735        if (ret != E_OK) {
    728736                syslog(LOG_ERROR, "ecn_snd_esv");
    729737        }
     
    744752        /* プロパティ設定電文作成 */
    745753        ret = ecn_esv_seti(&esv, ELECTRIC_HOT_WATER_POT_EOBJ, 0xE2, 1, p_edt);
    746         if(ret != E_OK){
     754        if (ret != E_OK) {
    747755                syslog(LOG_ERROR, "ecn_esv_seti");
    748756                return;
     
    751759        /* 電文送信 */
    752760        ecn_snd_esv(esv);
    753         if(ret != E_OK){
     761        if (ret != E_OK) {
    754762                syslog(LOG_ERROR, "ecn_snd_esv");
    755763        }
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app6_hot_water_pot/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.157741361" 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"/>
    6060                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1697219582" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    61                                                         <builder buildPath="${workspace_loc:/app7_buzzer}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.314753602" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     61                                                        <builder buildPath="${workspace_loc:/app7_buzzer}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.314753602" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    6262                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1983465188" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    6363                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1082331522" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    164164                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.1092918155" 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"/>
    165165                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1370006715" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    166                                                         <builder buildPath="${workspace_loc:/app7_buzzer}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.2100247045" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     166                                                        <builder buildPath="${workspace_loc:/app7_buzzer}/DebugEther" id="com.renesas.cdt.managedbuild.gcc.rz.builder.2100247045" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    167167                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1932491155" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    168168                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.158555834" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/Debug/Makefile

    r352 r364  
    173173        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    174174endif
    175 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     175CDEFS := $(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
    176176INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    177177        -I$(SRCDIR)/../btstack/include \
     
    181181        -I$(SRCDIR)/../usbhost/src \
    182182        $(INCLUDES)
    183 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     183LDFLAGS := $(LDFLAGS) -L.
    184184LIBS := $(LIBS) $(CXXLIBS)
    185185CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    215215endif
    216216
    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
     217ifdef 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
     247endif
    247248
    248249#
     
    277278#  コンフィギュレータに関する定義
    278279#
    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 \
     280ifndef 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)
     284else
     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 \
    281287                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    282288                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    284290                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    285291                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     292endif
    286293CFG_ASMOBJS := $(CFG_ASMOBJS)
    287294CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    429436
    430437#
     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#
    431445#  特別な依存関係の定義
    432446#
     
    437451#
    438452$(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 \
    440454                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    441455                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/DebugEther/Makefile

    r352 r364  
    171171        CDEFS := -DTOPPERS_OMIT_TECS $(CDEFS)
    172172endif
    173 CDEFS := $(CDEFS) -DDHCP4_CLI_CFG -DUSE_PING -DUSE_RESOLVER -DUSE_NETAPP_SUBR -DECHONET_USE_MALLOC -DRamDisk=_binary_______ntshell_src_rom_fs_bin_start
     173CDEFS := $(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
    174174INCLUDES := -I. -I$(SRCDIR)/include -I$(SRCDIR) \
    175175        -I$(SRCDIR)/../btstack/include \
     
    179179        -I$(SRCDIR)/../usbhost/src \
    180180        $(INCLUDES)
    181 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     181LDFLAGS := $(LDFLAGS) -L.
    182182LIBS := $(LIBS) $(CXXLIBS)
    183183CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    213213endif
    214214
    215 
    216 #
    217 #  ネットワークサービスの定義
    218 #
    219 NO_USE_TINET_LIBRARY = true
    220 
    221 #  ネットワークインタフェースの選択、何れか一つ選択する。
    222 NET_IF = ether
    223 
    224 #  イーサネット・ディバイスドライバの選択
     215ifdef TINETDIR
     216        #
     217        #  ネットワークサービスの定義
     218        #
     219        NO_USE_TINET_LIBRARY = true
     220
     221        #  ネットワークインタフェースの選択、何れか一つ選択する。
     222        NET_IF = ether
     223
     224        #  イーサネット・ディバイスドライバの選択
    225225        NET_DEV = if_mbed
    226226
    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
     245endif
    245246
    246247#
     
    275276#  コンフィギュレータに関する定義
    276277#
    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 \
     278ifndef 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)
     282else
     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 \
    279285                        --api-table ../../ntshell/echonet/echonet_api.def:echonet \
    280286                        --api-table $(SRCDIR)/kernel/kernel_api.def:kernel \
     
    282288                        --symval-table ../../ntshell/echonet/echonet_sym.def \
    283289                        --symval-table $(SRCDIR)/kernel/kernel_sym.def $(CFG_TABS)
     290endif
    284291CFG_ASMOBJS := $(CFG_ASMOBJS)
    285292CFG_COBJS := kernel_cfg.o echonet_cfg.o $(CFG_COBJS)
     
    427434
    428435#
     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#
    429443#  特別な依存関係の定義
    430444#
     
    435449#
    436450$(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 \
    438452                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    439453                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/src/echonet_main.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2014-2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
    3737
    38 /* 
     38/*
    3939 *  サンプルプログラム(1)の本体
    4040 */
     
    112112{
    113113        /* サイズが1以外は受け付けない */
    114         if(size != 1)
     114        if (size != 1)
    115115                return 0;
    116116
    117117        *anno = *((uint8_t*)item->exinf) != *((uint8_t*)src);
    118118
    119         switch(*(uint8_t *)src){
     119        switch (*(uint8_t *)src) {
    120120        /* ONの場合 */
    121121        case 0x30:
     
    144144{
    145145        /* サイズが1以外は受け付けない */
    146         if(size != 1)
     146        if (size != 1)
    147147                return 0;
    148148
    149149        *anno = *((uint8_t *)item->exinf) != *((uint8_t *)src);
    150150
    151         switch(*(uint8_t *)src){
     151        switch (*(uint8_t *)src) {
    152152        /* 異常発生ありの場合 */
    153153        case 0x41:
     
    170170{
    171171        /* サイズが1以外は受け付けない */
    172         if(size != 1)
    173                 return 0;
    174 
    175         switch(*(uint8_t *)src){
     172        if (size != 1)
     173                return 0;
     174
     175        switch (*(uint8_t *)src) {
    176176        /* 音発生有の場合 */
    177177        case 0x41:
     
    203203
    204204        /* サイズが1以外は受け付けない */
    205         if(size != 1)
     205        if (size != 1)
    206206                return 0;
    207207
     
    212212        data[1] = (*((uint8_t *)src) == 0x41) ? 0x01 : 0x00;
    213213        ret = ecn_brk_wai(data, sizeof(data));
    214         if(ret != E_OK){
     214        if (ret != E_OK) {
    215215                syslog(LOG_ERROR, "ecn_brk_wai");
    216216        }
     
    228228
    229229        /* サイズが1以外は受け付けない */
    230         if(size != 1)
     230        if (size != 1)
    231231                return 0;
    232232
     
    237237        data[1] = (*((uint8_t *)src) == 0x41) ? 0x01 : 0x00;
    238238        ret = ecn_brk_wai(data, sizeof(data));
    239         if(ret != E_OK){
     239        if (ret != E_OK) {
    240240                syslog(LOG_ERROR, "ecn_brk_wai");
    241241        }
     
    267267
    268268        ret2 = get_tim(&now);
    269         if (ret2 != E_OK){
     269        if (ret2 != E_OK) {
    270270                syslog(LOG_ERROR, "get_tim");
    271271                return;
    272272        }
    273273
    274         for(;;){
     274        for (;;) {
    275275                prev = now;
    276276
     
    280280                /* 応答電文待ち */
    281281                ret = ecn_trcv_esv(&esv, timer);
    282                 if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)){
     282                if ((ret != E_OK) && (ret != E_BRK) && (ret != E_TMOUT)) {
    283283                        syslog(LOG_ERROR, "ecn_trcv_esv");
    284284                        break;
     
    286286
    287287                ret2 = get_tim(&now);
    288                 if (ret2 != E_OK){
     288                if (ret2 != E_OK) {
    289289                        syslog(LOG_ERROR, "get_tim");
    290290                        break;
     
    301301                        /* 領域解放 */
    302302                        ret = ecn_rel_esv(esv);
    303                         if (ret != E_OK){
     303                        if (ret != E_OK) {
    304304                                syslog(LOG_ERROR, "ecn_rel_esv");
    305305                                break;
     
    310310                        /* 応答電文待ちの割り込みデータ取得 */
    311311                        ret = ecn_get_brk_dat(esv, brkdat, sizeof(brkdat), &len);
    312                         if (ret != E_OK){
     312                        if (ret != E_OK) {
    313313                                syslog(LOG_ERROR, "ecn_get_brk_dat");
    314314                                break;
     
    320320                        /* 領域解放 */
    321321                        ret = ecn_rel_esv(esv);
    322                         if (ret != E_OK){
     322                        if (ret != E_OK) {
    323323                                syslog(LOG_ERROR, "ecn_rel_esv");
    324324                                break;
     
    331331}
    332332
    333 bool_t started = false;
    334 
    335333void echonet_change_netif_link(uint8_t link_up, uint8_t up)
    336334{
     
    340338                return;
    341339
    342         if (up && !started) {
    343                 started = true;
    344 
    345                 /* ECHONETミドルウェアを起動 */
    346                 ret = ecn_sta_svc();
    347                 if (ret != E_OK)
    348                         return;
    349 
    350                 /* ECHONETミドルウェアを起動するのを待つ */
    351                 dly_tsk(100);
     340        if (up) {
     341                /* インスタンスリスト通知の送信 */
     342                ret = ecn_ntf_inl();
     343                if (ret != E_OK) {
     344                        syslog(LOG_ERROR, "ecn_ntf_inl");
     345                }
    352346        }
    353347
     
    363357}
    364358
    365 enum main_state_t{
     359enum main_state_t {
     360        main_state_start,
    366361        main_state_idle,
    367362        main_state_search,
     
    370365
    371366int main_timer = TMO_FEVR;
    372 enum main_state_t main_state = main_state_idle;
     367enum main_state_t main_state = main_state_start;
    373368
    374369int main_nop_timer = TMO_FEVR;
     
    390385        gpio_write(&led_red, 0);
    391386
    392         /* 1秒後にブザーを検索 */
    393         main_state = main_state_search;
     387        /* ECHONETミドルウェアを起動するのを待つ */
     388        main_state = main_state_start;
    394389        main_timer = 1000 * 1000;
    395390
     391        /* メインタスクを起動 */
    396392        ER ret = act_tsk(MAIN_TASK);
    397393        if (ret != E_OK) {
     
    407403        int result = main_timer;
    408404
    409         if((result == TMO_FEVR)
    410                 || ((main_nop_timer != TMO_FEVR) && (main_nop_timer < result))){
     405        if ((result == TMO_FEVR)
     406                || ((main_nop_timer != TMO_FEVR) && (main_nop_timer < result))) {
    411407                result = main_nop_timer;
    412408        }
     
    420416static void main_progress(int interval)
    421417{
    422         if(main_timer != TMO_FEVR){
     418        if (main_timer != TMO_FEVR) {
    423419                main_timer -= interval;
    424                 if(main_timer < 0){
     420                if (main_timer < 0) {
    425421                        main_timer = 0;
    426422                }
    427423        }
    428424
    429         if(main_nop_timer != TMO_FEVR){
     425        if (main_nop_timer != TMO_FEVR) {
    430426                main_nop_timer -= interval;
    431                 if(main_nop_timer < 0){
     427                if (main_nop_timer < 0) {
    432428                        main_nop_timer = 0;
    433429                }
     
    448444
    449445        eobjid = ecn_get_eobj(esv);
    450         if(eobjid == EOBJ_NULL){
     446        if (eobjid == EOBJ_NULL) {
    451447                syslog(LOG_ERROR, "ecn_get_eobj");
    452448                return;
     
    454450
    455451        ret = ecn_itr_ini(&enm, esv);
    456         if(ret != E_OK){
     452        if (ret != E_OK) {
    457453                syslog(LOG_ERROR, "ecn_itr_ini");
    458454                return;
    459455        }
    460456
    461         for(;;) {
    462                 while((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
     457        for (;;) {
     458                while ((ret = ecn_itr_nxt(&enm, &epc, &pdc, p_edt)) == E_OK) {
    463459                        switch (epc) {
    464460                        case 0xD6:
    465                                 switch(main_state){
     461                                switch (main_state) {
    466462                                case main_state_search:
    467463                                        if (eobjid == POT_NODE_EOBJ) {
     
    475471                        }
    476472                }
    477                 if(ret != E_BOVR){
     473                if (ret != E_BOVR) {
    478474                        syslog(LOG_ERROR, "ecn_itr_nxt");
    479475                        break;
    480476                }
    481                 if(enm.is_eof)
     477                if (enm.is_eof)
    482478                        break;
    483479        }
     
    490486        uint8_t p_edt[1];
    491487
    492         switch(main_state){
     488        switch (main_state) {
    493489        case main_state_idle:
    494490                p_edt[0] = 0x41; /* 音発生有 */
     
    496492                /* プロパティ設定電文作成 */
    497493                ret = ecn_esv_seti(&esv, BUZZER_EOBJ, 0xB1, 1, p_edt);
    498                 if(ret != E_OK){
     494                if (ret != E_OK) {
    499495                        syslog(LOG_ERROR, "ecn_esv_seti");
    500496                        break;
     
    503499                /* 電文送信 */
    504500                ecn_snd_esv(esv);
    505                 if(ret != E_OK){
     501                if (ret != E_OK) {
    506502                        syslog(LOG_ERROR, "ecn_snd_esv");
    507503                        break;
     
    523519        uint8_t p_edt[1];
    524520
    525         switch(main_state){
     521        switch (main_state) {
    526522        case main_state_buzzer_on:
    527523                p_edt[0] = 0x42; /* 音発生無 */
     
    529525                /* プロパティ設定電文作成 */
    530526                ret = ecn_esv_seti(&esv, BUZZER_EOBJ, 0xB1, 1, p_edt);
    531                 if(ret != E_OK){
     527                if (ret != E_OK) {
    532528                        syslog(LOG_ERROR, "ecn_esv_seti");
    533529                        break;
     
    536532                /* 電文送信 */
    537533                ecn_snd_esv(esv);
    538                 if(ret != E_OK){
     534                if (ret != E_OK) {
    539535                        syslog(LOG_ERROR, "ecn_snd_esv");
    540536                        break;
     
    557553        }
    558554
    559         if(len < 2)
    560                 return;
    561 
    562         switch(brkdat[0]){
     555        if (len < 2)
     556                return;
     557
     558        switch (brkdat[0]) {
    563559        case 0x01:
    564                 if(brkdat[1] != 0)
     560                if (brkdat[1] != 0)
    565561                        main_buzzer_on();
    566562                else
     
    568564                break;
    569565        case 0x02:
    570                 if(brkdat[1] == 0)
     566                if (brkdat[1] == 0)
    571567                        main_nop_timer = 5000 * 1000; /* 5秒後にブザーON */
    572568                break;
     
    582578static void main_timeout()
    583579{
    584         if(main_timer == 0){
     580        if (main_timer == 0) {
    585581                main_ontimer();
    586582        }
    587583
    588         if(main_nop_timer == 0){
     584        if (main_nop_timer == 0) {
    589585                main_nop_timeout();
    590586        }
     
    595591static void main_ontimer()
    596592{
    597         switch (main_state)
    598         {
     593        ER ret;
     594
     595        switch (main_state) {
     596        case main_state_start:
     597                /* ECHONETミドルウェアを起動 */
     598                ret = ecn_sta_svc();
     599                if (ret != E_OK) {
     600                        syslog(LOG_ERROR, "ecn_sta_svc");
     601                }
     602
     603                /* 1秒後にブザーを検索 */
     604                main_state = main_state_search;
     605                main_timer = 1000 * 1000;
     606                break;
    599607        case main_state_search:
    600608                /* 電気ポット再検索 */
     
    620628        /* 電気ポット検索 */
    621629        ret = ecn_esv_inf_req(&esv, EOBJ_NULL, 0xD6);
    622         if(ret != E_OK){
     630        if (ret != E_OK) {
    623631                syslog(LOG_ERROR, "ecn_esv_inf_req");
    624632                return;
     
    627635        /* 電文送信 */
    628636        ret = ecn_snd_esv(esv);
    629         if(ret != E_OK){
     637        if (ret != E_OK) {
    630638                syslog(LOG_ERROR, "ecn_snd_esv");
    631639        }
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/src/main.c

    r359 r364  
    7979
    8080ID ws_api_mailboxid = MAIN_DATAQUEUE;
     81#ifndef NOUSE_MPF_NET_BUF
    8182ID ws_mempoolid = MPF_NET_BUF_256;
     83#endif
    8284
    8385#ifdef IF_ETHER_BTUSB
     
    111113static void main_timeout();
    112114
     115extern int ntshell_exit;
     116
    113117int uart_read(char *buf, int cnt, void *extobj)
    114118{
    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;
    116153}
    117154
     
    119156{
    120157        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);
    136158}
    137159
     
    150172        main_initialize();
    151173
    152         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     174        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    153175        ntshell_set_prompt(&ntshell, "NTShell>");
    154176        ntshell_execute(&ntshell);
     
    168190        ER ret;
    169191
    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);
    171198
    172199        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/app7_buzzer/src/main.cfg

    r352 r364  
    5454INCLUDE("tinet/tinet_asp.cfg");
    5555INCLUDE("tinet_main.cfg");
    56 INCLUDE("netinet/ip_igmp.cfg");
    5756
    5857/* DHCP クライアント */
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.368389066" 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"/>
    6060                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.601068640" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    61                                                         <builder buildPath="${workspace_loc:/asp3_dcre}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1149515652" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     61                                                        <builder buildPath="${workspace_loc:/asp3_dcre}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.1149515652" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    6262                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.519851149" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    6363                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.279657327" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/Debug/Makefile

    r352 r364  
    5656SRCLANG = c
    5757ifeq ($(SRCLANG),c)
    58         LIBS = -lmusl
     58        LIBS = $(SRCDIR)/../musl-1.1.18/Debug/libmusl.a
    5959endif
    6060ifeq ($(SRCLANG),c++)
    6161        USE_CXX = true
    62         CXXLIBS = -lstdc++ -lmusl
     62        CXXLIBS = -lstdc++ $(SRCDIR)/../musl-1.1.18/Debug/libmusl.a
    6363        CXXRTS = cxxrt.o newlibrt.o
    6464endif
     
    150150endif
    151151
     152TINETDIR =
     153
    152154#
    153155#  mbedサービスの定義
     
    171173CDEFS := $(CDEFS)
    172174INCLUDES := -I. -I$(SRCDIR)/include $(INCLUDES) -I$(SRCDIR)
    173 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L$(SRCDIR)/../musl-1.1.18/Debug
     175LDFLAGS := $(LDFLAGS) -L.
    174176LIBS := $(LIBS) $(CXXLIBS)
    175177CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
     
    192194endif
    193195APPL_COBJS := $(APPL_COBJS) log_output.o vasyslog.o t_perror.o strerror.o time.o
    194 APPL_CFLAGS := $(APPL_CFLAGS)
     196APPL_CFLAGS := $(APPL_CFLAGS) -nostdinc
    195197ifdef APPLDIRS
    196198        INCLUDES := $(INCLUDES) $(foreach dir,$(APPLDIRS),-I$(dir))
    197199endif
    198200
    199 TINETDIR =
    200201ifdef TINETDIR
    201202        #
     
    335336vpath %.cfg $(APPL_DIRS)
    336337vpath %.cdl $(APPL_DIRS)
     338vpath %.bin $(APPL_DIRS)
    337339
    338340#
     
    341343KERNEL_LIB_OBJS = $(KERNEL_ASMOBJS) $(KERNEL_COBJS) $(KERNEL_LCOBJS)
    342344SYSSVC_OBJS = $(SYSSVC_ASMOBJS) $(SYSSVC_COBJS) $(HIDDEN_OBJS)
    343 APPL_OBJS = $(APPL_ASMOBJS) $(APPL_COBJS) $(APPL_CXXOBJS)
     345APPL_OBJS = $(APPL_ASMOBJS) $(APPL_COBJS) $(APPL_CXXOBJS) $(APPL_BINOBJS)
    344346ALL_OBJS = $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    345347                                                                                        $(END_OBJS) $(HIDDEN_OBJS)
     
    387389$(CFG1_OUT): $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS) $(HIDDEN_OBJS)
    388390        $(LINK) $(CFLAGS) $(LDFLAGS) $(CFG1_OUT_LDFLAGS) -o $(CFG1_OUT) \
    389                                                 $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS)
     391                                                $(START_OBJS) cfg1_out.o $(CFG_DMY) $(END_OBJS) $(HIDDEN_OBJS)
    390392
    391393cfg1_out.syms: $(CFG1_OUT)
     
    416418
    417419#
     420#  並列makeのための依存関係の定義
     421#
     422$(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp
     423$(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \
     424                                                                                                                | offset.timestamp
     425
     426#
    418427#  特別な依存関係の定義
    419428#
     
    424433#
    425434$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
    426         $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
     435        $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \
    427436                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    428                         $(ALL_LIBS) $(END_OBJS)
     437                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
    429438
    430439#
     
    597606        $(CC) -c -MD -MP -MF $(DEPDIR)/$*.d $(CFLAGS) $(APPL_CFLAGS) $<
    598607
     608$(APPL_BINOBJS): %.o: %.bin
     609        $(OBJCOPY) -B arm -I binary -O elf32-littlearm --rename-section .data=.rodata $< $*.o
     610
    599611#
    600612#  デフォルトコンパイルルールを上書き
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/gdic/adafruit_st7735/adafruit_st7735.c

    r352 r364  
    354354
    355355/*
     356 *  LCDへのRGBデータ送信関数
     357 */
     358ER
     359lcd_writedata4(LCD_Handler_t *hlcd, uint8_t *pbmp, uint16_t width, uint16_t height)
     360{
     361        ER  ercd = E_OK;
     362        int index, i;
     363
     364        if(width == 0 || height == 0)
     365                return ercd;
     366        if(hlcd->spi_lock != 0){
     367                if((ercd = wai_sem(hlcd->spi_lock)) != E_OK)
     368                        return ercd;
     369        }
     370        rs_set(PORT_HIGH);
     371        cs_set(PORT_LOW);
     372        //dly_tsk(100/*us*/);
     373        for(index=0; index < height; index++){
     374                uint8_t *p = pbmp;
     375                for (i = 0; i < width; i++){
     376                        spi_master_write(&hlcd->hspi, *p++);
     377                        spi_master_write(&hlcd->hspi, *p++);
     378                }
     379                pbmp -= width*2;
     380        }
     381        //dly_tsk(100/*us*/);
     382        cs_set(PORT_HIGH);
     383        if(hlcd->spi_lock != 0)
     384                sig_sem(hlcd->spi_lock);
     385        return ercd;
     386}
     387
     388/*
    356389 *  ST7735へのコマンドリスト送信
    357390 */
     
    590623        lcd_setAddrWindow(hlcd, x0, y0, x0+width-1, y0+height-1);
    591624        lcd_writedata3(hlcd, pbmp, width, height);
     625}
     626
     627void
     628lcd_drawImage(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, int16_t w, int16_t h, uint8_t *pbmp)
     629{
     630        lcd_setAddrWindow(hlcd, x0, y0, x0+w-1, y0+h-1);
     631        pbmp += w * (h - 1) * 3; 
     632        lcd_writedata3(hlcd, pbmp, w, h);
    592633}
    593634
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/gdic/adafruit_st7735/adafruit_st7735.h

    r352 r364  
    5959#endif
    6060
     61#include <stdbool.h>
    6162#include "device.h"
    6263#include "pinmap.h"
     
    145146#ifndef TOPPERS_MACRO_ONLY
    146147
     148typedef struct GFXfont GFXfont;
     149
    147150/*
    148151 *  LCDハンドラ構造体定義
     
    153156        uint16_t                _width;         /* 幅ピクセル数 */
    154157        uint16_t                                _height;        /* 高さピクセル数 */
     158        int16_t cursor_x, cursor_y;
     159        uint16_t textcolor, textbgcolor;
     160        uint8_t textsize, rotation;
     161        bool wrap;
     162        GFXfont *gfxFont;
    155163        uint8_t                 colstart;
    156164        uint8_t                 rowstart;
     
    188196extern ER lcd_writedata2(LCD_Handler_t *hlcd, uint16_t c, int cnt);
    189197extern ER lcd_writedata3(LCD_Handler_t *hlcd, uint8_t *pbmp, uint16_t width, uint16_t height);
     198extern ER lcd_writedata4(LCD_Handler_t *hlcd, uint8_t *pbmp, uint16_t width, uint16_t height);
    190199
    191200extern void lcd_initB(LCD_Handler_t *hlcd);
     
    198207extern void lcd_drawFastHLine(LCD_Handler_t *hlcd, int16_t x, int16_t y, int16_t w, uint16_t color);
    199208extern void lcd_drawBitmap(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, uint8_t *pbmp);
     209extern void lcd_drawImage(LCD_Handler_t *hlcd, uint16_t x0, uint16_t y0, int16_t w, int16_t h, uint8_t *pbmp);
    200210extern void lcd_invertDisplay(LCD_Handler_t *hlcd, bool_t i);
    201211
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/hal/spi_api.h

    r352 r364  
    116116 */
    117117int  spi_master_write(spi_t *obj, int value);
     118
     119/** Write a block out in master mode and receive a value
     120 *
     121 *  The total number of bytes sent and received will be the maximum of
     122 *  tx_length and rx_length. The bytes written will be padded with the
     123 *  value 0xff.
     124 *
     125 * @param[in] obj        The SPI peripheral to use for sending
     126 * @param[in] tx_buffer  Pointer to the byte-array of data to write to the device
     127 * @param[in] tx_length  Number of bytes to write, may be zero
     128 * @param[in] rx_buffer  Pointer to the byte-array of data to read from the device
     129 * @param[in] rx_length  Number of bytes to read, may be zero
     130 * @param[in] write_fill Default data transmitted while performing a read
     131 * @returns
     132 *      The number of bytes written and read from the device. This is
     133 *      maximum of tx_length and rx_length.
     134 */
     135int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length, char *rx_buffer, int rx_length, char write_fill);
    118136
    119137/** Check if a value is available to read
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/platform/mbed_rtc_time.c

    r352 r364  
    4444time_t __time32(time_t *timer)
    4545#else
    46 time_t time(time_t *timer)
     46time_t get_time(time_t *timer)
    4747#endif
    4848
     
    7878}
    7979
    80 clock_t clock() {
     80clock_t get_clock() {
    8181    //_mutex->lock();
    8282    clock_t t = us_ticker_read();
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/mbed/targets/TARGET_RENESAS/TARGET_RZ_A1H/spi_api.c

    r352 r364  
    259259    while(!spi_tend(obj));
    260260    return spi_read(obj);
     261}
     262
     263int spi_master_block_write(spi_t *obj, const char *tx_buffer, int tx_length,
     264                           char *rx_buffer, int rx_length, char write_fill) {
     265    int total = (tx_length > rx_length) ? tx_length : rx_length;
     266
     267    for (int i = 0; i < total; i++) {
     268        char out = (i < tx_length) ? tx_buffer[i] : write_fill;
     269        char in = spi_master_write(obj, out);
     270        if (i < rx_length) {
     271            rx_buffer[i] = in;
     272        }
     273    }
     274
     275    return total;
    261276}
    262277
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/sample/Makefile

    r352 r364  
    417417#
    418418$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
    419         $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
     419        $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \
    420420                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    421421                        $(ALL_LIBS) $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/syssvc/serial.h

    r359 r364  
    7979extern ER               serial_opn_por(ID portid) throw();
    8080extern ER               serial_cls_por(ID portid) throw();
    81 extern ER_UINT  serial_rea_dat(ID portid, char *buf, uint_t len) throw();
     81extern ER_UINT  serial_trea_dat(ID portid, char *buf, uint_t len, TMO tmout) throw();
    8282extern ER_UINT  serial_wri_dat(ID portid, const char *buf, uint_t len) throw();
    8383extern ER               serial_ctl_por(ID portid, uint_t ioctl) throw();
    8484extern ER               serial_ref_por(ID portid, T_SERIAL_RPOR *pk_rpor) throw();
     85
     86Inline ER_UINT  serial_rea_dat(ID portid, char *buf, uint_t len)
     87{
     88        return serial_trea_dat(portid, buf, len, TMO_FEVR);
     89}
    8590
    8691/*
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/syssvc/tSerialAdapter.c

    r352 r364  
    8383 */
    8484ER_UINT
    85 serial_rea_dat(ID portid, char *buf, uint_t len)
     85serial_trea_dat(ID portid, char *buf, uint_t len, TMO tmout)
    8686{
    8787        if (sns_dpn()) {                                /* コンテキストのチェック */
     
    9292        }
    9393
    94         return(cSerialPort_read(portid - 1, buf, len));
     94        return(cSerialPort_read(portid - 1, buf, len, tmout));
    9595}
    9696
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/syssvc/tSerialPort.cdl

    r352 r364  
    5757        ER              open(void);
    5858        ER              close(void);
    59         ER_UINT read([out,size_is(length)] char *buffer, [in] uint_t length);
     59        ER_UINT read([out,size_is(length)] char *buffer, [in] uint_t length, [in] TMO tmout);
    6060        ER_UINT write([in,size_is(length)] const char *buffer, [in] uint_t length);
    6161        ER              control([in] uint_t ioControl);
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/syssvc/tSerialPortMain.c

    r359 r364  
    397397 */
    398398ER_UINT
    399 eSerialPort_read(CELLIDX idx, char *buffer, uint_t length)
     399eSerialPort_read(CELLIDX idx, char *buffer, uint_t length, TMO tmout)
    400400{
    401401        CELLCB  *p_cellcb;
     
    423423        while (reacnt < length) {
    424424                if (buffer_empty) {
    425                         SVC(rercd = cReceiveSemaphore_wait(),
    426                                                                                 gen_ercd_wait(rercd, p_cellcb));
     425                        rercd = cReceiveSemaphore_waitTimeout(tmout);
     426                        if (rercd == E_TMOUT)
     427                                return E_TMOUT;
     428                        if (rercd < 0) {
     429                                gen_ercd_wait(rercd, p_cellcb);
     430                                ercd = rercd;
     431                                goto error_exit;
     432                        }
    427433                }
    428434                SVC(rercd = serialPort_readChar(p_cellcb, &c), rercd);
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/Makefile.tinet

    r352 r364  
    9393               in_subr.o route_cfg.o
    9494TINET_CFG_COBJS := $(TINET_CFG_COBJS) tinet_cfg.o
     95TINET_CFG2_OUT_SRCS := $(TINET_CFG2_OUT_SRCS) tinet_cfg.h tinet_cfg.c
    9596
    9697#  IPv6
     
    328329
    329330        CFG_COBJS := $(CFG_COBJS) $(TINET_CFG_COBJS)
     331        CFG2_OUT_SRCS := $(CFG2_OUT_SRCS) $(TINET_CFG2_OUT_SRCS)
    330332
    331333        CLEAN_FILES := $(CLEAN_FILES) $(TINET_CFG_OUT) $(MAKE_TINET_LIB)
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/net/ethernet.h

    r352 r364  
    9898#endif  /* of #ifndef IF_ETHER_NIC_HDR_ALIGN */
    9999
    100 #if defined(__RX) || defined(_MSC_VER)
    101100#if defined(__RX)
    102101#pragma pack
    103 #else
     102#elif defined(_MSC_VER)
    104103#pragma pack(push, 1)
    105104#endif
     105
     106#if defined(__RX) || defined(_MSC_VER)
     107
    106108typedef struct t_ether_header {
    107109
     
    116118        uint16_t        type;
    117119        } T_ETHER_HDR;
    118 #if defined(__RX)
    119 #pragma packoption
    120 #else
    121 #pragma pack(pop)
    122 #endif
    123120
    124121#elif defined(TOPPERS_S810_CLG3_85)     /* of #if defined(__RX) */
     
    166163        uint8_t         lladdr[ETHER_ADDR_LEN];
    167164        } __attribute__((packed, aligned(2))) T_ETHER_ADDR;
     165
     166#if defined(__RX)
     167#pragma packoption
     168#elif defined(_MSC_VER)
     169#pragma pack(pop)
     170#endif
    168171
    169172/*
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/net/net_asp.cfg

    r352 r364  
    4141
    4242INCLUDE("net/net.cfg");
     43
     44#ifndef NOUSE_MPF_NET_BUF
    4345
    4446/*
     
    169171                });
    170172#endif  /* of #if defined(NUM_MPF_NET_BUF6_65536) && NUM_MPF_NET_BUF6_65536 > 0 */
     173
     174#endif
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/net/net_buf.c

    r352 r364  
    6868#include <netinet/tcp_var.h>
    6969
     70#ifndef NOUSE_MPF_NET_BUF
     71
    7072/*
    7173 *  関数
     
    226228#endif  /* of #if defined(NUM_MPF_NET_BUF_128) && NUM_MPF_NET_BUF_128 > 0 */
    227229
    228 #if defined(_IP4_CFG)
     230#if defined(_IP6_CFG)
     231
     232#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
     233        {
     234                MPF_NET_BUF_CSEG,
     235                IF_HDR_SIZE + IP_HDR_SIZE + TCP_HDR_SIZE,
     236
     237#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     238
     239                NUM_MPF_NET_BUF_CSEG,
     240
     241#endif  /* of #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF */
     242
     243                },
     244#endif  /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
     245
     246#endif  /* of #if defined(_IP6_CFG) */
    229247
    230248#if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0
     
    242260#endif  /* of #if defined(NUM_MPF_NET_BUF_64) && NUM_MPF_NET_BUF_64 > 0 */
    243261
    244 #endif  /* of #if defined(_IP4_CFG) */
     262#if defined(_IP4_CFG) && !defined(_IP6_CFG)
    245263
    246264#if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0
     
    257275                },
    258276#endif  /* of #if defined(NUM_MPF_NET_BUF_CSEG) && NUM_MPF_NET_BUF_CSEG > 0 */
     277
     278#endif  /* of #if defined(_IP4_CFG) && !defined(_IP6_CFG) */
    259279
    260280        };
     
    307327
    308328        while (1) {
    309                 if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
     329                if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf, ix == 0 ? tmout : TMO_POL)) == E_OK) {
    310330                        (*buf)->idix  = (uint8_t)ix;
    311331                        (*buf)->len   = (uint16_t)minlen;
     
    320340                        return error;
    321341                        }
    322                 else if (ix == 0 || net_buf_table[ix].size > maxlen)
     342                ix --;
     343                if (ix < 0 || net_buf_table[ix].size > maxlen)
    323344                        break;
    324                 ix --;
    325345                }
    326346
     
    351371
    352372        while (1) {
    353                 if ((error = tget_mpf((ID)net_buf_table[ix].index, (void*)buf,
     373                if ((error = tget_mpf((ID)net_buf_table[ix].index, (void **)buf,
    354374                                      ix == sizeof(net_buf_table) / sizeof(T_NET_BUF_ENTRY) - 1 ? tmout : TMO_POL)) == E_OK) {
    355375                        (*buf)->idix  = (uint8_t)ix;
     
    359379                        (*buf)->conn_pos = 0;
    360380#endif
     381
    361382#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    362383                        NET_COUNT_NET_BUF(net_buf_table[ix].allocs, 1);
     
    454475                /* 固定メモリプールに返す。*/
    455476
    456 #if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
    457                 net_buf_table[buf->idix].busies --;
    458 #endif
    459                 if ((error = rel_mpf((ID)net_buf_table[buf->idix].index, buf)) != E_OK) {
    460                         syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), buf->idix);
     477                int idix = buf->idix;
     478#if NET_COUNT_ENABLE & PROTO_FLG_NET_BUF
     479                net_buf_table[idix].busies --;
     480#endif
     481                if ((error = rel_mpf((ID)net_buf_table[idix].index, buf)) != E_OK) {
     482                        syslog(LOG_WARNING, "[NET BUF] %s, ID=%d.", itron_strerror(error), idix);
    461483                        }
    462484                }
     
    509531        return (uint_t)net_buf_table[0].size;
    510532        }
     533
     534#else
     535#include <stdlib.h>
     536
     537/*
     538 *  tget_net_buf_ex -- ネットワークバッファを獲得する(拡張機能)。
     539 */
     540
     541ER
     542tget_net_buf_ex (T_NET_BUF **buf, uint_t minlen, uint_t maxlen, ATR nbatr, TMO tmout)
     543{
     544        uint_t len = (minlen > maxlen) ? minlen : maxlen;
     545        *buf = (T_NET_BUF *)malloc(sizeof(T_NET_BUF) - sizeof(((T_NET_BUF *)0)->buf) + len);
     546        if (*buf == NULL)
     547                return E_NOMEM;
     548
     549        (*buf)->idix = 0;
     550        (*buf)->len = (uint16_t)len;
     551        (*buf)->flags = 0;
     552#ifdef IF_ETHER_MULTI_NIC
     553        (*buf)->conn_pos = 0;
     554#endif
     555
     556        return E_OK;
     557        }
     558
     559/*
     560 *  tget_net_buf -- ネットワークバッファを獲得する(互換)。
     561 */
     562
     563ER
     564tget_net_buf (T_NET_BUF **buf, uint_t len, TMO tmout)
     565{
     566        return tget_net_buf_ex(buf, len, len, NBA_SEARCH_ASCENT, tmout);
     567        }
     568
     569
     570/*
     571 * rel_net_buf -- ネットワークバッファを返却する。
     572 */
     573
     574ER
     575rel_net_buf (T_NET_BUF *buf)
     576{
     577        free(buf);
     578
     579        return E_OK;
     580        }
     581
     582
     583/*
     584 * net_buf_max_siz -- ネットワークバッファの最大サイズを返す。
     585 */
     586
     587uint_t
     588net_buf_max_siz (void)
     589{
     590        return (uint_t)IF_PDU_SIZE;
     591        }
     592
     593#endif
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netapp/dbg_cons.c

    r352 r364  
    666666                    "IX Expire State      MAC Address       IP Address\n");
    667667
    668         /* expire の単位は [ms]。*/
     668        /* expire の単位は [us]。*/
    669669        get_tim(&now);
    670670        cache = nd6_get_cache();
     
    705705                    "IX Expire MAC Address       IP Address\n");
    706706
    707         /* expire の単位は [ms]。*/
     707        /* expire の単位は [us]。*/
    708708        cache = arp_get_cache();
    709709        for (ix = 0; ix < NUM_ARP_ENTRY; ix ++) {
     
    753753        WAI_NET_CONS_PRINTF();
    754754        get_tim(&now);
    755         cons_printf(portid, "ネットワーク統計情報\t経過時間[ms]\t%lu\t", now);
     755        cons_printf(portid, "ネットワーク統計情報\t経過時間[us]\t%lu\t", now);
    756756        if (now > (1000 * 3600 * 24))
    757757                cons_printf(portid, "%3lu日 %2lu時間 %2lu分 %2lu秒\n",
     
    938938                }
    939939
    940         cons_printf(portid, "\nネットワーク統計情報\t経過時間[ms]\t%lu\t", now);
     940        cons_printf(portid, "\nネットワーク統計情報\t経過時間[us]\t%lu\t", now);
    941941        if (now > (1000 * 3600 * 24))
    942942                cons_printf(portid, "%3lu日 %2lu時間 %2lu分 %2lu秒\n",
     
    10651065        WAI_NET_CONS_PRINTF();
    10661066        get_tim(&now);
    1067         cons_printf(portid, "ネットワークバッファ情報\t経過時間[ms]\t%u\n", now);
     1067        cons_printf(portid, "ネットワークバッファ情報\t経過時間[us]\t%u\n", now);
    10681068
    10691069#if NET_COUNT_ENABLE
     
    15771577        cons_printf(portid, " IP Address\n");
    15781578
    1579         /* expire の単位は [ms]。*/
     1579        /* expire の単位は [us]。*/
    15801580        get_tim(&now);
    15811581        dr = nd6_get_drl(&count);
     
    22982298
    22992299        cons_printf(portid, "ND:\n");
    2300         cons_printf(portid, "  TMO_ND6_RTR_SOL_DELAY:    %5d[ms]\n", TMO_ND6_RTR_SOL_DELAY);
    2301         cons_printf(portid, "  TMO_ND6_RTR_SOL_INTERVAL: %5d[ms]\n", TMO_ND6_RTR_SOL_INTERVAL);
     2300        cons_printf(portid, "  TMO_ND6_RTR_SOL_DELAY:    %5d[us]\n", TMO_ND6_RTR_SOL_DELAY);
     2301        cons_printf(portid, "  TMO_ND6_RTR_SOL_INTERVAL: %5d[us]\n", TMO_ND6_RTR_SOL_INTERVAL);
    23022302        cons_printf(portid, "  NUM_IP6_DAD_COUNT:        %5d\n",     NUM_IP6_DAD_COUNT);
    23032303        cons_printf(portid, "  NUM_ND6_CACHE_ENTRY:      %5d\n",     NUM_ND6_CACHE_ENTRY);
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netapp/dhcp4_cli.c

    r352 r364  
    20312031
    20322032                        /* 休止する。*/
    2033                         if (error == E_OK)
    2034                                 syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
     2033                        if (error == E_OK) {
     2034                                if (ct->fsm != DHCP4_FSM_SLEEP)
     2035                                        syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
     2036                        }
    20352037                        else {
    20362038                                syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(error));
     
    21582160
    21592161                        /* 休止する。*/
    2160                         if (ct->error == E_OK)
    2161                                 syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
     2162                        if (ct->error == E_OK) {
     2163                                if (ct->fsm != DHCP4_FSM_SLEEP)
     2164                                        syslog(LOG_NOTICE, "[DHCP4C] lease released, go to sleep.");
     2165                        }
    21622166                        else {
    21632167                                syslog(LOG_NOTICE, "[DHCP4C] server not available, go to sleep, error: %s.", itron_strerror(ct->error));
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netapp/wwws.c

    r352 r364  
    708708        len += put_str(cepid, srbuf, response);
    709709        get_tim(&finish);
    710         syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [ms]",
     710        syslog(LOG_NOTICE, "[WWWn:%02u SND] send: index.html, len: %4u, time: %lu [us]",
    711711                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    712712        return E_OK;
     
    16091609
    16101610        get_tim(&finish);
    1611         syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [ms]",
     1611        syslog(LOG_NOTICE, "[WWWn:%02u SND]send: stat.html,  len: %4u, time: %lu [us]",
    16121612                           cepid, len, (finish - start) * 1000 / SYSTIM_HZ);
    16131613        return E_OK;
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/icmp6.h

    r352 r364  
    291291typedef struct t_router_advert_hdr {
    292292        T_ICMP6_HDR     hdr;
    293         uint32_t        reachable;              /* [ms] 到達可能時間  */
    294         uint32_t        retransmit;             /* [ms] 近隣要請送信間隔        */
     293        uint32_t        reachable;              /* [us] 到達可能時間  */
     294        uint32_t        retransmit;             /* [us] 近隣要請送信間隔        */
    295295        /* この後にオプションが続く */
    296296        } __attribute__((packed, aligned(2))) T_ROUTER_ADVERT_HDR;
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/in4_subr.c

    r352 r364  
    287287
    288288        /* IP ヘッダを設定する。*/
    289         if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK)
     289        if ((error = in4_set_header(*nbuf, len, dstaddr, srcaddr, proto, ttl)) != E_OK) {
     290                syscall(rel_net_buf(*nbuf));
     291                *nbuf = NULL;
    290292                return error;
     293                }
    291294
    292295        /* 4 オクテット境界までパディングで埋める。*/
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/in_itron.h

    r352 r364  
    6262#define TFN_TCP_ALL             (0)
    6363
    64 #define TEV_TCP_RCV_OOB         (-0x201)
     64#define TEV_TCP_RCV_OOB         (0x201)
    6565
    6666/* UDP 関係 */
     
    7575#define TFN_UDP_ALL             (0)
    7676
    77 #define TEV_UDP_RCV_DAT         (-0x221)
     77#define TEV_UDP_RCV_DAT         (0x221)
    7878
    7979/* 一般 */
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/tcp_input.c

    r352 r364  
    13641364        NTOHS(tcph->dport);
    13651365
     1366        /* SDU 長 より 緊急ポインタが大きい場合 */
     1367        if (tcph->urp > tcph->sum)
     1368                goto drop;
     1369
    13661370find_cep:
    13671371
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/tcp_output.c

    r352 r364  
    369369                tcph->flags |= TCP_FLG_URG;
    370370                }
    371         else
     371        else {
     372                tcph->urp = 0;
    372373                cep->snd_up  = cep->snd_una;
     374                }
    373375
    374376#endif  /* of #ifdef TCP_CFG_EXTENTIONS */
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/tcp_usrreq.c

    r352 r364  
    897897
    898898        /* tcp_rcv_buf の割当て長をリセットする。*/
    899         cep->rcv_buf_len = 0;
     899        cep->rcv_buf_len -= len;
    900900
    901901        /* 通信端点のロックを解除する。*/
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udp_var.h

    r352 r364  
    101101typedef ER      (*t_udp_callback)(ID cepid, FN fncd, void *p_parblk);
    102102
     103typedef struct t_udp_rcv_dat_para {
     104        uint_t          len;
     105        T_NET_BUF       *input;
     106        uint_t          off;
     107        union {
     108                T_IPV4EP rep4;
     109                T_IPV6EP rep6;
     110        };
     111        } T_UDP_RCV_DAT_PARA;
     112
    103113/*
    104114 *  UDP 通信端点
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udpn_input.c

    r352 r364  
    7575{
    7676        T_UDP_HDR       *udph;
    77         uint_t          len;
     77        T_UDP_RCV_DAT_PARA para;
    7878
    7979        udph = (T_UDP_HDR *)(input->buf + off);
    80         len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
     80        para.len  = (uint_t)(ntohs(udph->ulen) - UDP_HDR_SIZE);
    8181
    8282        if (cep->rcv_tskid != TA_NULL) {        /* 非ノンブロッキングコールでペンディング中 */
     
    9898                /* データをバッファに移す。*/
    9999                memcpy(cep->rcv_data, GET_UDP_SDU(input, off),
    100                        (size_t)(len < cep->rcv_len ? len : cep->rcv_len));
     100                       (size_t)(para.len < cep->rcv_len ? para.len : cep->rcv_len));
    101101                syscall(rel_net_buf(input));
    102102
     
    104104
    105105#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    106                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)len);
     106                        (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)(uint32_t)para.len);
    107107#else
    108                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&len);
     108                        (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&para.len);
    109109#endif
    110110                else
     
    121121
    122122#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    123                 (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)len);
     123                (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)(uint32_t)para.len);
    124124#else
    125                 (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&len);
     125                para.input = input;
     126                para.off = off;
     127#if API_PROTO == API_PROTO_IPV4
     128                para.rep4.portno = ntohs(udph->sport);
     129                IN_COPY_TO_HOST(&para.rep4.ipaddr, input);
     130#else
     131                para.rep6.portno = ntohs(udph->sport);
     132                IN_COPY_TO_HOST(&para.rep6.ipaddr, input);
     133#endif
     134                (*cep->callback)(GET_UDP_CEPID(cep), TEV_UDP_RCV_DAT, (void*)&para.len);
    126135#endif
    127136                /*
     
    129138                 *  データを読み出さなかったことになるので、捨てる。
    130139                 */
    131                 if (cep->cb_netbuf != NULL)
    132                         syscall(rel_net_buf(cep->cb_netbuf));
     140                if (cep->cb_netbuf != NULL) {
     141                        if ((input->flags & NB_FLG_NOREL_IFOUT) == 0)
     142                                syscall(rel_net_buf(cep->cb_netbuf));
     143                        cep->cb_netbuf = NULL;
     144                        }
    133145                }
    134146        else {
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udpn_usrreq.c

    r352 r364  
    411411                return E_NOEXS;
    412412#if defined(SUPPORT_INET6)
    413 #endif
    414 #if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
     413#elif defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
    415414        switch (optname) {
    416415        case IP_MULTICAST_LOOP:
     
    488487                return E_NOEXS;
    489488#if defined(SUPPORT_INET6)
    490 #endif
    491 #if defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
     489#elif defined(SUPPORT_INET4) && defined(SUPPORT_IGMP) && TNUM_UDP4_CEPID > 0
    492490        switch (optname) {
    493491        case IP_MULTICAST_LOOP:
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet/udpn_usrreq_nblk.c

    r352 r364  
    122122
    123123#ifdef TCP_CFG_NON_BLOCKING_COMPAT14
    124                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)error);
     124                        (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)error);
    125125#else
    126                         (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_RCV_DAT, (void*)&error);
     126                        (*cep->callback)(GET_UDP_CEPID(cep), TFN_UDP_CAN_CEP, (void*)&error);
    127127#endif
    128128                else
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet6/in6_subr.c

    r352 r364  
    369369
    370370        /* IPv6 ヘッダを設定する。*/
    371         if ((error = in6_set_header(*nbuf, len, dstaddr, srcaddr, next, hlim)) != E_OK)
     371        if ((error = in6_set_header(*nbuf, len, dstaddr, srcaddr, next, hlim)) != E_OK) {
     372                syscall(rel_net_buf(*nbuf));
     373                *nbuf = NULL;
    372374                return error;
     375                }
    373376
    374377        /* 4 オクテット境界までパディングで埋める。*/
     
    662665 *  in6_rtredirect -- ルーティング表にエントリを登録する。
    663666 *
    664  *    注意: 引数 tmo の単位は [ms]。
     667 *    注意: 引数 tmo の単位は [us]。
    665668 */
    666669
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet6/in6_var.h

    r352 r364  
    184184         * vltime と pltime は、追加/変更してからの相対時間
    185185         */
    186         uint32_t        vltime;         /* 有効時間 [ms]                    */
    187         uint32_t        pltime;         /* 推奨有効時間 [ms]          */
     186        uint32_t        vltime;         /* 有効時間 [us]                    */
     187        uint32_t        pltime;         /* 推奨有効時間 [us]          */
    188188        } __attribute__((packed, aligned(2)))T_IN6_ADDR_LIFETIME;
    189189
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet6/nd6.c

    r352 r364  
    353353                        if (nd6_cache[mix].hold != NULL) {
    354354                                syscall(rel_net_buf(nd6_cache[mix].hold));
     355                                nd6_cache[mix].hold = NULL;
    355356                                }
    356357                        fix = mix;
     
    562563                        if (ln->hold != NULL) {
    563564                                syscall(rel_net_buf(ln->hold));
     565                                ln->hold = NULL;
    564566                                }
    565567
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/netinet6/nd6.h

    r352 r364  
    8181        T_NET_BUF       *hold;
    8282        TMO             tmout;
    83         SYSTIM          expire;         /* [ms] 有効時間が切れる時刻      */
     83        SYSTIM          expire;         /* [us] 有効時間が切れる時刻      */
    8484        T_IF_ADDR       ifaddr;
    8585        uint8_t         state;
     
    183183typedef struct t_def_router {
    184184        T_IN6_ADDR      addr;
    185         SYSTIM          expire;         /* [ms] 有効時間が切れる時刻      */
    186         uint32_t        lifetime;       /* [ms] 有効時間                    */
     185        SYSTIM          expire;         /* [us] 有効時間が切れる時刻      */
     186        uint32_t        lifetime;       /* [us] 有効時間                    */
    187187        uint16_t        plistmap;       /* プレフィックスマップ           */
    188188        uint8_t         flags;          /* ルータ通知のフラグ            */
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/tcpip_sym.def

    r352 r364  
    1515TMO_UDP_OUTPUT
    1616TMO_ICMP_OUTPUT
     17TMO_IGMP_OUTPUT
    1718TMO_ND6_NS_OUTPUT
    1819TMO_ND6_NA_OUTPUT
  • asp3_tinet_ecnl_arm/trunk/asp3_dcre/tinet/tinet_asp.cfg

    r352 r364  
    7373INCLUDE("netinet/if_ether.cfg");
    7474INCLUDE("netinet/ip.cfg");
     75INCLUDE("netinet/ip_igmp.cfg");
    7576INCLUDE("netinet/tcp.cfg");
    7677INCLUDE("netinet/udp.cfg");
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    5959                                                        <option id="com.renesas.cdt.managedbuild.gcc.rz.option.warnStack.606825282" 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"/>
    6060                                                        <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform.1276126881" isAbstract="false" osList="all" superClass="ilg.gnuarmeclipse.managedbuild.cross.targetPlatform"/>
    61                                                         <builder buildPath="${workspace_loc:/bnep_bridge}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.691118394" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="false" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
     61                                                        <builder buildPath="${workspace_loc:/bnep_bridge}/Debug" id="com.renesas.cdt.managedbuild.gcc.rz.builder.691118394" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="GCC for Renesas Builder" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.renesas.cdt.managedbuild.gcc.rz.builder"/>
    6262                                                        <tool id="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler.1838763743" name="Cross ARM GNU Assembler" superClass="com.renesas.cdt.managedbuild.gcc.rz.tool.assembler">
    6363                                                                <option id="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor.1323004654" name="Use preprocessor" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.assembler.usepreprocessor" useByScannerDiscovery="false" value="true" valueType="boolean"/>
     
    127127                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    128128                                <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"/>
    130130                        </storageModule>
    131131                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/Debug/Makefile

    r352 r364  
    153153endif
    154154
     155TINETDIR =
     156
    155157#
    156158#  mbedサービスの定義
     
    180182        -I$(SRCDIR)/../usbhost/src \
    181183        $(INCLUDES)
    182 LDFLAGS := $(LDFLAGS) -Wl,-Map=$(OBJNAME).map,--cref -L.
     184LDFLAGS := $(LDFLAGS) -L.
    183185LIBS := $(LIBS) $(CXXLIBS)
    184186CFLAGS = $(COPTS) $(CDEFS) $(INCLUDES)
    185187
    186 APPLDIRS := $(APPLDIRS) ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src
    187 APPL_COBJS := $(APPL_COBJS) ntshell_main.o fdtable.o io_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
    188 
    189188#
    190189#  アプリケーションプログラムに関する定義
    191190#
    192191APPLNAME = bnep_bridge
    193 APPLDIRS := $(APPLDIRS) ../src
     192APPLDIRS = ../src ../../ntshell/tlsf ../../ntshell/fatfs ../../ntshell/ntshell ../../ntshell/ntshell/core ../../ntshell/ntshell/util ../../ntshell/src $(SRCDIR)/$(TINETDIR)/netapp
    194193APPL_CFG = main.cfg
    195194APPL_CDL = main.cdl
     195
     196APPL_COBJS := $(APPL_COBJS) ntshell_main.o fdtable.o io_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
    196197
    197198APPL_DIRS := $(APPLDIRS) $(SRCDIR)/library
     
    210211endif
    211212
    212 TINETDIR =
    213213ifdef TINETDIR
    214214        #
     
    216216        #
    217217        NO_USE_TINET_LIBRARY = true
    218        
     218
    219219        #  ネットワークインタフェースの選択、何れか一つ選択する。
    220220        NET_IF = ether
    221        
     221
    222222        #  イーサネット・ディバイスドライバの選択
    223223        NET_DEV = if_mbed
     
    430430
    431431#
     432#  並列makeのための依存関係の定義
     433#
     434$(APPL_OBJS) $(filter-out $(CFG_DMY), $(SYSSVC_OBJS)): | kernel_cfg.timestamp
     435$(APPL_ASMOBJS) $(filter-out $(CFG_DMY), $(SYSSVC_ASMOBJS)) $(KERNEL_ASMOBJS) $(CFG_ASMOBJS): \
     436                                                                                                                | offset.timestamp
     437
     438#
    432439#  特別な依存関係の定義
    433440#
     
    438445#
    439446$(OBJFILE): $(ALL_OBJS) $(LIBS_DEP)
    440         $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) \
     447        $(LINK) $(CFLAGS) $(LDFLAGS) $(OBJ_LDFLAGS) -o $(OBJFILE) -Wl,-Map=$(OBJNAME).map,--cref \
    441448                        $(START_OBJS) $(APPL_OBJS) $(SYSSVC_OBJS) $(CFG_OBJS) \
    442449                        -Wl,--start-group $(ALL_LIBS) -Wl,--end-group $(END_OBJS)
  • asp3_tinet_ecnl_arm/trunk/bnep_bridge/src/main.c

    r359 r364  
    118118static void main_timeout();
    119119
     120extern int ntshell_exit;
     121
    120122int uart_read(char *buf, int cnt, void *extobj)
    121123{
    122         return serial_rea_dat(SIO_PORTID, (char *)buf, cnt);
     124        struct main_t *obj = (struct main_t *)extobj;
     125        int result;
     126        ER ret;
     127        int timer;
     128
     129        obj->prev = obj->now;
     130
     131        /* タイマー取得 */
     132        timer = main_get_timer();
     133
     134        /* 待ち */
     135        ret = serial_trea_dat(SIO_PORTID, buf, cnt, timer);
     136        if ((ret < 0) && (ret != E_OK) && (ret != E_TMOUT)) {
     137                syslog(LOG_NOTICE, "tslp_tsk ret: %s %d", itron_strerror(ret), timer);
     138                ntshell_exit = 1;
     139                return -1;
     140        }
     141        result = (int)ret;
     142
     143        ret = get_tim(&obj->now);
     144        if (ret != E_OK) {
     145                syslog(LOG_NOTICE, "get_tim ret: %s", itron_strerror(ret));
     146                ntshell_exit = 1;
     147                return -1;
     148        }
     149
     150                        /* 時間経過 */
     151        int elapse = obj->now - obj->prev;
     152        main_progress(elapse);
     153
     154        /* タイムアウト処理 */
     155        main_timeout();
     156
     157        return result;
    123158}
    124159
     
    126161{
    127162        return serial_wri_dat(SIO_PORTID, buf, cnt);
    128 }
    129 
    130 unsigned char ntstdio_xi(struct ntstdio_t *handle)
    131 {
    132         char buf[1];
    133         if(serial_rea_dat(SIO_PORTID, buf, 1) != 1)
    134                 return -EIO;
    135         return buf[0];
    136 }
    137 
    138 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
    139 {
    140         char buf[1];
    141         buf[0] = c;
    142         serial_wri_dat(SIO_PORTID, buf, 1);
    143163}
    144164
     
    155175        main_initialize();
    156176
    157         ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, NULL);
     177        ntshell_init(&ntshell, uart_read, uart_write, cmd_execute, &main_obj);
    158178        ntshell_set_prompt(&ntshell, "NTShell>");
    159179        ntshell_execute(&ntshell);
     
    173193        ER ret;
    174194
    175         ntshell_task_init();
     195#ifdef TOPPERS_OMIT_TECS
     196        serial_opn_por(SIO_PORTID);
     197#endif
     198        serial_ctl_por(SIO_PORTID, IOCTL_FCSND | IOCTL_FCRCV);
     199
     200        ntshell_task_init(uart_read, uart_write, &main_obj);
    176201
    177202        main_obj.timer = TMO_FEVR;
  • asp3_tinet_ecnl_arm/trunk/btstack/.cproject

    r352 r364  
    2222                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2323                                <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"/>
    2525                        </storageModule>
    2626                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    136136                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    137137                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    138                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     138                                <option id="toolchain.version" value="6.3.1.20170620"/>
    139139                        </storageModule>
    140140                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/curl-7.57.0/.cproject

    r352 r364  
    2424                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2525                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    26                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     26                                <option id="toolchain.version" value="6.3.1.20170620"/>
    2727                        </storageModule>
    2828                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    8080                                                                        <listOptionValue builtIn="false" value="HAVE_CONFIG_H"/>
    8181                                                                        <listOptionValue builtIn="false" value="BUILDING_LIBCURL"/>
     82                                                                        <listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
    8283                                                                </option>
     84                                                                <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="true" id="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files.169831869" name="Include files (-include)" superClass="ilg.gnuarmeclipse.managedbuild.cross.option.c.compiler.include.files" useByScannerDiscovery="false" valueType="includeFiles"/>
    8385                                                                <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.1041134774" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
    8486                                                        </tool>
     
    145147                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    146148                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    147                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     149                                <option id="toolchain.version" value="6.3.1.20170620"/>
    148150                        </storageModule>
    149151                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/curl-7.57.0/lib/curl_config.h

    r352 r364  
    44/* Location of default ca bundle */
    55/* #undef CURL_CA_BUNDLE */
     6#define CURL_CA_BUNDLE "0:/certs/ca-bundle.crt"
    67
    78/* define "1" to use built in CA store of SSL library */
     
    573574
    574575/* Define to 1 if you have the signal function. */
    575 #define HAVE_SIGNAL 1
     576/* #undef HAVE_SIGNAL */
    576577
    577578/* Define to 1 if you have the <signal.h> header file. */
     
    948949
    949950/* If you want to build curl with the built-in manual */
    950 #define USE_MANUAL 1
     951/* #undef USE_MANUAL */
    951952
    952953/* if mbedTLS is enabled */
  • asp3_tinet_ecnl_arm/trunk/curl-7.57.0/lib/mprintf.c

    r352 r364  
    997997{
    998998        unsigned int r, i, j, w, f;
    999         unsigned long v;
     999        unsigned long long v;
    10001000        char s[16], c, d, *p;
    10011001
     
    10221022                        w = w * 10 + c - '0';
    10231023                if (c == 'l' || c == 'L') {     /* Prefix: Size is long int */
    1024                         f |= 4; c = *fmt++;
     1024                        c = *fmt++;
     1025                        if (c == 'l' || c == 'L') {     /* Prefix: Size is long int */
     1026                                f |= 32; c = *fmt++;
     1027                        }
     1028                        else {
     1029                                f |= 4;
     1030                        }
    10251031                }
    10261032                else if (c == 'h') {    /* Prefix: Size is short int */
     
    10551061
    10561062                /* Get an argument and put it in numeral */
    1057                 v = (f & 4) ? va_arg(arp, long)
    1058                         : ((f & 16) ? ((d == 'D') ? (long)((short)va_arg(arp, int)) : (long)((unsigned short)va_arg(arp, unsigned int)))
    1059                                 : ((d == 'D') ? (long)va_arg(arp, int) : (long)va_arg(arp, unsigned int)));
    1060                 if (d == 'D' && (v & 0x80000000)) {
     1063                if (f & 4)
     1064                        v = (long long)va_arg(arp, long);
     1065                else if (f & 16)
     1066                        v = (d == 'D') ? (long long)((short)va_arg(arp, int)) : (long long)((unsigned short)va_arg(arp, unsigned int));
     1067                else if (f & 32)
     1068                        v = (d == 'D') ? (long long)(va_arg(arp, long long)) : (long long)(va_arg(arp, unsigned long long));
     1069                else
     1070                        v = (d == 'D') ? (long long)va_arg(arp, int) : (long long)va_arg(arp, unsigned int);
     1071                if (d == 'D' && (v & 0x8000000000000000ll)) {
    10611072                        v = 0 - v;
    10621073                        f |= 8;
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/.cproject

    r352 r364  
    2424                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2525                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    26                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     26                                <option id="toolchain.version" value="6.3.1.20170620"/>
    2727                        </storageModule>
    2828                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    151151                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    152152                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    153                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     153                                <option id="toolchain.version" value="6.3.1.20170620"/>
    154154                        </storageModule>
    155155                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/arch/arm/syscall_arch.h

    r352 r364  
    8383long __syscall_ret(unsigned long), __syscall_nr(long nr, ...);
    8484
    85 #define __syscall(n, ...) n(__VA_ARGS__)
    86 #define __syscall_cp(n, ...) n(__VA_ARGS__)
    87 #define syscall(n, ...) __syscall_ret(__syscall(n, __VA_ARGS__))
    88 #define syscall_cp(n, ...) __syscall_ret(__syscall_cp(n, __VA_ARGS__))
     85#define __syscall0(n) n()
     86#define __syscall1(n,a) n(__scc(a))
     87#define __syscall2(n,a,b) n(__scc(a),__scc(b))
     88#define __syscall3(n,a,b,c) n(__scc(a),__scc(b),__scc(c))
     89#define __syscall4(n,a,b,c,d) n(__scc(a),__scc(b),__scc(c),__scc(d))
     90#define __syscall5(n,a,b,c,d,e) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
     91#define __syscall6(n,a,b,c,d,e,f) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
     92#define __syscall7(n,a,b,c,d,e,f,g) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
    8993
    90 #define __syscall2(n, ...) n(__VA_ARGS__)
    91 #define __syscall3(n, ...) n(__VA_ARGS__)
    92 #define __syscall_cp2(n, ...) n(__VA_ARGS__)
    93 #define __syscall_cp3(n, ...) n(__VA_ARGS__)
     94#define __syscall_cp0(n) n()
     95#define __syscall_cp1(n,a) n(__scc(a))
     96#define __syscall_cp2(n,a,b) n(__scc(a),__scc(b))
     97#define __syscall_cp3(n,a,b,c) n(__scc(a),__scc(b),__scc(c))
     98#define __syscall_cp4(n,a,b,c,d) n(__scc(a),__scc(b),__scc(c),__scc(d))
     99#define __syscall_cp5(n,a,b,c,d,e) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e))
     100#define __syscall_cp6(n,a,b,c,d,e,f) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
     101#define __syscall_cp7(n,a,b,c,d,e,f,g) n(__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f),__scc(g))
     102
     103#define __SYSCALL_NARGS_X(a,b,c,d,e,f,g,h,n,...) n
     104#define __SYSCALL_NARGS(...) __SYSCALL_NARGS_X(__VA_ARGS__,7,6,5,4,3,2,1,0,)
     105#define __SYSCALL_CONCAT_X(a,b) a##b
     106#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
     107#define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
    94108#endif
  • asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/internal/syscall.h

    r352 r364  
    5050#define __SYSCALL_CONCAT(a,b) __SYSCALL_CONCAT_X(a,b)
    5151#define __SYSCALL_DISP(b,...) __SYSCALL_CONCAT(b,__SYSCALL_NARGS(__VA_ARGS__))(__VA_ARGS__)
    52 #if 0
     52
    5353#define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__)
    5454#define syscall(...) __syscall_ret(__syscall(__VA_ARGS__))
    55 #endif
     55
    5656#define socketcall __socketcall
    5757#define socketcall_cp __socketcall_cp
     
    6464#define __syscall_cp5(n,a,b,c,d,e) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),0)
    6565#define __syscall_cp6(n,a,b,c,d,e,f) (__syscall_cp)(n,__scc(a),__scc(b),__scc(c),__scc(d),__scc(e),__scc(f))
    66 
     66#endif
    6767#define __syscall_cp(...) __SYSCALL_DISP(__syscall_cp,__VA_ARGS__)
    6868#define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__))
    69 #endif
    7069
    7170#ifndef SYSCALL_USE_SOCKETCALL
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.c

    r352 r364  
    5656
    5757/*
     58 * インスタンスリスト通知の送信
     59 */
     60ER ecn_ntf_inl()
     61{
     62        return _ecn_tsk_ntf_inl();
     63}
     64
     65/*
    5866 * ECHONETオブジェクト参照
    5967 * 引数
     
    393401                return E_PAR;
    394402
    395         a_ret = trcv_dtq(ecn_api_mailboxid, (intptr_t *)&p_msg, fa_tmout);
     403        a_ret = trcv_dtq(ecn_api_dataqueueid, (intptr_t *)&p_msg, fa_tmout);
    396404        if (a_ret != E_OK) {
    397405                *ppk_esv = NULL;
     
    425433        a_ret = _ecn_fbs_del(a_fbs);
    426434        return a_ret;
     435}
     436
     437/*
     438 * 応答電文の送信元ノードを取得する
     439 */
     440ID ecn_get_enod(T_EDATA *pk_esv)
     441{
     442        const EOBJCB    *p_snod;
     443        const EOBJINIB  *p_sobj = NULL;
     444
     445        p_snod = _ecn_eno_fnd(((T_ECN_FST_BLK *)pk_esv)->hdr.sender.id);
     446        if (p_snod != NULL) {
     447                p_sobj = p_snod->profile;
     448        }
     449
     450        if (p_sobj == NULL)
     451                return EOBJ_NULL;
     452#ifdef ECHONET_CONTROLLER_EXTENTION
     453        if (p_sobj->eprpcnt == 0)
     454                return ecn_agent_get_eobj(p_sobj);
     455#endif
     456        return 1 + (((intptr_t)p_sobj - (intptr_t)eobjinib_table) / sizeof(EOBJINIB));
    427457}
    428458
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.h

    r352 r364  
    6767typedef enum _echonet_enod_id
    6868{
    69         ENOD_NOT_MATCH_ID       = -1,
     69        ENOD_NOT_MATCH_ID       = -1,                   /* アドレスID登録なし */
    7070        ENOD_MULTICAST_ID       = 0,                    /* マルチキャストアドレスID */
    7171        ENOD_LOCAL_ID           = 1,                    /* 自ノードアドレスID */
     
    279279extern const ID ecn_svc_taskid;
    280280extern const ID ecn_udp_taskid;
    281 extern const ID ecn_api_mailboxid;
    282 extern const ID ecn_svc_mailboxid;
    283 extern const ID ecn_udp_mailboxid;
     281extern const ID ecn_api_dataqueueid;
     282extern const ID ecn_svc_dataqueueid;
     283extern const ID ecn_udp_dataqueueid;
    284284#ifndef ECHONET_USE_MALLOC
    285285extern const ID ecn_mempoolid;
     
    309309
    310310/*
     311 * インスタンスリスト通知の送信
     312 */
     313ER ecn_ntf_inl();
     314
     315/*
    311316 * ECHONETオブジェクト参照
    312317 */
     
    392397 */
    393398ER ecn_rel_esv(T_EDATA *pk_esv);
     399
     400/*
     401 * 応答電文の送信元ノードを取得する
     402 */
     403ID ecn_get_enod(T_EDATA *pk_esv);
    394404
    395405/*
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet.trb

    r352 r364  
    634634const ID _echonet_ecn_svc_taskid = ECHONET_SVC_TASK;
    635635const ID _echonet_ecn_udp_taskid = ECHONET_UDP_TASK;
    636 const ID _echonet_ecn_api_mailboxid = ECHONET_API_MAILBOX;
    637 const ID _echonet_ecn_svc_mailboxid = ECHONET_SVC_MAILBOX;
    638 const ID _echonet_ecn_udp_mailboxid = ECHONET_UDP_MAILBOX;
     636const ID _echonet_ecn_api_dataqueueid = ECHONET_API_DATAQUEUE;
     637const ID _echonet_ecn_svc_dataqueueid = ECHONET_SVC_DATAQUEUE;
     638const ID _echonet_ecn_udp_dataqueueid = ECHONET_UDP_DATAQUEUE;
    639639#ifndef ECHONET_USE_MALLOC
    640640const ID _echonet_ecn_mempoolid = ECHONET_MEMPOOL;
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_asp.cfg

    r352 r364  
    5151
    5252/*
    53  * ECHONET Lite API用メールボックス
     53 * ECHONET Lite API用データキュー
    5454 */
    55 CRE_DTQ(ECHONET_API_MAILBOX, { TA_TFIFO, 1, NULL });
     55CRE_DTQ(ECHONET_API_DATAQUEUE, { TA_TFIFO, ECHONET_API_DATAQUEUE_COUNT, NULL });
    5656
    5757/*
    58  * ECHONET Lite サービス処理タスク用メールボックス
     58 * ECHONET Lite サービス処理タスク用データキュー
    5959 */
    60 CRE_DTQ(ECHONET_SVC_MAILBOX, { TA_TFIFO, 1, NULL });
     60CRE_DTQ(ECHONET_SVC_DATAQUEUE, { TA_TFIFO, ECHONET_SVC_DATAQUEUE_COUNT, NULL });
    6161
    6262/*
     
    6666
    6767/*
    68  * ECHONET Lite UDP通信処理用メールボックス
     68 * ECHONET Lite UDP通信処理用データキュー
    6969 */
    70 CRE_DTQ(ECHONET_UDP_MAILBOX, { TA_TFIFO, 1, NULL });
     70CRE_DTQ(ECHONET_UDP_DATAQUEUE, { TA_TFIFO, ECHONET_UDP_DATAQUEUE_COUNT, NULL });
    7171
    7272/*
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_rename.h

    r352 r364  
    4747#define ecn_svc_taskid          _echonet_ecn_svc_taskid
    4848#define ecn_udp_taskid          _echonet_ecn_udp_taskid
    49 #define ecn_api_mailboxid       _echonet_ecn_api_mailboxid
    50 #define ecn_svc_mailboxid       _echonet_ecn_svc_mailboxid
    51 #define ecn_udp_mailboxid       _echonet_ecn_udp_mailboxid
     49#define ecn_api_dataqueueid     _echonet_ecn_api_dataqueueid
     50#define ecn_svc_dataqueueid     _echonet_ecn_svc_dataqueueid
     51#define ecn_udp_dataqueueid     _echonet_ecn_udp_dataqueueid
    5252#define ecn_mempoolid           _echonet_ecn_mempoolid
    5353#define ecn_udp_cepid           _echonet_ecn_udp_cepid
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_task.c

    r352 r364  
    7777static bool_t g_release_esv;
    7878
    79 ER _ecn_tsk_ntf_inl(intptr_t fa_exinf);
    80 
    8179ER _ecn_tsk_snd_dtq(ECN_FBS_ID fa_rsp_fbs, bool_t from_app)
    8280{
    8381        ER      a_ret;
    8482        T_MSG *msg = (T_MSG *)fa_rsp_fbs.ptr;
    85         ID dtqid = ecn_udp_mailboxid;
     83        ID dtqid = ecn_udp_dataqueueid;
    8684        int i;
    8785#ifdef ECN_DBG_PUT_ENA
     
    9088        if (from_app && (((T_EDATA *)fa_rsp_fbs.ptr)->hdr.edata.esv == ESV_INFC)) {
    9189                g_api_tid = ((T_EDATA *)fa_rsp_fbs.ptr)->hdr.ecn_hdr.tid;
    92                 dtqid = ecn_svc_mailboxid;
     90                dtqid = ecn_svc_dataqueueid;
    9391        }
    9492        else {
     
    9896                                g_api_tid = ((T_EDATA *)fa_rsp_fbs.ptr)->hdr.ecn_hdr.tid;
    9997
    100                         dtqid = ecn_udp_mailboxid;
     98                        dtqid = ecn_udp_dataqueueid;
    10199                        break;
    102100                case ENOD_LOCAL_ID:
    103101                        if (from_app)
    104                                 dtqid = ecn_svc_mailboxid;
     102                                dtqid = ecn_svc_dataqueueid;
    105103                        else
    106                                 dtqid = ecn_api_mailboxid;
     104                                dtqid = ecn_api_dataqueueid;
    107105                        break;
    108106                case ENOD_API_ID:
    109                         dtqid = ecn_api_mailboxid;
     107                        dtqid = ecn_api_dataqueueid;
    110108                        break;
    111109                default:
     
    121119                                switch (eobjcb_table[i].profile->eobjatr) {
    122120                                case EOBJ_SYNC_REMOTE_NODE:
    123                                         dtqid = ecn_udp_mailboxid;
     121                                        dtqid = ecn_udp_dataqueueid;
    124122                                        break;
    125123                                case EOBJ_ASYNC_REMOTE_NODE:
    126                                         dtqid = ecn_svc_mailboxid;
     124                                        dtqid = ecn_svc_dataqueueid;
    127125                                        break;
    128126                                default:
     
    131129                        }
    132130                        else {
    133                                 dtqid = ecn_udp_mailboxid;
     131                                dtqid = ecn_udp_dataqueueid;
    134132                        }
    135133                        break;
     
    242240#endif
    243241
    244                 a_ret = trcv_dtq(ecn_svc_mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);
     242                a_ret = trcv_dtq(ecn_svc_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer);
    245243                if ((a_ret != E_OK) && (a_ret != E_TMOUT)) {
    246244                        ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret));
     
    867865                g_release_esv = false;
    868866
    869                 ECN_CAP_PUT_1("redirect ecn_svc_mailboxid → ecn_api_mailboxid (esv:0x%02X)",
     867                ECN_CAP_PUT_1("redirect ecn_svc_dataqueueid → ecn_api_dataqueueid (esv:0x%02X)",
    870868                        p_esv->edata.esv);
    871869                fa_fbs_id.ptr->hdr.target.id = ENOD_API_ID;
    872                 a_ret = snd_dtq(ecn_api_mailboxid, (intptr_t)fa_fbs_id.ptr);
     870                a_ret = snd_dtq(ecn_api_dataqueueid, (intptr_t)fa_fbs_id.ptr);
    873871                if (a_ret != E_OK) {
    874872                        syslog(LOG_WARNING, "_ecn_tsk_ecn_msg() : snd_dtq() result = %d:%s", a_ret, itron_strerror(a_ret));
     
    20242022        req.ptr->hdr.type = ECN_MSG_INTERNAL;
    20252023        req.ptr->hdr.sender.dtqid = sender;
    2026         req.ptr->hdr.target.dtqid = ecn_svc_mailboxid;
     2024        req.ptr->hdr.target.dtqid = ecn_svc_dataqueueid;
    20272025        req.ptr->hdr.reply.dtqid = sender;
    20282026
     
    20522050
    20532051        res.ptr->hdr.type = ECN_MSG_INTERNAL;
    2054         res.ptr->hdr.sender.dtqid = ecn_svc_mailboxid;
     2052        res.ptr->hdr.sender.dtqid = ecn_svc_dataqueueid;
    20552053        res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid;
    2056         res.ptr->hdr.reply.dtqid = ecn_svc_mailboxid;
     2054        res.ptr->hdr.reply.dtqid = ecn_svc_dataqueueid;
    20572055
    20582056        *pk_res = res;
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_task.h

    r352 r364  
    110110} T_ECN_INTERNAL_MSG;
    111111
     112/*
     113 * インスタンスリスト通知の送信
     114 */
     115ER _ecn_tsk_ntf_inl();
    112116/*
    113117 * 要求電文作成
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp6_task.c

    r352 r364  
    151151
    152152        /* echonet_taskに送る */
    153         a_ret = snd_dtq(ecn_svc_mailboxid, (intptr_t)a_fbs_id.ptr);
    154         if (a_ret != E_OK) {
    155                 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_mailboxid) result = %d:%s", a_ret, itron_strerror(a_ret));
     153        a_ret = snd_dtq(ecn_svc_dataqueueid, (intptr_t)a_fbs_id.ptr);
     154        if (a_ret != E_OK) {
     155                ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_dataqueueid) result = %d:%s", a_ret, itron_strerror(a_ret));
    156156                goto lb_except;
    157157        }
     
    201201                a_timer = ECHONET_UDP_TASK_GET_TIMER;
    202202
    203                 a_ret = trcv_dtq(ecn_udp_mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);
     203                a_ret = trcv_dtq(ecn_udp_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer);
    204204                if ((a_ret != E_OK) && (a_ret != E_TMOUT)) {
    205205                        ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret));
     
    261261        req.ptr->hdr.type = ECN_MSG_INTERNAL;
    262262        req.ptr->hdr.sender.dtqid = sender;
    263         req.ptr->hdr.target.dtqid = ecn_udp_mailboxid;
     263        req.ptr->hdr.target.dtqid = ecn_udp_dataqueueid;
    264264        req.ptr->hdr.reply.dtqid = sender;
    265265
     
    289289
    290290        res.ptr->hdr.type = ECN_MSG_INTERNAL;
    291         res.ptr->hdr.sender.dtqid = ecn_udp_mailboxid;
     291        res.ptr->hdr.sender.dtqid = ecn_udp_dataqueueid;
    292292        res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid;
    293         res.ptr->hdr.reply.dtqid = ecn_udp_mailboxid;
     293        res.ptr->hdr.reply.dtqid = ecn_udp_dataqueueid;
    294294
    295295        *pk_res = res;
     
    416416                else if (memcmp(&a_dst.ipaddr, &locl, sizeof(a_dst.ipaddr)) == 0) {
    417417                        /* 送信先が127.0.0.1 → dtqに転送 */
    418                         ECN_DBG_PUT_1("redirect ecn_udp_mailboxid → ecn_svc_mailboxid (esv:0x%02X)",
     418                        ECN_DBG_PUT_1("redirect ecn_udp_dataqueueid → ecn_svc_dataqueueid (esv:0x%02X)",
    419419                                ((T_EDATA *)fbs_id.ptr)->hdr.edata.esv);
    420420
     
    462462
    463463        switch (fncd) {
    464         case TFN_UDP_CRE_CEP:
     464        case TEV_UDP_RCV_DAT:
    465465        case TFN_UDP_RCV_DAT:
    466466                /* ECN_CAP_PUT("[UDP ECHO SRV] callback_nblk_udp() recv: %u", *(int *)p_parblk); */
     
    488488                return E_OK;
    489489
     490        case TFN_UDP_CRE_CEP:
    490491        case TFN_UDP_SND_DAT:
    491492                break;
    492493        default:
    493494                ECN_CAP_PUT_2("[UDP ECHO SRV] fncd:0x%04X(%s)", -fncd,
     495                        (fncd == TEV_UDP_RCV_DAT ? "TEV_UDP_RCV_DAT" :
    494496                        (fncd == TFN_UDP_CRE_CEP ? "TFN_UDP_CRE_CEP" :
    495497                        (fncd == TFN_UDP_RCV_DAT ? "TFN_UDP_RCV_DAT" :
    496                         (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef"))));
     498                        (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef")))));
    497499
    498500                error = E_PAR;
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp6_task.h

    r352 r364  
    7171#endif /* ECHONET_UDP_TASK_STACK_SIZE */
    7272
    73 #ifndef NUM_ECHONET_UDP_MAILBOX
    74 #define NUM_ECHONET_UDP_MAILBOX 10
    75 #endif /* NUM_ECHONET_UDP_MAILBOX */
     73#ifndef NUM_ECHONET_UDP_DATAQUEUE
     74#define NUM_ECHONET_UDP_DATAQUEUE       10
     75#endif /* NUM_ECHONET_UDP_DATAQUEUE */
    7676
    7777/*
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp_task.c

    r352 r364  
    146146
    147147        /* echonet_taskに送る */
    148         a_ret = snd_dtq(ecn_svc_mailboxid, (intptr_t)a_fbs_id.ptr);
    149         if (a_ret != E_OK) {
    150                 ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_mailboxid) result = %d:%s", a_ret, itron_strerror(a_ret));
     148        a_ret = snd_dtq(ecn_svc_dataqueueid, (intptr_t)a_fbs_id.ptr);
     149        if (a_ret != E_OK) {
     150                ECN_DBG_PUT_2("[UDP ECHO SRV] snd_dtq(ecn_svc_dataqueueid) result = %d:%s", a_ret, itron_strerror(a_ret));
    151151                goto lb_except;
    152152        }
     
    206206                a_timer = ECHONET_UDP_TASK_GET_TIMER;
    207207
    208                 a_ret = trcv_dtq(ecn_udp_mailboxid, (intptr_t *)&a_mdt.p_msg, a_timer);
     208                a_ret = trcv_dtq(ecn_udp_dataqueueid, (intptr_t *)&a_mdt.p_msg, a_timer);
    209209                if ((a_ret != E_OK) && (a_ret != E_TMOUT)) {
    210210                        ECN_DBG_PUT_2("trcv_dtq() result = %d:%s", a_ret, itron_strerror(a_ret));
     
    266266        req.ptr->hdr.type = ECN_MSG_INTERNAL;
    267267        req.ptr->hdr.sender.dtqid = sender;
    268         req.ptr->hdr.target.dtqid = ecn_udp_mailboxid;
     268        req.ptr->hdr.target.dtqid = ecn_udp_dataqueueid;
    269269        req.ptr->hdr.reply.dtqid = sender;
    270270
     
    294294
    295295        res.ptr->hdr.type = ECN_MSG_INTERNAL;
    296         res.ptr->hdr.sender.dtqid = ecn_udp_mailboxid;
     296        res.ptr->hdr.sender.dtqid = ecn_udp_dataqueueid;
    297297        res.ptr->hdr.target.dtqid = req.ptr->hdr.reply.dtqid;
    298         res.ptr->hdr.reply.dtqid = ecn_udp_mailboxid;
     298        res.ptr->hdr.reply.dtqid = ecn_udp_dataqueueid;
    299299
    300300        *pk_res = res;
     
    420420                else if (a_dst.ipaddr == MAKE_IPV4_ADDR(127,0,0,1)) {
    421421                        /* 送信先が127.0.0.1 → dtqに転送 */
    422                         ECN_DBG_PUT_1("redirect ecn_udp_mailboxid → ecn_svc_mailboxid (esv:0x%02X)",
     422                        ECN_DBG_PUT_1("redirect ecn_udp_dataqueueid → ecn_svc_dataqueueid (esv:0x%02X)",
    423423                                ((T_EDATA *)fbs_id.ptr)->hdr.edata.esv);
    424424
     
    466466
    467467        switch (fncd) {
    468         case TFN_UDP_CRE_CEP:
     468        case TEV_UDP_RCV_DAT:
    469469        case TFN_UDP_RCV_DAT:
    470470                /* ECN_CAP_PUT("[UDP ECHO SRV] callback_nblk_udp() recv: %u", *(int *)p_parblk); */
     
    492492                return E_OK;
    493493
     494        case TFN_UDP_CRE_CEP:
    494495        case TFN_UDP_SND_DAT:
    495496                break;
    496497        default:
    497498                ECN_CAP_PUT_2("[UDP ECHO SRV] fncd:0x%04X(%s)", -fncd,
     499                        (fncd == TEV_UDP_RCV_DAT ? "TEV_UDP_RCV_DAT" :
    498500                        (fncd == TFN_UDP_CRE_CEP ? "TFN_UDP_CRE_CEP" :
    499501                        (fncd == TFN_UDP_RCV_DAT ? "TFN_UDP_RCV_DAT" :
    500                         (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef"))));
     502                        (fncd == TFN_UDP_SND_DAT ? "TFN_UDP_SND_DAT" : "undef")))));
    501503
    502504                error = E_PAR;
  • asp3_tinet_ecnl_arm/trunk/ntshell/echonet/echonet_udp_task.h

    r352 r364  
    7171#endif /* ECHONET_UDP_TASK_STACK_SIZE */
    7272
    73 #ifndef NUM_ECHONET_UDP_MAILBOX
    74 #define NUM_ECHONET_UDP_MAILBOX 10
    75 #endif /* NUM_ECHONET_UDP_MAILBOX */
     73#ifndef NUM_ECHONET_UDP_DATAQUEUE
     74#define NUM_ECHONET_UDP_DATAQUEUE       10
     75#endif /* NUM_ECHONET_UDP_DATAQUEUE */
    7676
    7777/*
  • asp3_tinet_ecnl_arm/trunk/ntshell/fatfs/ffarch.h

    r359 r364  
    4141#define FFARCH_STACK_SIZE               512
    4242
    43 void ffarch_init();
     43void ffarch_init(void);
    4444void ffarch_task(intptr_t exinf);
    45 int ffarch_get_timer();
     45int ffarch_get_timer(void);
    4646void ffarch_progress(int elapse);
    47 void ffarch_timeout();
     47void ffarch_timeout(void);
    4848
    4949void sdfs_cychdr(intptr_t exinf);
  • asp3_tinet_ecnl_arm/trunk/ntshell/lcd/draw_font.c

    r352 r364  
    11/*
    22 *  TOPPERS ECHONET Lite Communication Middleware
    3  * 
     3 *
    44 *  Copyright (C) 2018 Cores Co., Ltd. Japan
    5  * 
     5 *
    66 *  上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
    77 *  ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
     
    2626 *      由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
    2727 *      免責すること.
    28  * 
     28 *
    2929 *  本ソフトウェアは,無保証で提供されているものである.上記著作権者お
    3030 *  よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
     
    3232 *  アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
    3333 *  の責任を負わない.
    34  * 
     34 *
    3535 *  @(#) $Id$
    3636 */
     
    4141#include <string.h>
    4242#include <target_syssvc.h>
     43#ifndef ADAFRUIT_SSD1306
    4344#include "adafruit_st7735.h"
     45#else
     46#include "adafruit_ssd1306.h"
     47#endif
    4448#include "draw_font.h"
    45 #include "misaki_font.h"
    46 
    47 void get_bitmap_font(char *string, unsigned char *bitmap_data, unsigned long *use_chars)
    48 {
    49         unsigned long len, code;
    50         unsigned char i,j,k;
    51         unsigned long totalj, totalk;
     49
     50void get_bitmap_font(const uint8_t *string, uint8_t *bitmap_data, uint32_t *use_chars)
     51{
     52        uint32_t len, code;
     53        uint8_t i, j, k;
     54        uint32_t totalj, totalk;
    5255
    5356        *use_chars = 0;
    5457        len = 0;
    55         if      ((string[0] & 0x80) ==    0) { len = 1; }
     58        if ((string[0] & 0x80) == 0) { len = 1; }
    5659        else if ((string[0] & 0xE0) == 0xC0) { len = 2; }
    5760        else if ((string[0] & 0xF0) == 0xE0) { len = 3; }
    5861        else if ((string[0] & 0xF8) == 0xF0) { len = 4; }
    59         else { return;  }
     62        else { return; }
    6063
    6164        j = k = totalj = totalk = 0;
    6265
    63         if( len == 1 ) {
     66        if (len == 1) {
    6467                code = string[0];
    65                 memcpy(bitmap_data, &UTF8_1B_CODE_BITMAP[code][0], 8 );
     68                memcpy(bitmap_data, &UTF8_1B_CODE_BITMAP[code][0], FONT_WIDTH * FONT_HEIGHT / 8);
    6669                *use_chars = 1;
    6770                return;
    6871        }
    6972
    70         if( len == 2 ) {
     73        if (len == 2) {
    7174                code = string[0];
    7275                // 1バイト目サーチ
    73                 for(i = 0; i < UTF8_CODE_2B_1_NUM; i++ ) {
    74                         if ( Utf8CodeTable_2B_1st[i][0] == code ) {
     76                for (i = 0; i < UTF8_CODE_2B_1_NUM; i++) {
     77                        if (Utf8CodeTable_2B_1st[i][0] == code) {
    7578                                code = string[1];
    76                                 for( j = 0; j < Utf8CodeTable_2B_1st[i][1]; j++ ) {
    77                                         if ( UTF8_2B_CODE_BITMAP[totalk].code == code ) {
    78                                                 memcpy(bitmap_data, UTF8_2B_CODE_BITMAP[totalk].bitmap, 8 );
     79                                for (j = 0; j < Utf8CodeTable_2B_1st[i][1]; j++) {
     80                                        if (UTF8_2B_CODE_BITMAP[totalk].code == code) {
     81                                                memcpy(bitmap_data, UTF8_2B_CODE_BITMAP[totalk].bitmap, FONT_WIDTH * FONT_HEIGHT / 8);
    7982                                                *use_chars = 2;
    8083                                                return;
     
    9093        }
    9194
    92         if( len == 3 ) {
     95        if (len == 3) {
    9396                code = string[0];
    9497                // 1バイト目サーチ
    95                 for(i = 0; i < UTF8_CODE_3B_1_NUM; i++ ) {
    96                         if ( Utf8CodeTable_3B_1st[i][0] == code ) {
     98                for (i = 0; i < UTF8_CODE_3B_1_NUM; i++) {
     99                        if (Utf8CodeTable_3B_1st[i][0] == code) {
    97100                                code = string[1];
    98101                                // 2バイト目サーチ
    99                                 for( j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++ ){
    100                                         if ( Utf8CodeTable_3B_2nd[totalj][0] == code ) {
     102                                for (j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++) {
     103                                        if (Utf8CodeTable_3B_2nd[totalj][0] == code) {
    101104                                                code = string[2];
    102105                                                // 3バイト目サーチ
    103                                                 for( k = 0; k < Utf8CodeTable_3B_2nd[totalj][1]; k++) {
     106                                                for (k = 0; k < Utf8CodeTable_3B_2nd[totalj][1]; k++) {
    104107                                                        if (UTF8_3B_CODE_BITMAP[totalk].code == code) {
    105                                                                 memcpy(bitmap_data, UTF8_3B_CODE_BITMAP[totalk].bitmap, 8 );
     108                                                                memcpy(bitmap_data, UTF8_3B_CODE_BITMAP[totalk].bitmap, FONT_WIDTH * FONT_HEIGHT / 8);
    106109                                                                *use_chars = 3;
    107110                                                                return;
     
    111114                                                return;
    112115                                        }
    113                                         else{/*読み飛ばすbitmap個数を蓄積*/
     116                                        else {/*読み飛ばすbitmap個数を蓄積*/
    114117                                                totalk += Utf8CodeTable_3B_2nd[totalj][1];
    115118                                        }
     
    118121                        }
    119122                        else {/*読み飛ばすbitmap個数を蓄積*/
    120                                 for( j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++ ) {
     123                                for (j = 0; j < Utf8CodeTable_3B_1st[i][1]; j++) {
    121124                                        totalk += Utf8CodeTable_3B_2nd[totalj][1];
    122125                                        totalj++;
     
    128131}
    129132
    130 void lcd_drawFont(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color)
    131 {
    132         int i, j;
    133 
    134         for(i = 0; i < 8; i++ ) {
    135                 for(j = 0; j < 8; j++ ) {
    136                         if (((bitmap_data[i] >> j) & 0x01) == 1){
    137                                 lcd_drawPixel(hlcd, x - j, y + i, color);
     133void lcd_drawFont(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color)
     134{
     135        int i, j, b;
     136        uint8_t *bitmap = bitmap_data;
     137
     138        b = 0x80;
     139        for (i = 0; i < FONT_HEIGHT; i++) {
     140                for (j = 0; j < FONT_WIDTH; j++) {
     141                        if ((*bitmap & b) != 0) {
     142                                lcd_drawPixel(hlcd, x + j, y + i, color);
    138143                        }
    139144                        else {
    140                                 lcd_drawPixel(hlcd, x - j, y + i, back_color);
    141                         }
    142                 }
    143         }
    144 }
    145 
    146 void lcd_drawFontHalf(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color)
    147 {
    148         int i, j;
    149 
    150         for(i = 0; i < 8; i++ ) {
    151                 for(j = 4; j < 8; j++ ) {
    152                         if (((bitmap_data[i] >> j) & 0x01) == 1){
    153                                 lcd_drawPixel(hlcd, x - j, y + i, color);
     145                                lcd_drawPixel(hlcd, x + j, y + i, back_color);
     146                        }
     147                        b >>= 1;
     148                        if (b == 0) {
     149                                b = 0x80;
     150                                bitmap++;
     151                        }
     152                }
     153        }
     154}
     155
     156void lcd_drawFontHalf(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color)
     157{
     158        int i, j, b;
     159        uint8_t *bitmap = bitmap_data;
     160
     161        b = 0x80;
     162        for (i = 0; i < FONT_HEIGHT; i++) {
     163                for (j = 0; j < FONT_HALF_WIDTH; j++) {
     164                        if ((*bitmap & b) != 0) {
     165                                lcd_drawPixel(hlcd, x + j, y + i, color);
    154166                        }
    155167                        else {
    156                                 lcd_drawPixel(hlcd, x - j, y + i, back_color);
    157                         }
    158                 }
    159         }
    160 }
    161 
    162 void lcd_drawString(LCD_Handler_t *hlcd, char *string, int x, int y, unsigned short color, unsigned short back_color )
    163 {
    164         unsigned long current_top, use_chars, for_3B_hankaku_code;
    165         unsigned char bitmap_data[8], ctrl_code;
    166         int local_x, local_y;
     168                                lcd_drawPixel(hlcd, x + j, y + i, back_color);
     169                        }
     170                        b >>= 1;
     171                        if (b == 0) {
     172                                b = 0x80;
     173                                bitmap++;
     174                        }
     175                }
     176        }
     177}
     178
     179void lcd_drawString(LCD_Handler_t *hlcd, const char *string, int x, int y, uint16_t color, uint16_t back_color)
     180{
     181        uint32_t current_top, use_chars, for_3B_hankaku_code;
     182        uint8_t bitmap_data[FONT_WIDTH * FONT_HEIGHT / 8], ctrl_code;
     183        int local_x, local_y, len = strlen(string);
     184        const uint8_t *code = (const uint8_t *)string;
    167185
    168186        local_x = x;
     
    170188
    171189        current_top = 0;
    172         while( current_top < strlen(string) )
    173         {
    174                 memset(bitmap_data,0x0,8);
    175                 ctrl_code = string[current_top];
    176                 get_bitmap_font(&string[current_top], bitmap_data, &use_chars);
    177                 if(use_chars == 0)
     190        while (current_top < len) {
     191                memset(bitmap_data, 0x0, FONT_WIDTH * FONT_HEIGHT / 8);
     192                ctrl_code = code[current_top];
     193                get_bitmap_font(&code[current_top], bitmap_data, &use_chars);
     194                if (use_chars == 0)
    178195                        return;
    179196
    180197                //3バイトコード半角文字用
    181                 if(use_chars == 3) {
     198                if (use_chars == 3) {
    182199                        for_3B_hankaku_code = 0;
    183                         for_3B_hankaku_code = ( (string[current_top]  << 16) |
    184                                                                     (string[current_top+1] << 8) |
    185                                                                     (string[current_top+2]      )   );
     200                        for_3B_hankaku_code = ((code[current_top] << 16) |
     201                                (code[current_top + 1] << 8) |
     202                                (code[current_top + 2]));
    186203                }
    187204
     
    189206
    190207                //1バイトコード半角文字
    191                 if ( use_chars == 1 ) {
    192                         if(ctrl_code == 0x0D) { // CR
     208                if (use_chars == 1) {
     209                        if (ctrl_code == 0x0D) { // CR
    193210                                local_x = X_LINE_TO_PIX(hlcd, 0);
    194211                                continue;
    195212                        }
    196                         if(ctrl_code == 0x0A) { // LF
    197                                 local_y = local_y + 8;
     213                        if (ctrl_code == 0x0A) { // LF
     214                                local_y = local_y + FONT_HEIGHT;
    198215                                continue;
    199216                        }
    200217
    201                         if ( local_x >= hlcd->_width + 4 ) {
     218                        if (local_x + FONT_HALF_WIDTH > hlcd->_width) {
    202219                                local_x = X_LINE_HALF_TO_PIX(hlcd, 0);
    203                                 local_y = local_y + 8;
     220                                local_y = local_y + FONT_HEIGHT;
    204221                        }
    205222                        lcd_drawFontHalf(hlcd, bitmap_data, local_x, local_y, color, back_color);
    206                         local_x += 4;
     223                        local_x += FONT_HALF_WIDTH;
    207224                        continue;
    208225                }
    209226
    210227                //3バイトコード半角文字
    211                 if( use_chars == 3 ) {
    212                         if (    ( (0xEFBDA1 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBDBF) ) ||
    213                                         ( (0xEFBE80 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBE9F) )      ) {
     228                if (use_chars == 3) {
     229                        if (((0xEFBDA1 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBDBF)) ||
     230                                ((0xEFBE80 <= for_3B_hankaku_code) && (for_3B_hankaku_code <= 0xEFBE9F))) {
    214231                                //3バイトコード半角文字
    215                                 if ( local_x >= hlcd->_width + 4 ) {
     232                                if (local_x + FONT_HALF_WIDTH > hlcd->_width) {
    216233                                        local_x = X_LINE_HALF_TO_PIX(hlcd, 0);
    217                                         local_y = local_y + 8;
     234                                        local_y = local_y + FONT_HEIGHT;
    218235                                }
    219236                                lcd_drawFontHalf(hlcd, bitmap_data, local_x, local_y, color, back_color);
    220                                 local_x += 4;
     237                                local_x += FONT_HALF_WIDTH;
    221238                                continue;
    222239                        }
     
    224241
    225242                //全角文字
    226                 if ( local_x >= hlcd->_width + 8 ) {
     243                if (local_x + FONT_WIDTH > hlcd->_width) {
    227244                        local_x = X_LINE_TO_PIX(hlcd, 0);
    228                         local_y = local_y + 8;
     245                        local_y = local_y + FONT_HEIGHT;
    229246                }
    230247                lcd_drawFont(hlcd, bitmap_data, local_x, local_y, color, back_color);
    231                 local_x += 8;
    232         }
    233 }
    234 
     248                local_x += FONT_WIDTH;
     249        }
     250}
     251
  • asp3_tinet_ecnl_arm/trunk/ntshell/lcd/draw_font.h

    r352 r364  
    3939#define DRAW_FONT_H
    4040
     41#if defined(SHNM16_FONT)
     42#include "shnm16_font.h"
     43#elif defined(SHNM12_FONT)
     44#include "shnm12_font.h"
     45#else
     46#include "misaki_font.h"
     47#endif
     48
    4149#define DISP_X_ADJ      0
    4250#define DISP_Y_ADJ      0
    43 #define X_ZENKAKU_CHARACTERS(hlcd)      ((hlcd)->_width / 8)
    44 #define X_HANKAKU_CHARACTERS(hlcd)      ((hlcd)->_width / 4)
    45 #define Y_CHARACTERS(hlcd)                      ((hlcd)->_height / 8)
    46 #define X_LINE_TO_PIX(hlcd, x)          ((8*(x))-DISP_X_ADJ)
    47 #define X_LINE_HALF_TO_PIX(hlcd, x)     ((4*(x))-DISP_X_ADJ)
    48 #define Y_ROW_TO_PIX(hlcd, y)           ((8*(y))-DISP_Y_ADJ)
     51#define X_ZENKAKU_CHARACTERS(hlcd)      ((hlcd)->_width / FONT_WIDTH)
     52#define X_HANKAKU_CHARACTERS(hlcd)      ((hlcd)->_width / FONT_HALF_WIDTH)
     53#define Y_CHARACTERS(hlcd)                      ((hlcd)->_height / FONT_HEIGHT)
     54#define X_LINE_TO_PIX(hlcd, x)          ((FONT_WIDTH*(x))-DISP_X_ADJ)
     55#define X_LINE_HALF_TO_PIX(hlcd, x)     ((FONT_HALF_WIDTH*(x))-DISP_X_ADJ)
     56#define Y_ROW_TO_PIX(hlcd, y)           ((FONT_HEIGHT*(y))-DISP_Y_ADJ)
    4957
    5058#ifdef __cplusplus
     
    5260#endif
    5361
    54 void get_bitmap_font(char *string, unsigned char *bitmap_data, unsigned long *use_chars);
    55 void lcd_drawFont(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color);
    56 void lcd_drawFontHalf(LCD_Handler_t *hlcd, unsigned char *bitmap_data, int x, int y, unsigned short color, unsigned short back_color);
    57 void lcd_drawString(LCD_Handler_t *hlcd, char *string, int x, int y, unsigned short color, unsigned short back_color );
     62void get_bitmap_font(const uint8_t *string, uint8_t *bitmap_data, uint32_t *use_chars);
     63void lcd_drawFont(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color);
     64void lcd_drawFontHalf(LCD_Handler_t *hlcd, uint8_t *bitmap_data, int x, int y, uint16_t color, uint16_t back_color);
     65void lcd_drawString(LCD_Handler_t *hlcd, const char *string, int x, int y, uint16_t color, uint16_t back_color );
    5866
    5967#ifdef __cplusplus
  • asp3_tinet_ecnl_arm/trunk/ntshell/lcd/misaki_font.c

    r352 r364  
    4646
    4747// 1バイトコード
    48 unsigned char UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][8] = {
    49         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    50         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    51         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    52         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    53         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    54         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    55         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    56         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    57         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    58         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    59         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    60         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    61         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    62         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    63         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    64         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    65         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    66         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    67         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    68         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    69         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    70         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    71         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    72         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    73         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    74         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    75         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    76         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    77         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    78         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    79         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    80         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    81         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    82         {0x40, 0x40, 0x40, 0x40, 0x00, 0x40, 0x00, 0x00},
    83         {0xA0, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    84         {0xA0, 0xE0, 0xA0, 0xA0, 0xE0, 0xA0, 0x00, 0x00},
    85         {0x40, 0xE0, 0xC0, 0x60, 0xE0, 0x40, 0x00, 0x00},
    86         {0x00, 0x80, 0x20, 0x40, 0x80, 0x20, 0x00, 0x00},
    87         {0x40, 0xA0, 0x40, 0x60, 0xC0, 0xE0, 0x00, 0x00},
    88         {0x40, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    89         {0x20, 0x40, 0x40, 0x40, 0x40, 0x40, 0x20, 0x00},
    90         {0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00},
    91         {0x40, 0xE0, 0x40, 0xA0, 0x00, 0x00, 0x00, 0x00},
    92         {0x00, 0x40, 0x40, 0xE0, 0x40, 0x40, 0x00, 0x00},
    93         {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x80, 0x00},
    94         {0x00, 0x00, 0x00, 0xE0, 0x00, 0x00, 0x00, 0x00},
    95         {0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00},
    96         {0x00, 0x00, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00},
    97         {0x00, 0x40, 0xA0, 0xE0, 0xA0, 0x40, 0x00, 0x00},
    98         {0x00, 0x40, 0xC0, 0x40, 0x40, 0xE0, 0x00, 0x00},
    99         {0x00, 0xC0, 0x20, 0x40, 0x80, 0xE0, 0x00, 0x00},
    100         {0x00, 0xC0, 0x20, 0x40, 0x20, 0xC0, 0x00, 0x00},
    101         {0x00, 0x20, 0x60, 0xA0, 0xE0, 0x20, 0x00, 0x00},
    102         {0x00, 0xE0, 0x80, 0xC0, 0x20, 0xC0, 0x00, 0x00},
    103         {0x00, 0x60, 0x80, 0xC0, 0xA0, 0x40, 0x00, 0x00},
    104         {0x00, 0xE0, 0x20, 0x40, 0x40, 0x40, 0x00, 0x00},
    105         {0x00, 0x40, 0xA0, 0x40, 0xA0, 0x40, 0x00, 0x00},
    106         {0x00, 0x40, 0xA0, 0x60, 0x20, 0xC0, 0x00, 0x00},
    107         {0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x00, 0x00},
    108         {0x00, 0x00, 0x40, 0x00, 0x00, 0x40, 0x80, 0x00},
    109         {0x00, 0x20, 0x40, 0x80, 0x40, 0x20, 0x00, 0x00},
    110         {0x00, 0x00, 0xE0, 0x00, 0xE0, 0x00, 0x00, 0x00},
    111         {0x00, 0x80, 0x40, 0x20, 0x40, 0x80, 0x00, 0x00},
    112         {0x40, 0xA0, 0x20, 0x40, 0x00, 0x40, 0x00, 0x00},
    113         {0x40, 0xA0, 0x20, 0x60, 0xA0, 0x40, 0x00, 0x00},
    114         {0x40, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0x00, 0x00},
    115         {0xC0, 0xA0, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},
    116         {0x60, 0x80, 0x80, 0x80, 0x80, 0x60, 0x00, 0x00},
    117         {0xC0, 0xA0, 0xA0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},
    118         {0xE0, 0x80, 0xC0, 0x80, 0x80, 0xE0, 0x00, 0x00},
    119         {0xE0, 0x80, 0xC0, 0x80, 0x80, 0x80, 0x00, 0x00},
    120         {0x60, 0x80, 0x80, 0xA0, 0xA0, 0x60, 0x00, 0x00},
    121         {0xA0, 0xA0, 0xA0, 0xE0, 0xA0, 0xA0, 0x00, 0x00},
    122         {0xE0, 0x40, 0x40, 0x40, 0x40, 0xE0, 0x00, 0x00},
    123         {0x20, 0x20, 0x20, 0x20, 0xA0, 0x40, 0x00, 0x00},
    124         {0xA0, 0xA0, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},
    125         {0x80, 0x80, 0x80, 0x80, 0x80, 0xE0, 0x00, 0x00},
    126         {0xA0, 0xE0, 0xE0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},
    127         {0xC0, 0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},
    128         {0x40, 0xA0, 0xA0, 0xA0, 0xA0, 0x40, 0x00, 0x00},
    129         {0xC0, 0xA0, 0xA0, 0xC0, 0x80, 0x80, 0x00, 0x00},
    130         {0x40, 0xA0, 0xA0, 0xA0, 0xA0, 0x40, 0x20, 0x00},
    131         {0xC0, 0xA0, 0xA0, 0xC0, 0xA0, 0xA0, 0x00, 0x00},
    132         {0x60, 0x80, 0x40, 0x20, 0x20, 0xC0, 0x00, 0x00},
    133         {0xE0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
    134         {0xA0, 0xA0, 0xA0, 0xA0, 0xA0, 0xE0, 0x00, 0x00},
    135         {0xA0, 0xA0, 0xA0, 0xA0, 0xC0, 0x80, 0x00, 0x00},
    136         {0xA0, 0xA0, 0xA0, 0xE0, 0xE0, 0xA0, 0x00, 0x00},
    137         {0xA0, 0xA0, 0x40, 0x40, 0xA0, 0xA0, 0x00, 0x00},
    138         {0xA0, 0xA0, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
    139         {0xE0, 0x20, 0x40, 0x40, 0x80, 0xE0, 0x00, 0x00},
    140         {0x60, 0x40, 0x40, 0x40, 0x40, 0x40, 0x60, 0x00},
    141         {0xA0, 0x40, 0xE0, 0x40, 0xE0, 0x40, 0x00, 0x00},
    142         {0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0xC0, 0x00},
    143         {0x40, 0xA0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    144         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x00},
    145         {0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    146         {0x00, 0x00, 0x60, 0xA0, 0xA0, 0x60, 0x00, 0x00},
    147         {0x80, 0x80, 0xC0, 0xA0, 0xA0, 0xC0, 0x00, 0x00},
    148         {0x00, 0x00, 0x60, 0x80, 0x80, 0x60, 0x00, 0x00},
    149         {0x20, 0x20, 0x60, 0xA0, 0xA0, 0x60, 0x00, 0x00},
    150         {0x00, 0x00, 0x60, 0xE0, 0x80, 0x60, 0x00, 0x00},
    151         {0x60, 0x40, 0xE0, 0x40, 0x40, 0x40, 0x00, 0x00},
    152         {0x00, 0x00, 0x60, 0xA0, 0x60, 0x20, 0xC0, 0x00},
    153         {0x80, 0x80, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},
    154         {0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
    155         {0x40, 0x00, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00},
    156         {0x80, 0x80, 0xA0, 0xC0, 0xA0, 0xA0, 0x00, 0x00},
    157         {0xC0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00},
    158         {0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xA0, 0x00, 0x00},
    159         {0x00, 0x00, 0xC0, 0xA0, 0xA0, 0xA0, 0x00, 0x00},
    160         {0x00, 0x00, 0x40, 0xA0, 0xA0, 0x40, 0x00, 0x00},
    161         {0x00, 0x00, 0xC0, 0xA0, 0xA0, 0xC0, 0x80, 0x00},
    162         {0x00, 0x00, 0x60, 0xA0, 0xA0, 0x60, 0x20, 0x00},
    163         {0x00, 0x00, 0xA0, 0xC0, 0x80, 0x80, 0x00, 0x00},
    164         {0x00, 0x00, 0x60, 0xC0, 0x60, 0xC0, 0x00, 0x00},
    165         {0x00, 0x40, 0xE0, 0x40, 0x40, 0x60, 0x00, 0x00},
    166         {0x00, 0x00, 0xA0, 0xA0, 0xA0, 0xE0, 0x00, 0x00},
    167         {0x00, 0x00, 0xA0, 0xA0, 0xC0, 0x80, 0x00, 0x00},
    168         {0x00, 0x00, 0xA0, 0xA0, 0xE0, 0xE0, 0x00, 0x00},
    169         {0x00, 0x00, 0xA0, 0x40, 0x40, 0xA0, 0x00, 0x00},
    170         {0x00, 0x00, 0xA0, 0xA0, 0x60, 0x20, 0xC0, 0x00},
    171         {0x00, 0x00, 0xE0, 0x20, 0x40, 0xE0, 0x00, 0x00},
    172         {0x20, 0x40, 0x40, 0x80, 0x40, 0x40, 0x20, 0x00},
    173         {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00},
    174         {0x80, 0x40, 0x40, 0x20, 0x40, 0x40, 0x80, 0x00},
    175         {0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
    176         {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
     48const uint8_t UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][FONT_HALF_WIDTH * FONT_HEIGHT / 8] = {
     49        {0x00, 0x00, 0x00, 0x00},
     50        {0x00, 0x00, 0x00, 0x00},
     51        {0x00, 0x00, 0x00, 0x00},
     52        {0x00, 0x00, 0x00, 0x00},
     53        {0x00, 0x00, 0x00, 0x00},
     54        {0x00, 0x00, 0x00, 0x00},
     55        {0x00, 0x00, 0x00, 0x00},
     56        {0x00, 0x00, 0x00, 0x00},
     57        {0x00, 0x00, 0x00, 0x00},
     58        {0x00, 0x00, 0x00, 0x00},
     59        {0x00, 0x00, 0x00, 0x00},
     60        {0x00, 0x00, 0x00, 0x00},
     61        {0x00, 0x00, 0x00, 0x00},
     62        {0x00, 0x00, 0x00, 0x00},
     63        {0x00, 0x00, 0x00, 0x00},
     64        {0x00, 0x00, 0x00, 0x00},
     65        {0x00, 0x00, 0x00, 0x00},
     66        {0x00, 0x00, 0x00, 0x00},
     67        {0x00, 0x00, 0x00, 0x00},
     68        {0x00, 0x00, 0x00, 0x00},
     69        {0x00, 0x00, 0x00, 0x00},
     70        {0x00, 0x00, 0x00, 0x00},
     71        {0x00, 0x00, 0x00, 0x00},
     72        {0x00, 0x00, 0x00, 0x00},
     73        {0x00, 0x00, 0x00, 0x00},
     74        {0x00, 0x00, 0x00, 0x00},
     75        {0x00, 0x00, 0x00, 0x00},
     76        {0x00, 0x00, 0x00, 0x00},
     77        {0x00, 0x00, 0x00, 0x00},
     78        {0x00, 0x00, 0x00, 0x00},
     79        {0x00, 0x00, 0x00, 0x00},
     80        {0x00, 0x00, 0x00, 0x00},
     81        {0x00, 0x00, 0x00, 0x00},
     82        {0x44, 0x44, 0x04, 0x00},
     83        {0xAA, 0x00, 0x00, 0x00},
     84        {0xAE, 0xAA, 0xEA, 0x00},
     85        {0x4E, 0xC6, 0xE4, 0x00},
     86        {0x08, 0x24, 0x82, 0x00},
     87        {0x4A, 0x46, 0xCE, 0x00},
     88        {0x48, 0x00, 0x00, 0x00},
     89        {0x24, 0x44, 0x44, 0x20},
     90        {0x84, 0x44, 0x44, 0x80},
     91        {0x4E, 0x4A, 0x00, 0x00},
     92        {0x04, 0x4E, 0x44, 0x00},
     93        {0x00, 0x00, 0x04, 0x80},
     94        {0x00, 0x0E, 0x00, 0x00},
     95        {0x00, 0x00, 0x04, 0x00},
     96        {0x00, 0x24, 0x80, 0x00},
     97        {0x04, 0xAE, 0xA4, 0x00},
     98        {0x04, 0xC4, 0x4E, 0x00},
     99        {0x0C, 0x24, 0x8E, 0x00},
     100        {0x0C, 0x24, 0x2C, 0x00},
     101        {0x02, 0x6A, 0xE2, 0x00},
     102        {0x0E, 0x8C, 0x2C, 0x00},
     103        {0x06, 0x8C, 0xA4, 0x00},
     104        {0x0E, 0x24, 0x44, 0x00},
     105        {0x04, 0xA4, 0xA4, 0x00},
     106        {0x04, 0xA6, 0x2C, 0x00},
     107        {0x00, 0x40, 0x04, 0x00},
     108        {0x00, 0x40, 0x04, 0x80},
     109        {0x02, 0x48, 0x42, 0x00},
     110        {0x00, 0xE0, 0xE0, 0x00},
     111        {0x08, 0x42, 0x48, 0x00},
     112        {0x4A, 0x24, 0x04, 0x00},
     113        {0x4A, 0x26, 0xA4, 0x00},
     114        {0x4A, 0xAE, 0xAA, 0x00},
     115        {0xCA, 0xCA, 0xAC, 0x00},
     116        {0x68, 0x88, 0x86, 0x00},
     117        {0xCA, 0xAA, 0xAC, 0x00},
     118        {0xE8, 0xC8, 0x8E, 0x00},
     119        {0xE8, 0xC8, 0x88, 0x00},
     120        {0x68, 0x8A, 0xA6, 0x00},
     121        {0xAA, 0xAE, 0xAA, 0x00},
     122        {0xE4, 0x44, 0x4E, 0x00},
     123        {0x22, 0x22, 0xA4, 0x00},
     124        {0xAA, 0xCA, 0xAA, 0x00},
     125        {0x88, 0x88, 0x8E, 0x00},
     126        {0xAE, 0xEA, 0xAA, 0x00},
     127        {0xCA, 0xAA, 0xAA, 0x00},
     128        {0x4A, 0xAA, 0xA4, 0x00},
     129        {0xCA, 0xAC, 0x88, 0x00},
     130        {0x4A, 0xAA, 0xA4, 0x20},
     131        {0xCA, 0xAC, 0xAA, 0x00},
     132        {0x68, 0x42, 0x2C, 0x00},
     133        {0xE4, 0x44, 0x44, 0x00},
     134        {0xAA, 0xAA, 0xAE, 0x00},
     135        {0xAA, 0xAA, 0xC8, 0x00},
     136        {0xAA, 0xAE, 0xEA, 0x00},
     137        {0xAA, 0x44, 0xAA, 0x00},
     138        {0xAA, 0x44, 0x44, 0x00},
     139        {0xE2, 0x44, 0x8E, 0x00},
     140        {0x64, 0x44, 0x44, 0x60},
     141        {0xA4, 0xE4, 0xE4, 0x00},
     142        {0xC4, 0x44, 0x44, 0xC0},
     143        {0x4A, 0x00, 0x00, 0x00},
     144        {0x00, 0x00, 0x00, 0xE0},
     145        {0x42, 0x00, 0x00, 0x00},
     146        {0x00, 0x6A, 0xA6, 0x00},
     147        {0x88, 0xCA, 0xAC, 0x00},
     148        {0x00, 0x68, 0x86, 0x00},
     149        {0x22, 0x6A, 0xA6, 0x00},
     150        {0x00, 0x6E, 0x86, 0x00},
     151        {0x64, 0xE4, 0x44, 0x00},
     152        {0x00, 0x6A, 0x62, 0xC0},
     153        {0x88, 0xCA, 0xAA, 0x00},
     154        {0x40, 0x44, 0x44, 0x00},
     155        {0x40, 0x44, 0x44, 0x80},
     156        {0x88, 0xAC, 0xAA, 0x00},
     157        {0xC4, 0x44, 0x44, 0x00},
     158        {0x00, 0xCE, 0xEA, 0x00},
     159        {0x00, 0xCA, 0xAA, 0x00},
     160        {0x00, 0x4A, 0xA4, 0x00},
     161        {0x00, 0xCA, 0xAC, 0x80},
     162        {0x00, 0x6A, 0xA6, 0x20},
     163        {0x00, 0xAC, 0x88, 0x00},
     164        {0x00, 0x6C, 0x6C, 0x00},
     165        {0x04, 0xE4, 0x46, 0x00},
     166        {0x00, 0xAA, 0xAE, 0x00},
     167        {0x00, 0xAA, 0xC8, 0x00},
     168        {0x00, 0xAA, 0xEE, 0x00},
     169        {0x00, 0xA4, 0x4A, 0x00},
     170        {0x00, 0xAA, 0x62, 0xC0},
     171        {0x00, 0xE2, 0x4E, 0x00},
     172        {0x24, 0x48, 0x44, 0x20},
     173        {0x44, 0x44, 0x44, 0x40},
     174        {0x84, 0x42, 0x44, 0x80},
     175        {0xE0, 0x00, 0x00, 0x00},
     176        {0x00, 0x00, 0x00, 0x00}
    177177};
    178178
    179179// 2バイトコード 1バイト目
    180 unsigned char Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2] = {
     180const uint8_t Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2] = {
    181181        {0xC2,  0x06},
    182182        {0xC3,  0x02},
     
    187187};
    188188// 2バイトコード 2バイト目 bitmapデータ
    189 struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM] = {
     189const struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM] = {
    190190        {0xA7,  {0x1C, 0x20, 0x18, 0x24, 0x18, 0x04, 0x38, 0x00}},
    191191        {0xA8,  {0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
     
    313313
    314314// 3バイトコード 1バイト目
    315 unsigned char Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2] = {
     315const uint8_t Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2] = {
    316316        {0xE2,  0x0E},
    317317        {0xE3,  0x04},
     
    325325};
    326326// 3バイトコード 2バイト目
    327 unsigned char Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2] = {
     327const uint8_t Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2] = {
    328328        {0x80,  0x0F},
    329329        {0x84,  0x02},
     
    673673
    674674// 3バイトコード 3バイト目 bitmapデータ
    675 struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM] = {
     675const struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM] = {
    676676        { 0x90 ,{0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00}},
    677677        { 0x95 ,{0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00}},
  • asp3_tinet_ecnl_arm/trunk/ntshell/lcd/misaki_font.h

    r352 r364  
    3939#define MISAKI_FONT_H
    4040
     41#include <stdint.h>
     42
     43#define FONT_HALF_WIDTH                 4
     44#define FONT_WIDTH                              8
     45#define FONT_HEIGHT                             8
     46
    4147struct utf8_code_bitmap {
    42         unsigned char code;
    43         unsigned char bitmap[8];
     48        const uint8_t code;
     49        const uint8_t bitmap[FONT_WIDTH * FONT_HEIGHT / 8];
    4450};
    4551
     
    4854#define UTF8_CODE_3B_2_NUM              (343+1)         /*半角追加2/2*/
    4955
    50 #define UTF8_CODE_BITMAP_NUM    6879                                                                                            /*トータル*/
    5156#define UTF8_1B_CODE_BITMAP_NUM 128
    5257#define UTF8_2B_CODE_BITMAP_NUM 122                                                                                                     /*"¬","\","¢""£"移動)*/
     
    5459
    5560// 1バイトコード
    56 extern unsigned char UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][8];
     61extern const uint8_t UTF8_1B_CODE_BITMAP[UTF8_1B_CODE_BITMAP_NUM][FONT_HALF_WIDTH * FONT_HEIGHT / 8];
    5762
    5863// 2バイトコード 1バイト目
    59 extern unsigned char Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2];
     64extern const uint8_t Utf8CodeTable_2B_1st[UTF8_CODE_2B_1_NUM][2];
    6065// 2バイトコード 2バイト目 bitmapデータ
    61 extern struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM];
     66extern const struct utf8_code_bitmap UTF8_2B_CODE_BITMAP[UTF8_2B_CODE_BITMAP_NUM];
    6267
    6368// 3バイトコード 1バイト目
    64 extern unsigned char Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2];
     69extern const uint8_t Utf8CodeTable_3B_1st[UTF8_CODE_3B_1_NUM][2];
    6570// 3バイトコード 2バイト目
    66 extern unsigned char Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2];
     71extern const uint8_t Utf8CodeTable_3B_2nd[UTF8_CODE_3B_2_NUM][2];
    6772
    6873// 3バイトコード 3バイト目 bitmapデータ
    69 extern struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM];
     74extern const struct utf8_code_bitmap UTF8_3B_CODE_BITMAP[UTF8_3B_CODE_BITMAP_NUM];
    7075
    7176#endif /* MISAKI_FONT_H */
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/echonet_app_config.h

    r352 r364  
    4040
    4141#define ECHONET_TASK_STACK_SIZE 1024    /* ECNL UDPタスク用スタック領域のサイズ */
     42
     43#define ECHONET_API_DATAQUEUE_COUNT 5           /* ECHONET Lite API用データキュー */
     44#define ECHONET_SVC_DATAQUEUE_COUNT 5           /* ECHONET Lite サービス処理タスク用データキュー */
     45#define ECHONET_UDP_DATAQUEUE_COUNT 5           /* ECHONET Lite UDP通信処理用データキュー */
    4246
    4347/*
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/fdtable.c

    r359 r364  
    4545#include "target_syssvc.h"
    4646#ifndef NTSHELL_NO_SOCKET
     47#include <tinet_defs.h>
    4748#include <tinet_config.h>
     49#include <net/net.h>
     50#include <net/net_endian.h>
    4851#include <netinet/in.h>
    4952#include <netinet/in_itron.h>
     
    5558#include <net/net.h>
    5659#include <net/if_var.h>
     60#include <netinet/udp.h>
    5761#include <netinet/udp_var.h>
    5862#include <netinet/tcp.h>
    5963#include <netinet/tcp_var.h>
     64#include <net/net_buf.h>
    6065#endif
    6166#include "ff.h"
     
    6974#define IO_TYPE_DIR             3
    7075#define IO_TYPE_TCP             4
    71 #define IO_TYPE_UDP             5
     76#define IO_TYPE_UDP     5
    7277
    7378static struct _IO_FILE fd_table[8 * sizeof(FLGPTN)] = {
     
    8590                        continue;
    8691
     92                memset(fp, 0, sizeof(struct _IO_FILE));
    8793                fp->fd = fd;
    8894                fp->type = type;
     
    280286#endif
    281287
     288void memor(void *dst, void *src, size_t len)
     289{
     290        uint8_t *d = (uint8_t *)dst;
     291        uint8_t *s = (uint8_t *)src;
     292        uint8_t *e = &s[len];
     293
     294        while (s < e) {
     295                *d++ |= *s++;
     296        }
     297}
     298
    282299struct fd_events {
    283300        int count;
     
    304321        }
    305322
    306         memcpy(&evts.readfds, rfds, sizeof(fd_set));
    307         memcpy(&evts.writefds, wfds, sizeof(fd_set));
    308         memcpy(&evts.errorfds, efds, sizeof(fd_set));
     323        if (rfds != NULL)
     324                memcpy(&evts.readfds, rfds, sizeof(fd_set));
     325        else
     326                memset(&evts.readfds, 0, sizeof(fd_set));
     327        if (wfds != NULL)
     328                memcpy(&evts.writefds, wfds, sizeof(fd_set));
     329        else
     330                memset(&evts.writefds, 0, sizeof(fd_set));
     331        if (efds != NULL)
     332                memcpy(&evts.errorfds, efds, sizeof(fd_set));
     333        else
     334                memset(&evts.errorfds, 0, sizeof(fd_set));
    309335        evts.count = 0;
    310336
    311337        ret = shell_get_evts(&evts, tmout);
     338        if (rfds != NULL)
     339                memset(rfds, 0, sizeof(fd_set));
     340        if (wfds != NULL)
     341                memset(wfds, 0, sizeof(fd_set));
     342        if (efds != NULL)
     343                memset(efds, 0, sizeof(fd_set));
    312344        if (ret == E_OK) {
    313                 memcpy(rfds, &evts.readfds, sizeof(fd_set));
    314                 memcpy(wfds, &evts.writefds, sizeof(fd_set));
    315                 memcpy(efds, &evts.errorfds, sizeof(fd_set));
     345                if (rfds != NULL)
     346                        memor(rfds, &evts.readfds, sizeof(fd_set));
     347                if (wfds != NULL)
     348                        memor(wfds, &evts.writefds, sizeof(fd_set));
     349                if (efds != NULL)
     350                        memor(efds, &evts.errorfds, sizeof(fd_set));
    316351                return evts.count;
    317352        }
    318353        if (ret == E_TMOUT) {
    319                 memset(rfds, 0, sizeof(fd_set));
    320                 memset(wfds, 0, sizeof(fd_set));
    321                 memset(efds, 0, sizeof(fd_set));
    322354                return 0;
    323355        }
     
    441473        struct _IO_FILE *fp = tcpid_to_fd(cepid);
    442474        FLGPTN flgptn = 0;
     475        ER ret;
     476        int len;
    443477
    444478        if (fp == NULL)
     
    449483
    450484        switch (fncd) {
     485        case TFN_TCP_RCV_BUF:
     486                len = *(int *)p_parblk;
     487                if (len <= 0)
     488                        return E_OK;
     489
     490                ret = wai_sem(SEM_FILEDESC);
     491                if (ret < 0) {
     492                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     493                }
     494                fp->psock->len += len;
     495                ret = sig_sem(SEM_FILEDESC);
     496                if (ret < 0) {
     497                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     498                }
     499
     500                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     501
     502                set_flg(FLG_SELECT_WAIT, flgptn);
     503                return E_OK;
     504
    451505        case TFN_TCP_RCV_DAT:
     506                len = *(int *)p_parblk;
     507                if (len <= 0)
     508                        return E_OK;
     509
     510                ret = wai_sem(SEM_FILEDESC);
     511                if (ret < 0) {
     512                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     513                }
     514                fp->psock->len += len;
     515                ret = sig_sem(SEM_FILEDESC);
     516                if (ret < 0) {
     517                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     518                }
     519
    452520                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    453521
     
    484552        struct _IO_FILE *fp = udpid_to_fd(cepid);
    485553        FLGPTN flgptn = 0;
     554        int len;
    486555
    487556        if (fp == NULL)
     
    492561
    493562        switch (fncd) {
     563        case TEV_UDP_RCV_DAT:
     564        {
     565                T_UDP_RCV_DAT_PARA *udppara = (T_UDP_RCV_DAT_PARA *)p_parblk;
     566                len = udppara->len;
     567                if (len <= 0)
     568                        return E_OK;
     569
     570                ER ret = wai_sem(SEM_FILEDESC);
     571                if (ret < 0) {
     572                        syslog(LOG_ERROR, "wai_sem => %d", ret);
     573                }
     574                fp->psock->len = len;
     575                if (fp->psock->input != NULL) {
     576                        ret = rel_net_buf(fp->psock->input);
     577                        if (ret < 0) {
     578                                syslog(LOG_ERROR, "rel_net_buf => %d", ret);
     579                        }
     580                }
     581                fp->psock->input = udppara->input;
     582                fp->psock->buf = GET_UDP_SDU(udppara->input, udppara->off);
     583                memset(&fp->psock->raddr4, 0, sizeof(fp->psock->raddr4));
     584                fp->psock->raddr4.sin_family = AF_INET;
     585                fp->psock->raddr4.sin_port = htons(udppara->rep4.portno);
     586                fp->psock->raddr4.sin_addr.s_addr = htonl(udppara->rep4.ipaddr);
     587                udppara->input->flags |= NB_FLG_NOREL_IFOUT;
     588                ret = sig_sem(SEM_FILEDESC);
     589                if (ret < 0) {
     590                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     591                }
     592
     593                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
     594
     595                set_flg(FLG_SELECT_WAIT, flgptn);
     596                return E_OK;
     597        }
    494598        case TFN_UDP_CRE_CEP:
     599                return E_OK;
     600
    495601        case TFN_UDP_RCV_DAT:
     602                len = *(int *)p_parblk;
     603                if (len <= 0)
     604                        return E_OK;
     605
    496606                if (fp->readevt_w == fp->readevt_r) fp->readevt_w++;
    497607
     
    524634ER shell_get_evts(struct fd_events *evts, TMO tmout)
    525635{
    526         ER ret;
    527         FLGPTN waitptn, flgptn = 0, readfds = 0, writefds = 0;
    528         struct _IO_FILE *fp = NULL;
    529636        int count = 0;
    530 
    531         stdio_update_evts();
     637        SYSTIM prev, now;
     638
     639        get_tim(&prev);
     640
     641        for (;;) {
     642                ER ret;
     643                FLGPTN waitptn, flgptn, readfds = 0, writefds = 0;
     644                struct _IO_FILE *fp = NULL;
     645
     646                stdio_update_evts();
    532647
    533648#ifndef NTSHELL_NO_SOCKET
    534         waitptn = *((FLGPTN *)&evts->errorfds);
     649                waitptn = *((FLGPTN *)&evts->errorfds);
    535650#else
    536         waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->errorfds);
     651                waitptn = *((FLGPTN *)&evts->readfds) | *((FLGPTN *)&evts->errorfds);
    537652#endif
    538         for (int fd = 0; fd < fd_table_count; fd++) {
    539                 fp = &fd_table[fd];
     653                for (int fd = 0; fd < fd_table_count; fd++) {
     654                        fp = &fd_table[fd];
    540655
    541656#ifndef NTSHELL_NO_SOCKET
    542                 if (FD_ISSET(fd, &evts->readfds)) {
    543                         if ((fp->type == IO_TYPE_TCP)
    544                                 && (GET_TCP_CEP(fp->psock->cepid)->rwbuf_count > 0)) {
    545                                 FD_SET(fd, (fd_set *)&readfds);
    546                                 count++;
    547                                 if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
     657                        if (FD_ISSET(fd, &evts->readfds)) {
     658                                if ((fp->type == IO_TYPE_TCP) && (fp->psock->cepid != 0)) {
     659                                        if (fp->psock->len == 0) {
     660                                                ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_NBLK);
     661                                                if ((ret != E_WBLK) && (ret != E_OBJ) && (ret < 0)) {
     662                                                        syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     663                                                        //return ret;
     664                                                }
     665                                                if (ret > 0) {
     666                                                        ret = wai_sem(SEM_FILEDESC);
     667                                                        if (ret < 0) {
     668                                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     669                                                        }
     670                                                        fp->psock->len += ret;
     671                                                        ret = sig_sem(SEM_FILEDESC);
     672                                                        if (ret < 0) {
     673                                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     674                                                        }
     675                                                }
     676                                        }
     677                                        else ret = 1;
     678                                        if (ret > 0) {
     679                                                FD_SET(fd, (fd_set *)&readfds);
     680                                                count++;
     681                                                if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
     682                                        }
     683                                }
     684                                else if ((fp->type == IO_TYPE_UDP) && (fp->psock->cepid != 0)) {
     685                                        if (fp->psock->input != NULL) {
     686                                                FD_SET(fd, (fd_set *)&readfds);
     687                                                count++;
     688                                                if (fp->readevt_w == fp->readevt_r) fp->readevt_r--;
     689                                        }
     690                                }
     691                                else {
     692                                        FD_SET(fd, (fd_set *)&waitptn);
     693                                }
    548694                        }
    549                         else {
    550                                 FD_SET(fd, (fd_set *)&waitptn);
     695#endif
     696                        if (FD_ISSET(fd, &evts->writefds)) {
     697                                if (fp->writeevt_w == fp->writeevt_r) {
     698                                        FD_SET(fd, (fd_set *)&writefds);
     699                                        count++;
     700                                        if (fp->writeevt_w == fp->writeevt_r) fp->writeevt_r--;
     701                                }
     702                                else {
     703                                        FD_SET(fd, (fd_set *)&waitptn);
     704                                }
    551705                        }
    552706                }
    553 #endif
    554                 if (FD_ISSET(fd, &evts->writefds)) {
    555                         if (fp->writable) {
    556                                 FD_SET(fd, (fd_set *)&writefds);
     707                memset(evts, 0, sizeof(*evts));
     708
     709                if (waitptn == 0) {
     710                        memcpy(&evts->readfds, &readfds, sizeof(evts->readfds));
     711                        memcpy(&evts->writefds, &writefds, sizeof(evts->writefds));
     712                        evts->count = count;
     713                        return E_OK;
     714                }
     715                else if ((readfds | writefds) != 0) {
     716                        set_flg(FLG_SELECT_WAIT, (readfds | writefds));
     717                }
     718
     719                /* イベント待ち */
     720                flgptn = 0;
     721                ret = twai_flg(FLG_SELECT_WAIT, waitptn, TWF_ORW, &flgptn, tmout);
     722                if (ret != E_OK) {
     723                        if (ret != E_TMOUT) {
     724                                syslog(LOG_ERROR, "twai_flg => %d", ret);
     725                                return ret;
     726                        }
     727
     728                        stdio_flgptn(&flgptn);
     729
     730                        if (flgptn == 0)
     731                                return E_TMOUT;
     732                }
     733                flgptn &= waitptn;
     734
     735                /* 受け取ったフラグのみクリア */
     736                ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
     737                if (ret != E_OK) {
     738                        syslog(LOG_ERROR, "clr_flg => %d", ret);
     739                }
     740
     741                count = 0;
     742                for (int fd = 0; fd < fd_table_count; fd++) {
     743                        if (!FD_ISSET(fd, (fd_set *)&waitptn))
     744                                continue;
     745
     746                        fp = &fd_table[fd];
     747
     748                        if (fp->readevt_w != fp->readevt_r) {
     749                                fp->readevt_r++;
     750                                FD_SET(fd, &evts->readfds);
    557751                                count++;
    558752                        }
    559                         else {
    560                                 FD_SET(fd, (fd_set *)&waitptn);
     753                        if (fp->writeevt_w != fp->writeevt_r) {
     754                                fp->writeevt_r++;
     755                                fp->writable = 1;
    561756                        }
    562                 }
    563         }
    564         memset(evts, 0, sizeof(*evts));
    565 
    566         if (waitptn == 0) {
    567                 memcpy(&evts->readfds, &readfds, sizeof(evts->readfds));
    568                 memcpy(&evts->writefds, &writefds, sizeof(evts->writefds));
    569                 evts->count = count;
    570                 return E_OK;
    571         }
    572         else if ((readfds | writefds) != 0){
    573                 set_flg(FLG_SELECT_WAIT, (readfds | writefds));
    574         }
    575 
    576         /* イベント待ち */
    577         ret = twai_flg(FLG_SELECT_WAIT, waitptn, TWF_ORW, &flgptn, tmout);
    578         if (ret != E_OK) {
    579                 if (ret != E_TMOUT) {
    580                         syslog(LOG_ERROR, "twai_flg => %d", ret);
    581                         return ret;
    582                 }
    583 
    584                 stdio_flgptn(&flgptn);
    585 
    586                 if (flgptn == 0)
     757                        if (fp->writable) {
     758                                FD_SET(fd, &evts->writefds);
     759                                count++;
     760                        }
     761                        if (fp->errorevt_w != fp->errorevt_r) {
     762                                fp->errorevt_r++;
     763                                FD_SET(fd, &evts->errorfds);
     764                                count++;
     765                        }
     766                }
     767
     768                if (count > 0)
     769                        break;
     770
     771                get_tim(&now);
     772
     773                SYSTIM elapse = now - prev;
     774                if (elapse > tmout)
    587775                        return E_TMOUT;
    588         }
    589         flgptn &= waitptn;
    590 
    591         /* 受け取ったフラグのみクリア */
    592         ret = clr_flg(FLG_SELECT_WAIT, ~flgptn);
    593         if (ret != E_OK) {
    594                 syslog(LOG_ERROR, "clr_flg => %d", ret);
    595         }
    596 
    597         count = 0;
    598         for (int fd = 0; fd < fd_table_count; fd++) {
    599                 if (!FD_ISSET(fd, (fd_set *)&waitptn))
    600                         continue;
    601 
    602                 fp = &fd_table[fd];
    603 
    604                 if (fp->readevt_w != fp->readevt_r) {
    605                         fp->readevt_r++;
    606                         FD_SET(fd, &evts->readfds);
    607                         count++;
    608                 }
    609                 if (fp->writeevt_w != fp->writeevt_r) {
    610                         fp->writeevt_r++;
    611                         fp->writable = 1;
    612                 }
    613                 if (fp->writable) {
    614                         FD_SET(fd, &evts->writefds);
    615                         count++;
    616                 }
    617                 if (fp->errorevt_w != fp->errorevt_r) {
    618                         fp->errorevt_r++;
    619                         FD_SET(fd, &evts->errorfds);
    620                         count++;
    621                 }
    622         }
     776
     777                prev = now;
     778                tmout -= elapse;
     779        }
     780
    623781        evts->count = count;
    624782
     
    676834}
    677835
    678 ssize_t shell_send(int fd, const void *buf, size_t len, int flags)
    679 {
    680         return -ENOMEM;
    681 }
    682 
    683836ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
    684837{
     
    691844}
    692845
    693 ssize_t shell_recv(int fd, void *buf, size_t len, int flags)
    694 {
    695         return -ENOMEM;
    696 }
    697 
    698 ssize_t shell_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
     846ssize_t shell_recvfrom(int fd, void *__restrict buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
    699847{
    700848        return -ENOMEM;
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/net_misc.h

    r352 r364  
    4141/* スタックサイズ */
    4242
    43 #define NET_MISC_STACK_SIZE     1024            /* NTP クライアントタスク(IPv4)のスタックサイズ  */
     43#define NET_MISC_STACK_SIZE     2048            /* NTP クライアントタスク(IPv4)のスタックサイズ  */
    4444
    4545/* 優先度 */
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/netcmd.c

    r352 r364  
    239239int usrcmd_ping(int argc, char **argv)
    240240{
    241         int     tmo, size;
    242         char    apip = DEFAULT_API_PROTO;
     241        int tmo = 3, size = 64;
     242        char apip = DEFAULT_API_PROTO;
    243243        char *line = argv[1];
    244244#if defined(SUPPORT_INET6)
     
    262262
    263263#if defined(SUPPORT_INET6) && defined(SUPPORT_INET4)
     264        if (argc <= 2)
     265                return 0;
     266
    264267        if ('0' <= *line && *line <= '9') {
    265268                if (*line == '6')
     
    269272                line++;
    270273        }
     274
     275        line = argv[2];
     276#else
     277        if (argc <= 1)
     278                return 0;
    271279#endif  /* of #if defined(SUPPORT_INET6) && defined(SUPPORT_INET4) */
    272280
     
    276284        }
    277285
    278         line = argv[2];
    279         if ('0' <= *line && *line <= '9')
    280                 line = get_int(&tmo, line);
    281         else
    282                 tmo = 3;
    283 
    284         line = argv[3];
    285         if ('0' <= *line && *line <= '9')
    286                 line = get_int(&size, line);
    287         else
    288                 size = 64;
     286        if (argc > 2) {
     287                line = argv[2];
     288                if ('0' <= *line && *line <= '9')
     289                        line = get_int(&tmo, line);
     290
     291                if (argc > 3) {
     292                        line = argv[3];
     293                        if ('0' <= *line && *line <= '9')
     294                                line = get_int(&size, line);
     295                }
     296        }
    289297
    290298#if defined(SUPPORT_INET6)
     
    337345{
    338346        ER ret;
     347
     348        if (argc < 2)
     349                return 0;
     350
    339351        if (ntlibc_strcmp(argv[1], "rel") == 0) {
    340352                ret = dhcp4c_rel_info();
     
    348360                dhcp4c_info();
    349361        }
     362
    350363        return 0;
    351364}
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntp_cli.c

    r359 r364  
    265265
    266266        nc->buf[0] = '\0';
    267 #ifndef _MSC_VER
     267#ifdef __NEED_struct_timespec
    268268        if (ctime_r(&tp.tv_sec, nc->buf) != NULL)
    269269#else
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.c

    r352 r364  
    6969const struct utsname host_name = {
    7070        "TOPPERS/ASP3",
    71     TARGET_NAME,
    72     "3.2.0",
    73     "3.2.0",
    74     TARGET_NAME,
    75     "toppers.jp"
     71        TARGET_NAME,
     72        "3.2.0",
     73        "3.2.0",
     74        TARGET_NAME,
     75        "toppers.jp"
    7676};
    7777
     
    8888jmp_buf process_exit;
    8989void sys_init(void);
    90 
    91 void ntshell_task_init()
    92 {
     90NTSHELL_SERIAL_READ ntshell_serial_read = 0;
     91NTSHELL_SERIAL_WRITE ntshell_serial_write = 0;
     92void *ntshell_serial_extobj;
     93
     94unsigned char ntstdio_xi(struct ntstdio_t *handle)
     95{
     96        unsigned char buf[1];
     97        ntshell_serial_read((char *)buf, 1, ntshell_serial_extobj);
     98        return buf[0];
     99}
     100
     101void ntstdio_xo(struct ntstdio_t *handle, unsigned char c)
     102{
     103        char buf[1];
     104        buf[0] = c;
     105        ntshell_serial_write(buf, 1, ntshell_serial_extobj);
     106}
     107
     108void ntshell_task_init(NTSHELL_SERIAL_READ func_read,
     109        NTSHELL_SERIAL_WRITE func_write, void *extobj)
     110{
     111        ntshell_serial_read = func_read;
     112        ntshell_serial_write = func_write;
     113        ntshell_serial_extobj = extobj;
     114
    93115        sys_init();
    94116
     
    126148        int result = 0;
    127149        int found = 0;
     150
     151        if (*args == 0)
     152                return result;
    128153
    129154        if (strcmp((const char *)args[1], "help") == 0) {
     
    295320int shell_clock_getres(clockid_t clk_id, struct timespec *res)
    296321{
    297         if (clk_id != CLOCK_REALTIME)
     322        if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    298323                return -EINVAL;
    299324
     
    308333        SYSTIM now = 0;
    309334
    310         if (clk_id != CLOCK_REALTIME)
     335        if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    311336                return -EINVAL;
    312337
     
    320345int shell_clock_settime(clockid_t clk_id, const struct timespec *tp)
    321346{
    322         if (clk_id != CLOCK_REALTIME)
     347        if ((clk_id != CLOCK_REALTIME) && (clk_id != CLOCK_MONOTONIC))
    323348                return -EINVAL;
    324349
    325         rtc_write(tp->tv_sec);
     350        SYSTIM time;
     351        ER ret;
     352
     353        time = (tp->tv_sec * 1000000ll) + (tp->tv_nsec / 1000ll);
     354
     355        ret = set_tim(time);
     356        if (ret != E_OK) {
     357                return -EPERM;
     358        }
    326359
    327360        return 0;
     
    356389}
    357390
    358 struct sigaction sigtable[6];
     391struct sigaction sigtable[7];
    359392
    360393int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
     
    381414                sat = &sigtable[5];
    382415                break;
     416        case SIGPIPE:
     417                sat = &sigtable[6];
     418                break;
    383419        default:
    384420                return -EINVAL;
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.cfg

    r352 r364  
    4343CRE_TSK(NTSHELL_TASK, { TA_NULL, 0, ntshell_task, NTSHELL_PRIORITY, NTSHELL_STACK_SIZE, NULL });
    4444CRE_FLG(FLG_SELECT_WAIT, { TA_WMUL, 0x00 });
     45CRE_SEM(SEM_FILEDESC, { TA_TPRI, 1, 1 });
    4546CRE_SEM(SEM_MALLOC, { TA_TPRI, 1, 1 });
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/ntshell_main.h

    r352 r364  
    4949
    5050#include "usrcmd.h"
     51#include "core/ntshell.h"
    5152
    5253/*
     
    5455 */
    5556
    56 #define NTSHELL_PRIORITY        4               /* ntshellタスクの優先度 */
     57#define NTSHELL_PRIORITY        8               /* ntshellタスクの優先度 */
    5758
    5859#define NTSHELL_STACK_SIZE      8192    /* ntshellタスクのスタック領域のサイズ */
     
    7576extern PRI main_task_priority;
    7677
    77 struct ntstdio_t;
    78 unsigned char ntstdio_xi(struct ntstdio_t *handle);
    79 void ntstdio_xo(struct ntstdio_t *handle, unsigned char c);
    80 
    8178/* ntshellタスク初期化 */
    82 void ntshell_task_init();
     79void ntshell_task_init(NTSHELL_SERIAL_READ func_read,
     80        NTSHELL_SERIAL_WRITE func_write, void *extobj);
    8381
    8482/* ntshellタスク */
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/shellif.h

    r352 r364  
    3939
    4040#ifdef _MSC_VER
    41 #define _CRT_NO_TIME_T
    42 #define tm msc_tm
    43 #include <time.h>
    44 #include <errno.h>
    45 #include <limits.h>
    46 #include <stdlib.h>
    47 #undef tm
    4841#undef NULL
    4942#endif
     
    133126#endif
    134127
     128#ifdef __cplusplus
     129extern "C" {
     130#endif
     131
    135132// time.h
    136133#define CLOCK_REALTIME 0
     
    179176int shell_access(const char *path, int mode);
    180177// signal.h
    181 int shell_sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old);
    182 int shell_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old);
     178int shell_sigprocmask(int how, const sigset_t *__restrict set, sigset_t *__restrict old);
     179int shell_sigaction(int sig, const struct sigaction *__restrict sa, struct sigaction *__restrict old);
    183180// socket.h
    184181int shell_socket(int, int, int);
    185182int shell_connect(int, const struct sockaddr *, socklen_t);
    186 ssize_t shell_send(int, const void *, size_t, int);
    187183ssize_t shell_sendto(int, const void *, size_t, int, const struct sockaddr *, socklen_t);
    188184ssize_t shell_sendmsg(int, const struct msghdr *, int);
     
    190186int shell_listen(int, int);
    191187int shell_accept(int, struct sockaddr *__restrict, socklen_t *__restrict);
    192 ssize_t shell_recv(int, void *, size_t, int);
    193188ssize_t shell_recvfrom(int, void *__restrict, size_t, int, struct sockaddr *__restrict, socklen_t *__restrict);
    194189ssize_t shell_recvmsg(int, struct msghdr *, int);
     
    263258int shell_pipe2(int [2], int);
    264259int shell_ppoll(struct pollfd *, nfds_t, const struct timespec *,const sigset_t *);
    265 int shell_pselect6(int, fd_set *restrict, fd_set *restrict,
    266         fd_set *restrict, const struct timespec *restrict, const sigset_t *restrict);
     260int shell_pselect6(int, fd_set *__restrict, fd_set *__restrict,
     261        fd_set *__restrict, const struct timespec *__restrict, const sigset_t *__restrict);
    267262int shell_setpgid(pid_t, pid_t);
    268263int shell_setsid();
     
    314309void free(void *ptr);
    315310
     311#ifdef __cplusplus
     312}
     313#endif
     314
    316315#endif /* SHELLIF_H */
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/socket_stub.c

    r352 r364  
    4242#include <sil.h>
    4343#include "syssvc/syslog.h"
     44#include <tinet_defs.h>
    4445#include <tinet_config.h>
     46#include <net/net.h>
     47#include <net/net_endian.h>
    4548#include <netinet/in.h>
    4649#include <netinet/in_itron.h>
     
    5356#include <net/if_var.h>
    5457#include <netinet/udp_var.h>
     58#include <net/net_buf.h>
    5559//#include <netinet/tcp_var.h>
    5660#include <netapp/resolver.h>
     
    5862#include "ff.h"
    5963#include "socket_stub.h"
     64#include "kernel_cfg.h"
    6065
    6166#define SOCKET_TIMEOUT 2000000
     
    181186                        fp->psock->buf_size = 512 + 512;
    182187                        fp->psock->buf = malloc(fp->psock->buf_size);
     188#ifdef _DEBUG
     189                        memset(fp->psock->buf, 0, fp->psock->buf_size);
     190#endif
    183191                        T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
    184192                        ret = tcp_cre_cep(cepid, &ccep);
     
    279287                        fp->psock->buf_size = 512 + 512;
    280288                        fp->psock->buf = malloc(fp->psock->buf_size);
     289#ifdef _DEBUG
     290                        memset(fp->psock->buf, 0, fp->psock->buf_size);
     291#endif
    281292                        T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
    282293                        ret = tcp_cre_cep(cepid, &ccep);
     
    298309                        return -EHOSTUNREACH;
    299310                }
    300                 fp->writable = 1;
    301311                break;
    302312        }
     
    322332        }
    323333
    324         memcpy(&fp->psock, &lfp->psock, sizeof(fp->psock));
     334        memcpy(fp->psock, lfp->psock, offsetof(socket_t, buf_size));
    325335
    326336        ER ret;
     
    335345                        fp->psock->buf_size = 512 + 512;
    336346                        fp->psock->buf = malloc(fp->psock->buf_size);
     347#ifdef _DEBUG
     348                        memset(fp->psock->buf, 0, fp->psock->buf_size);
     349#endif
    337350                        T_TCP_CCEP ccep = { 0, fp->psock->buf, 512, &fp->psock->buf[512], 512, (FP)socket_tcp_callback };
    338351                        ret = tcp_cre_cep(cepid, &ccep);
     
    346359                else {
    347360                        cepid = lfp->psock->cepid;
     361                        fp->handle = cepid;
    348362                        lfp->handle = tmax_tcp_cepid + lfp->psock->repid;
    349363                        lfp->psock->cepid = 0;
     
    356370                        return -ENOMEM;
    357371                }
    358                 fp->writable = 1;
    359372                struct sockaddr_in *raddr = &fp->psock->raddr4;
    360373                memset(raddr, 0, sizeof(*raddr));
     
    384397}
    385398
    386 ssize_t shell_send(int fd, const void *buf, size_t len, int flags)
     399ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
    387400{
    388401        SOCKET *fp = fd_to_fp(fd);
     
    396409                switch (fp->psock->type) {
    397410                case SOCK_STREAM: {
    398                         fp->writable = 0;
     411                        if ((addr != NULL) || (alen != 0)) {
     412                                return -EISCONN;
     413                        }
     414
    399415                        if (flags & MSG_OOB) {
    400416                                ret = tcp_snd_oob(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     
    404420                        }
    405421                        else {
    406                                 ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    407                                 if (ret < 0) {
    408                                         return -ECOMM;
    409                                 }
    410                         }
    411                         break;
    412                 }
    413                 case SOCK_DGRAM: {
    414                         return -EINVAL;
    415                 }
    416                 }
    417                 break;
    418         }
    419         case AF_INET6: {
    420                 return -EAFNOSUPPORT;
    421         }
    422         }
    423 
    424         return ret;
    425 }
    426 
    427 ssize_t shell_sendto(int fd, const void *buf, size_t len, int flags, const struct sockaddr *addr, socklen_t alen)
    428 {
    429         SOCKET *fp = fd_to_fp(fd);
    430         if (fp == NULL) {
    431                 return -EBADF;
    432         }
    433 
    434         int ret = 0;
    435         switch (fp->psock->family) {
    436         case AF_INET: {
    437                 switch (fp->psock->type) {
    438                 case SOCK_STREAM: {
    439                         if ((addr != NULL) && (alen != 0)) {
    440                                 return -EINVAL;
    441                         }
    442 
    443                         fp->writable = 0;
    444                         if (flags & MSG_OOB) {
    445                                 ret = tcp_snd_oob(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    446                                 if (ret < 0) {
    447                                         return -ECOMM;
    448                                 }
    449                         }
    450                         else {
    451                                 ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
    452                                 if (ret < 0) {
    453                                         return -ECOMM;
    454                                 }
     422                                for (;;) {
     423                                        ret = tcp_snd_dat(fp->psock->cepid, (void *)buf, len, SOCKET_TIMEOUT);
     424                                        if (ret < 0) {
     425                                                if (ret == E_TMOUT)
     426                                                        return -ETIME;
     427                                                return -ECOMM;
     428                                        }
     429                                        len -= ret;
     430                                        if (len <= 0)
     431                                                break;
     432                                        buf = (const void *)&((uint8_t *)buf)[ret];
     433                                }
    455434                        }
    456435                        break;
     
    458437                case SOCK_DGRAM: {
    459438                        int sz = alen;
    460                         if (sz < 8) {
     439                        if ((addr == NULL) || (sz < 8)) {
    461440                                return -EINVAL;
    462441                        }
     
    465444                        memcpy(raddr, addr, sz);
    466445                        T_IPV4EP rep = { ntohl(raddr->sin_addr.s_addr), ntohs(raddr->sin_port) };
    467                         fp->writable = 0;
    468446                        ret = udp_snd_dat(fp->psock->cepid, &rep, (void *)buf, len,
    469                                 (fp->psock->flags & O_NONBLOCK) ? 0 : SOCKET_TIMEOUT);
     447                                (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    470448                        if (ret < 0) {
    471                                 return -ECOMM;
     449                                return (ret == E_TMOUT) ? -ETIME : -ECOMM;
    472450                        }
    473451                        break;
     
    490468}
    491469
    492 ssize_t shell_recv(int fd, void *buf, size_t len, int flags)
     470ssize_t shell_recvfrom(int fd, void *__restrict buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
    493471{
    494472        SOCKET *fp = fd_to_fp(fd);
     
    505483                                ret = tcp_rcv_oob(fp->psock->cepid, buf, len);
    506484                                if (ret < 0) {
     485                                        syslog(LOG_ERROR, "tcp_rcv_oob => %d", ret);
    507486                                        return -ECOMM;
    508487                                }
    509488                        }
    510489                        else {
    511                                 ret = tcp_rcv_dat(fp->psock->cepid, buf, len, TMO_FEVR);
     490                                int rsz, tmp;
     491                                if (fp->psock->input == NULL) {
     492                                        ret = wai_sem(SEM_FILEDESC);
     493                                        if (ret < 0) {
     494                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     495                                        }
     496                                        fp->psock->len = 0;
     497                                        ret = sig_sem(SEM_FILEDESC);
     498                                        if (ret < 0) {
     499                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     500                                        }
     501                                        ret = tcp_rcv_buf(fp->psock->cepid, &fp->psock->input, TMO_FEVR);
     502                                        if (ret < 0) {
     503                                                syslog(LOG_ERROR, "tcp_rcv_buf => %d", ret);
     504                                                return -ECOMM;
     505                                        }
     506                                        rsz = ret;
     507                                }
     508                                else
     509                                        rsz = fp->psock->len;
     510                                tmp = rsz;
     511                                if (rsz > len)
     512                                        rsz = len;
     513                                if (rsz >= 0) {
     514                                        memcpy(buf, fp->psock->input, rsz);
     515                                        ret = wai_sem(SEM_FILEDESC);
     516                                        if (ret < 0) {
     517                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     518                                        }
     519                                        fp->psock->len = tmp - rsz;
     520                                        ret = sig_sem(SEM_FILEDESC);
     521                                        if (ret < 0) {
     522                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     523                                        }
     524                                        if (tmp - rsz == 0) {
     525                                                fp->psock->input = NULL;
     526                                        }
     527                                        else
     528                                                fp->psock->input = (void *)&((uint8_t *)fp->psock->input)[rsz];
     529                                        ret = tcp_rel_buf(fp->psock->cepid, rsz);
     530                                        if ((ret != E_OBJ) && (ret < 0)) {
     531                                                syslog(LOG_ERROR, "tcp_rel_buf => %d", ret);
     532                                                //return -ECOMM;
     533                                        }
     534                                }
     535                                ret = rsz;
     536                        }
     537                        break;
     538                }
     539                case SOCK_DGRAM: {
     540                        struct sockaddr_in *raddr = &fp->psock->raddr4;
     541                        int rsz;
     542                        ret = wai_sem(SEM_FILEDESC);
     543                        if (ret < 0) {
     544                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     545                        }
     546                        T_NET_BUF *input = fp->psock->input;
     547                        if (input == NULL) {
     548                                ret = sig_sem(SEM_FILEDESC);
    512549                                if (ret < 0) {
    513                                         return -ECOMM;
    514                                 }
    515                         }
    516                         break;
    517                 }
    518                 case SOCK_DGRAM: {
    519                         T_IPV4EP rep = { 0, 0 };
    520                         ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len, (fp->psock->flags & O_NONBLOCK) ? 0 : TMO_FEVR);
    521                         if (ret < 0) {
    522                                 return -ECOMM;
    523                         }
    524                 }
    525                 }
    526                 break;
    527         }
    528         case AF_INET6: {
    529                 return -EAFNOSUPPORT;
    530         }
    531         }
    532 
    533         return ret;
    534 }
    535 
    536 ssize_t shell_recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *__restrict addr, socklen_t *__restrict alen)
    537 {
    538         SOCKET *fp = fd_to_fp(fd);
    539         if (fp == NULL) {
    540                 return -EBADF;
    541         }
    542 
    543         int ret = 0;
    544         switch (fp->psock->family) {
    545         case AF_INET: {
    546                 switch (fp->psock->type) {
    547                 case SOCK_STREAM: {
    548                         if (flags & MSG_OOB) {
    549                                 ret = tcp_rcv_oob(fp->psock->cepid, buf, len);
     550                                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     551                                }
     552
     553                                T_IPV4EP rep = { 0, 0 };
     554                                ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len,
     555                                        (fp->psock->flags & O_NONBLOCK) ? TMO_POL : SOCKET_TIMEOUT);
    550556                                if (ret < 0) {
    551                                         return -ECOMM;
     557                                        syslog(LOG_ERROR, "udp_rcv_buf => %d", ret);
     558                                        return (ret == E_TMOUT) ? -ETIME : -ECOMM;
     559                                }
     560                                rsz = ret;
     561                                if ((addr != NULL) && (alen != NULL)) {
     562                                        ret = wai_sem(SEM_FILEDESC);
     563                                        if (ret < 0) {
     564                                                syslog(LOG_ERROR, "wai_sem => %d", ret);
     565                                        }
     566                                        int sz = *alen;
     567                                        memset(raddr, 0, sizeof(fp->psock->raddr4));
     568                                        raddr->sin_family = AF_INET;
     569                                        raddr->sin_port = htons(rep.portno);
     570                                        raddr->sin_addr.s_addr = htonl(rep.ipaddr);
     571                                        if (sz > sizeof(fp->psock->raddr4))
     572                                                sz = sizeof(fp->psock->raddr4);
     573                                        memcpy(addr, raddr, sz);
     574                                        *alen = sz;
     575                                        ret = sig_sem(SEM_FILEDESC);
     576                                        if (ret < 0) {
     577                                                syslog(LOG_ERROR, "sig_sem => %d", ret);
     578                                        }
    552579                                }
    553580                        }
    554581                        else {
    555                                 ret = tcp_rcv_dat(fp->psock->cepid, buf, len, TMO_FEVR);
     582                                rsz = fp->psock->len;
     583                                void *pbuf = fp->psock->buf;
     584                                fp->psock->input = NULL;
     585                                fp->psock->len = 0;
     586                                fp->psock->buf = NULL;
     587                                if ((addr != NULL) && (alen != NULL)) {
     588                                        int sz = *alen;
     589                                        if (sz > sizeof(fp->psock->raddr4))
     590                                                sz = sizeof(fp->psock->raddr4);
     591                                        memcpy(addr, raddr, sz);
     592                                        *alen = sz;
     593                                }
     594                                ret = sig_sem(SEM_FILEDESC);
    556595                                if (ret < 0) {
    557                                         return -ECOMM;
    558                                 }
    559                         }
    560                         break;
    561                 }
    562                 case SOCK_DGRAM: {
    563                         T_IPV4EP rep = { 0, 0 };
    564                         ret = udp_rcv_dat(fp->psock->cepid, &rep, buf, len, TMO_FEVR);
    565                         if (ret < 0) {
    566                                 return -ECOMM;
    567                         }
    568                         int sz = *alen;
    569                         struct sockaddr_in raddr;
    570                         memset(&raddr, 0, sizeof(raddr));
    571                         raddr.sin_family = AF_INET;
    572                         raddr.sin_port = htons(rep.portno);
    573                         raddr.sin_addr.s_addr = htonl(rep.ipaddr);
    574                         if (sz > sizeof(raddr))
    575                                 sz = sizeof(raddr);
    576                         memcpy(addr, &raddr, sz);
     596                                        syslog(LOG_ERROR, "sig_sem => %d", ret);
     597                                }
     598                                if (rsz > len)
     599                                        rsz = len;
     600                                memcpy(buf, pbuf, rsz);
     601                                ret = rel_net_buf(input);
     602                                if (ret < 0) {
     603                                        syslog(LOG_ERROR, "rel_net_buf => %d", ret);
     604                                        //return -ECOMM;
     605                                }
     606                        }
     607                        ret = rsz;
    577608                }
    578609                }
     
    830861int tcp_fd_close(struct _IO_FILE *fp)
    831862{
    832         ER ret;
    833 
    834         free(fp->psock->buf);
    835         fp->psock->buf = NULL;
     863        ER ret, ret2;
    836864
    837865        switch (fp->psock->family) {
     
    844872                        }
    845873                        ret = tcp_cls_cep(cepid, (fp->psock->repid != 0) ? 0 : SOCKET_TIMEOUT);
    846                         if (ret < 0) {
    847                                 //return -1;
    848                         }
    849                         ret = tcp_del_cep(cepid);
     874                        ret2 = tcp_del_cep(cepid);
     875                        free(fp->psock->buf);
     876                        fp->psock->buf = NULL;
    850877                        delete_tcp_fd(cepid);
    851878                        delete_id(tcp_cepid_table, tcp_cepid_table_count, cepid);
    852                         if (ret < 0) {
    853                                 return -EINVAL;
     879                        if ((ret < 0) || (ret2 < 0)) {
     880                                return (ret == E_TMOUT) ? -ETIME : -EINVAL;
    854881                        }
    855882                }
     
    857884                        ID repid = fp->psock->repid;
    858885                        ret = tcp_del_rep(repid);
     886                        free(fp->psock->buf);
     887                        fp->psock->buf = NULL;
    859888                        delete_tcp_fd(tmax_tcp_cepid + repid);
    860889                        delete_id(tcp_repid_table, tcp_repid_table_count, repid);
     
    864893                }
    865894                else {
     895                        free(fp->psock->buf);
     896                        fp->psock->buf = NULL;
    866897                        return -EINVAL;
    867898                }
     
    878909size_t tcp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
    879910{
    880         return shell_recv(fp->fd, dst, dstsz, 0);
     911        return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL);
    881912}
    882913
    883914size_t tcp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
    884915{
    885         return shell_send(fp->fd, src, srcsz, 0);
     916        return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0);
    886917}
    887918
     
    901932        ID cepid;
    902933
    903         free(fp->psock->buf);
    904         fp->psock->buf = NULL;
    905 
    906934        switch (fp->psock->family) {
    907935        case AF_INET: {
    908936                cepid = fp->psock->cepid;
    909937                ret = udp_del_cep(cepid);
     938                //free(fp->psock->buf);
     939                //fp->psock->buf = NULL;
    910940                delete_udp_fd(cepid);
    911941                delete_id(udp_cepid_table, udp_cepid_table_count, cepid);
     
    925955size_t udp_fd_read(struct _IO_FILE *fp, unsigned char *dst, size_t dstsz)
    926956{
    927         return shell_recv(fp->fd, dst, dstsz, 0);
     957        return shell_recvfrom(fp->fd, dst, dstsz, 0, NULL, NULL);
    928958}
    929959
    930960size_t udp_fd_write(struct _IO_FILE *fp, const unsigned char *src, size_t srcsz)
    931961{
    932         return shell_send(fp->fd, src, srcsz, 0);
     962        return shell_sendto(fp->fd, src, srcsz, 0, NULL, 0);
    933963}
    934964
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/socket_stub.h

    r352 r364  
    9999        int buf_size;
    100100        unsigned char *buf;
     101        void *input;
     102        int len;
    101103} socket_t;
    102104
  • asp3_tinet_ecnl_arm/trunk/ntshell/src/syscall.c

    r352 r364  
    201201
    202202long SYS_futex() {
     203        int futex(int *uaddr, int op, int val, const struct timespec *timeout, int *uaddr2, int val3);
    203204        return no_implement("futex\n");
    204205}
     
    309310
    310311long SYS_recv(long a, long b, long c, long d) {
    311         return shell_recv((int)a, (void *)b, (size_t)c, (int)d);
     312        return shell_recvfrom((int)a, (void *)b, (size_t)c, (int)d, NULL, NULL);
    312313}
    313314
    314315long SYS_recvfrom(long a, long b, long c, long d, long e, long f) {
    315         if (a == 0)
    316                 return shell_recv(a, (void *)b, (size_t)c, (int)d);
    317         else
    318                 return shell_recvfrom(a, (void *)b, (size_t)c, (int)d, (struct sockaddr *)e, (socklen_t *)f);
     316        return shell_recvfrom(a, (void *)b, (size_t)c, (int)d, (struct sockaddr *)e, (socklen_t *)f);
    319317}
    320318
     
    344342
    345343long SYS_send(long a, long b, long c, long d) {
    346         return shell_send((int)a, (const void *)b, (size_t)c, (int)d);
     344        return shell_sendto((int)a, (const void *)b, (size_t)c, (int)d, NULL, 0);
    347345}
    348346
     
    352350
    353351long SYS_sendto(long a, long b, long c, long d, long e, long f) {
    354         if (a == 0)
    355                 return shell_send(a, (const void *)b, (size_t)c, (int)d);
    356         else
    357                 return shell_sendto(a, (const void *)b, (size_t)c, (int)d, (const struct sockaddr *)e, (socklen_t)f);
     352        return shell_sendto(a, (const void *)b, (size_t)c, (int)d, (const struct sockaddr *)e, (socklen_t)f);
    358353}
    359354
     
    422417}
    423418
     419long SYS_dup()
     420{
     421        return no_implement("dup\n");
     422}
     423
     424long SYS_dup2()
     425{
     426        return no_implement("dup2\n");
     427}
     428
     429long SYS_pipe()
     430{
     431        return no_implement("pipe\n");
     432}
     433
     434long SYS_readlink()
     435{
     436        return no_implement("readlink\n");
     437}
     438
     439long SYS_symlink()
     440{
     441        return no_implement("symlink\n");
     442}
     443
     444long SYS_umask()
     445{
     446        return no_implement("umask\n");
     447}
     448
     449long SYS_execve()
     450{
     451        return no_implement("execve\n");
     452}
     453
     454long SYS_fork()
     455{
     456        return no_implement("fork\n");
     457}
     458
     459long SYS_wait4()
     460{
     461        return no_implement("wait4\n");
     462}
     463
     464long SYS_socketpair()
     465{
     466        return no_implement("socketpair\n");
     467}
     468
     469long SYS_flock()
     470{
     471        return no_implement("flock\n");
     472}
     473
    424474long ARM_SYS_cacheflush() {
    425475        flash_access_cache_control();
  • asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/.cproject

    r352 r364  
    2424                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2525                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    26                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     26                                <option id="toolchain.version" value="6.3.1.20170620"/>
    2727                        </storageModule>
    2828                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    6969                                                                <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="com.renesas.cdt.managedbuild.gcc.rz.option.compiler.include.75756997" name="Include paths (-I)" superClass="com.renesas.cdt.managedbuild.gcc.rz.option.compiler.include" useByScannerDiscovery="false" valueType="includePath">
    7070                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/musl-1.1.18/include}&quot;"/>
     71                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/zlib-1.2.11/src}&quot;"/>
    7172                                                                        <listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}&quot;"/>
    7273                                                                </option>
     
    7677                                                                        <listOptionValue builtIn="false" value="WOLFSSL_SHA512"/>
    7778                                                                        <listOptionValue builtIn="false" value="HAVE_CONFIG_H"/>
     79                                                                        <listOptionValue builtIn="false" value="WOLFSSL_USER_SETTINGS"/>
    7880                                                                </option>
    7981                                                                <inputType id="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input.787222748" superClass="ilg.gnuarmeclipse.managedbuild.cross.tool.c.compiler.input"/>
     
    142144                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    143145                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    144                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     146                                <option id="toolchain.version" value="6.3.1.20170620"/>
    145147                        </storageModule>
    146148                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
  • asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/src/internal.c

    r352 r364  
    1637816378            if (ret != 0)
    1637916379                return ret;
     16380
     16381            word32 tim = LowResTimer();
     16382            *((word32 *)(output + idx)) = (tim >> 24) | ((tim & 0xFF0000) >> 8)
     16383                | ((tim & 0xFF00) << 8)| (tim << 24);
    1638016384
    1638116385            /* store random */
  • asp3_tinet_ecnl_arm/trunk/wolfssl-3.12.2/user_settings.h

    r352 r364  
    11//#define DEBUG_WOLFSSL
    22
     3#define HAVE_LIBZ
    34#define HAVE_ECC
     5#define HAVE_AESGCM
    46//#define HAVE_FIPS
     7#define HAVE_SNI
     8#define HAVE_TLS_EXTENSIONS
     9#define HAVE_SUPPORTED_CURVES
    510
    611#define ECC_TIMING_RESISTANT
  • asp3_tinet_ecnl_arm/trunk/zlib-1.2.11/.cproject

    r352 r364  
    2424                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    2525                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    26                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     26                                <option id="toolchain.version" value="6.3.1.20170620"/>
    2727                        </storageModule>
    2828                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
     
    129129                        <storageModule moduleId="com.renesas.cdt.managedbuild.core.toolchainInfo">
    130130                                <option id="toolchain.id" value="gcc-arm-embedded"/>
    131                                 <option id="toolchain.version" value="5.4.1.20160919"/>
     131                                <option id="toolchain.version" value="6.3.1.20170620"/>
    132132                        </storageModule>
    133133                        <storageModule moduleId="cdtBuildSystem" version="4.0.0">
Note: See TracChangeset for help on using the changeset viewer.