[388] | 1 | #ifndef tMessageBufferCEP__INLINE_H
|
---|
| 2 | #define tMessageBufferCEP__INLINE_H
|
---|
| 3 |
|
---|
| 4 | /* #[<PREAMBLE>]#
|
---|
| 5 | * #[<...>]# から #[</...>]# で囲まれたコメントは編集しないでください
|
---|
| 6 | * tecsmerge によるマージに使用されます
|
---|
| 7 | *
|
---|
| 8 | * 呼び口関数 #_TCPF_#
|
---|
| 9 | * call port: cMessageBuffer0 signature: sMessageBuffer context:task
|
---|
| 10 | * ER cMessageBuffer0_send( const uint8_t* message, uint32_t size );
|
---|
| 11 | * ER cMessageBuffer0_sendPolling( const uint8_t* message, uint32_t size );
|
---|
| 12 | * ER cMessageBuffer0_sendTimeout( const uint8_t* message, uint32_t size, TMO timeout );
|
---|
| 13 | * ER_UINT cMessageBuffer0_receive( uint8_t* message );
|
---|
| 14 | * ER_UINT cMessageBuffer0_receivePolling( uint8_t* message );
|
---|
| 15 | * ER_UINT cMessageBuffer0_receiveTimeout( uint8_t* message, TMO timeout );
|
---|
| 16 | * ER cMessageBuffer0_initialize( );
|
---|
| 17 | * ER cMessageBuffer0_refer( T_RMBF* pk_messageBufferStatus );
|
---|
| 18 | * call port: cMessageBuffer1 signature: sMessageBuffer context:task
|
---|
| 19 | * ER cMessageBuffer1_send( const uint8_t* message, uint32_t size );
|
---|
| 20 | * ER cMessageBuffer1_sendPolling( const uint8_t* message, uint32_t size );
|
---|
| 21 | * ER cMessageBuffer1_sendTimeout( const uint8_t* message, uint32_t size, TMO timeout );
|
---|
| 22 | * ER_UINT cMessageBuffer1_receive( uint8_t* message );
|
---|
| 23 | * ER_UINT cMessageBuffer1_receivePolling( uint8_t* message );
|
---|
| 24 | * ER_UINT cMessageBuffer1_receiveTimeout( uint8_t* message, TMO timeout );
|
---|
| 25 | * ER cMessageBuffer1_initialize( );
|
---|
| 26 | * ER cMessageBuffer1_refer( T_RMBF* pk_messageBufferStatus );
|
---|
| 27 | *
|
---|
| 28 | * #[</PREAMBLE>]# */
|
---|
| 29 |
|
---|
| 30 | /* 受け口関数 #_TEPF_# */
|
---|
| 31 | /* #[<ENTRY_PORT>]# eChannel
|
---|
| 32 | * entry port: eChannel
|
---|
| 33 | * signature: sChannel
|
---|
| 34 | 2 * context: task
|
---|
| 35 | * #[</ENTRY_PORT>]# */
|
---|
| 36 |
|
---|
| 37 | /* #[<ENTRY_FUNC>]# eChannel_send
|
---|
| 38 | * name: eChannel_send
|
---|
| 39 | * global_name: tMessageBufferCEP_eChannel_send
|
---|
| 40 | * oneway: false
|
---|
| 41 | * #[</ENTRY_FUNC>]# */
|
---|
| 42 | Inline ER
|
---|
| 43 | eChannel_send(CELLIDX idx, const int8_t* buf, int16_t size, TMO tmo)
|
---|
| 44 | {
|
---|
| 45 | ER ercd = E_OK;
|
---|
| 46 | int16_t write_count;
|
---|
| 47 | CELLCB *p_cellcb;
|
---|
| 48 | if (VALID_IDX(idx)) {
|
---|
| 49 | p_cellcb = GET_CELLCB(idx);
|
---|
| 50 | }
|
---|
| 51 | else {
|
---|
| 52 | return(E_ID);
|
---|
| 53 | } /* end if VALID_IDX(idx) */
|
---|
| 54 | (void)p_cellcb; // to avoid unused warning
|
---|
| 55 |
|
---|
| 56 | /* ここに処理本体を記述します #_TEFB_# */
|
---|
| 57 | if( size < 0 )
|
---|
| 58 | return E_PAR;
|
---|
| 59 | else if( size == 0 )
|
---|
| 60 | return E_OK;
|
---|
| 61 |
|
---|
| 62 | write_count = 0;
|
---|
| 63 | while( write_count < size ){
|
---|
| 64 | VAR_write_buf[ VAR_write_count++ ] = buf[ write_count++ ];
|
---|
| 65 | if( VAR_write_count >= ATTR_buf_size ){
|
---|
| 66 | ercd = eChannel_flush( idx, tmo);
|
---|
| 67 | if( ercd != E_OK ){
|
---|
| 68 | break;
|
---|
| 69 | }
|
---|
| 70 | }
|
---|
| 71 | }
|
---|
| 72 |
|
---|
| 73 | // syslog( LOG_INFO, "eChannel_send ercd=%d", ercd );
|
---|
| 74 | return(ercd);
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | /* #[<ENTRY_FUNC>]# eChannel_flush
|
---|
| 78 | * name: eChannel_flush
|
---|
| 79 | * global_name: tMessageBufferCEP_eChannel_flush
|
---|
| 80 | * oneway: false
|
---|
| 81 | * #[</ENTRY_FUNC>]# */
|
---|
| 82 | Inline ER
|
---|
| 83 | eChannel_flush(CELLIDX idx, TMO tmo)
|
---|
| 84 | {
|
---|
| 85 | ER ercd = E_OK;
|
---|
| 86 | CELLCB *p_cellcb;
|
---|
| 87 | if (VALID_IDX(idx)) {
|
---|
| 88 | p_cellcb = GET_CELLCB(idx);
|
---|
| 89 | }
|
---|
| 90 | else {
|
---|
| 91 | return(E_ID);
|
---|
| 92 | } /* end if VALID_IDX(idx) */
|
---|
| 93 | (void)p_cellcb; // to avoid unused warning
|
---|
| 94 |
|
---|
| 95 | /* ここに処理本体を記述します #_TEFB_# */
|
---|
| 96 | /* flush しなくても、いつも送られる */
|
---|
| 97 | if( VAR_write_count > 0 ){
|
---|
| 98 | ercd = cMessageBuffer0_sendTimeout( (const uint8_t *)VAR_write_buf, VAR_write_count, tmo );
|
---|
| 99 | }
|
---|
| 100 | // syslog( LOG_INFO, "eChannel_flush ercd=%d count=%d", ercd, VAR_write_count );
|
---|
| 101 | VAR_write_count = 0;
|
---|
| 102 | return(ercd);
|
---|
| 103 | }
|
---|
| 104 |
|
---|
| 105 | /* #[<ENTRY_FUNC>]# eChannel_receive
|
---|
| 106 | * name: eChannel_receive
|
---|
| 107 | * global_name: tMessageBufferCEP_eChannel_receive
|
---|
| 108 | * oneway: false
|
---|
| 109 | * #[</ENTRY_FUNC>]# */
|
---|
| 110 | Inline ER_UINT
|
---|
| 111 | eChannel_receive(CELLIDX idx, int8_t* buf, int16_t size, TMO tmo)
|
---|
| 112 | {
|
---|
| 113 | ER ercd = E_OK;
|
---|
| 114 | CELLCB *p_cellcb;
|
---|
| 115 | int16_t count = 0;
|
---|
| 116 | if (VALID_IDX(idx)) {
|
---|
| 117 | p_cellcb = GET_CELLCB(idx);
|
---|
| 118 | }
|
---|
| 119 | else {
|
---|
| 120 | return(E_ID);
|
---|
| 121 | } /* end if VALID_IDX(idx) */
|
---|
| 122 | (void)p_cellcb; // to avoid unused warning
|
---|
| 123 |
|
---|
| 124 | /* ここに処理本体を記述します #_TEFB_# */
|
---|
| 125 | if( size == 0 )
|
---|
| 126 | return 0;
|
---|
| 127 |
|
---|
| 128 | while( count < size ){
|
---|
| 129 | if( VAR_n_read_buf_filled == 0 ){
|
---|
| 130 | ercd = cMessageBuffer1_receiveTimeout( (uint8_t *)VAR_read_buf, tmo );
|
---|
| 131 | if( ercd < 0 )
|
---|
| 132 | break;
|
---|
| 133 | VAR_n_read_buf_filled = ercd;
|
---|
| 134 | }
|
---|
| 135 | while( count < size && VAR_read_count < VAR_n_read_buf_filled ){
|
---|
| 136 | buf[ count ] = VAR_read_buf[ VAR_read_count ];
|
---|
| 137 | count++;
|
---|
| 138 | VAR_read_count++;
|
---|
| 139 | }
|
---|
| 140 | if( VAR_read_count >= VAR_n_read_buf_filled ){
|
---|
| 141 | VAR_n_read_buf_filled = 0;
|
---|
| 142 | VAR_read_count = 0;
|
---|
| 143 | }
|
---|
| 144 | ercd = count;
|
---|
| 145 | }
|
---|
| 146 | // syslog( LOG_INFO, "eChannel_receive ercd=%d", ercd );
|
---|
| 147 |
|
---|
| 148 | return(ercd);
|
---|
| 149 | }
|
---|
| 150 |
|
---|
| 151 | /* #[<ENTRY_FUNC>]# eChannel_end_receive
|
---|
| 152 | * name: eChannel_end_receive
|
---|
| 153 | * global_name: tMessageBufferCEP_eChannel_end_receive
|
---|
| 154 | * oneway: false
|
---|
| 155 | * #[</ENTRY_FUNC>]# */
|
---|
| 156 | Inline ER
|
---|
| 157 | eChannel_end_receive(CELLIDX idx)
|
---|
| 158 | {
|
---|
| 159 | ER ercd = E_OK;
|
---|
| 160 | CELLCB *p_cellcb;
|
---|
| 161 | if (VALID_IDX(idx)) {
|
---|
| 162 | p_cellcb = GET_CELLCB(idx);
|
---|
| 163 | }
|
---|
| 164 | else {
|
---|
| 165 | return(E_ID);
|
---|
| 166 | } /* end if VALID_IDX(idx) */
|
---|
| 167 | (void)p_cellcb; // to avoid unused warning
|
---|
| 168 |
|
---|
| 169 | /* ここに処理本体を記述します #_TEFB_# */
|
---|
| 170 |
|
---|
| 171 | return(ercd);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
| 174 | /* #[<ENTRY_FUNC>]# eChannel_reset
|
---|
| 175 | * name: eChannel_reset
|
---|
| 176 | * global_name: tMessageBufferCEP_eChannel_reset
|
---|
| 177 | * oneway: false
|
---|
| 178 | * #[</ENTRY_FUNC>]# */
|
---|
| 179 | Inline ER
|
---|
| 180 | eChannel_reset(CELLIDX idx)
|
---|
| 181 | {
|
---|
| 182 | ER ercd0 = E_OK, ercd1 = E_OK;
|
---|
| 183 | CELLCB *p_cellcb;
|
---|
| 184 | if (VALID_IDX(idx)) {
|
---|
| 185 | p_cellcb = GET_CELLCB(idx);
|
---|
| 186 | }
|
---|
| 187 | else {
|
---|
| 188 | return(E_ID);
|
---|
| 189 | } /* end if VALID_IDX(idx) */
|
---|
| 190 | (void)p_cellcb; // to avoid unused warning
|
---|
| 191 |
|
---|
| 192 | /* ここに処理本体を記述します #_TEFB_# */
|
---|
| 193 | ercd0 = cMessageBuffer0_initialize( );
|
---|
| 194 | ercd1 = cMessageBuffer1_initialize( );
|
---|
| 195 |
|
---|
| 196 | return(ercd1 != E_OK ? ercd1 : ercd0);
|
---|
| 197 | }
|
---|
| 198 |
|
---|
| 199 | /* #[<POSTAMBLE>]#
|
---|
| 200 | * これより下に非受け口関数を書きます
|
---|
| 201 | * #[</POSTAMBLE>]#*/
|
---|
| 202 |
|
---|
| 203 | #endif /* tMessageBufferCEP_INLINEH */
|
---|