Changeset 114
- Timestamp:
- 06/28/2007 01:59:37 AM (5 years ago)
- Location:
- nano-RK
- Files:
-
- 8 added
- 15 edited
-
projects/basic_sensors/makefile (modified) (1 diff)
-
projects/basic_signals/makefile (modified) (1 diff)
-
projects/basic_slip/main.c (modified) (5 diffs)
-
projects/basic_slip/makefile (modified) (1 diff)
-
projects/basic_slip/nrk_cfg.h (modified) (1 diff)
-
src/drivers/platform/firefly2_2/source/adc_driver.c (modified) (2 diffs)
-
src/drivers/platform/firefly2_2/source/ff_basic_sensor.c (modified) (1 diff)
-
src/kernel/include/nrk_error.h (modified) (1 diff)
-
src/kernel/include/nrk_events.h (modified) (1 diff)
-
src/kernel/source/nrk_error.c (modified) (1 diff)
-
src/kernel/source/nrk_events.c (modified) (1 diff)
-
src/net/slip/slip.c (modified) (2 diffs)
-
src/net/slip/slip.h (modified) (1 diff)
-
src/platform/firefly2_2/source/ulib.c (modified) (4 diffs)
-
src/platform/include/ulib.h (modified) (1 diff)
-
tools (added)
-
tools/SLIPstream (added)
-
tools/SLIPstream/SLIPstream-client (added)
-
tools/SLIPstream/SLIPstream-client/makefile (added)
-
tools/SLIPstream/SLIPstream-client/sample-client.c (added)
-
tools/SLIPstream/SLIPstream-server (added)
-
tools/SLIPstream/SLIPstream-server/main.c (added)
-
tools/SLIPstream/SLIPstream-server/makefile (added)
Legend:
- Unmodified
- Added
- Removed
-
nano-RK/projects/basic_sensors/makefile
r107 r114 1 1 # Platform name cc2420DK, firefly, micaZ, firefly2, firefly2_2 2 PLATFORM = firefly2 2 PLATFORM = firefly2_2 3 3 4 4 -
nano-RK/projects/basic_signals/makefile
r50 r114 1 1 # Platform name cc2420DK, firefly, micaZ, firefly2, firefly2_2 2 PLATFORM = firefly2 2 PLATFORM = firefly2_2 3 3 4 4 -
nano-RK/projects/basic_slip/main.c
r47 r114 9 9 #include <slip.h> 10 10 11 #define MAX_SLIP_BUF 48 11 12 12 13 NRK_STK Stack1[NRK_APP_STACKSIZE]; 13 14 nrk_task_type TaskOne; 14 void Task1 (void);15 void Task1 (void); 15 16 16 17 NRK_STK Stack2[NRK_APP_STACKSIZE]; … … 22 23 void Task3 (void); 23 24 25 void nrk_create_taskset (); 24 26 25 NRK_STK Stack4[NRK_APP_STACKSIZE]; 26 nrk_task_type TaskFour; 27 void Task4 (void); 27 uint8_t slip_buf[MAX_SLIP_BUF]; 28 28 29 void nrk_create_taskset(); 30 uint8_t kill_stack(uint8_t val); 29 int main () 30 { 31 nrk_setup_ports (); 32 // PORTE |= 2; 33 // DDRA &= ~(0x10); 34 nrk_setup_uart (UART_BAUDRATE_115K2); 31 35 32 int 33 main () 34 { 35 nrk_setup_ports(); 36 PORTE |= 2; 37 DDRA &= ~(0x10); 38 nrk_setup_uart(UART_BAUDRATE_9K6); 36 printf ("Starting up...\r\n"); 39 37 40 printf( "Starting up...\r\n");38 nrk_init (); 41 39 42 nrk_init(); 40 nrk_led_clr (ORANGE_LED); 41 nrk_led_clr (BLUE_LED); 42 nrk_led_clr (GREEN_LED); 43 nrk_led_clr (RED_LED); 43 44 44 nrk_led_clr(ORANGE_LED); 45 nrk_led_clr(BLUE_LED); 46 nrk_led_clr(GREEN_LED); 47 nrk_led_clr(RED_LED); 45 nrk_time_set (0, 0); 46 nrk_create_taskset (); 47 nrk_start (); 48 48 49 nrk_time_set(0,0);50 nrk_create_taskset ();51 nrk_start();52 53 49 return 0; 54 50 } 55 51 56 52 57 void Task1 ()53 void Task1 () 58 54 { 59 uint16_t cnt;60 uint8_t buf[32];61 printf( "My node's address is %d\r\n",NODE_ADDR);55 uint16_t cnt; 56 uint8_t buf[32], len; 57 printf ("My node's address is %d\r\n", NODE_ADDR); 62 58 63 printf ( "Task1 PID=%d\r\n",nrk_get_pid());64 cnt =0;65 slip_init (stdin,stdout,0,0);66 while(1) { 67 nrk_led_set(ORANGE_LED); 68 buf[0]=66;69 buf[1]=(cnt>>8)&0xFF;70 buf[2]=cnt&0xFF;71 slip_tx(buf,3); 72 nrk_wait_until_next_period();73 nrk_led_clr(ORANGE_LED);74 nrk_wait_until_next_period();75 cnt++;76 }59 printf ("Task1 PID=%d\r\n", nrk_get_pid ()); 60 cnt = 0; 61 slip_init (stdin, stdout, 0, 0); 62 63 while (1) { 64 nrk_led_set (ORANGE_LED); 65 sprintf (buf, "Hello %d", cnt); 66 len = strlen (buf); 67 slip_tx (buf, len); 68 nrk_wait_until_next_period (); 69 nrk_led_clr (ORANGE_LED); 70 nrk_wait_until_next_period (); 71 cnt++; 72 } 77 73 } 78 74 79 void Task2 ()75 void Task2 () 80 76 { 81 77 uint8_t cnt; 82 printf ( "Task2 PID=%d\r\n",nrk_get_pid());83 cnt =0;84 while (1) {85 nrk_led_set(BLUE_LED);86 printf( "Task2 cnt=%d\r\n",cnt);87 nrk_wait_until_next_period();88 nrk_led_clr(BLUE_LED);89 nrk_wait_until_next_period();90 cnt++;91 }78 printf ("Task2 PID=%d\r\n", nrk_get_pid ()); 79 cnt = 0; 80 while (1) { 81 nrk_led_set (BLUE_LED); 82 printf ("Task2 cnt=%d\r\n", cnt); 83 nrk_wait_until_next_period (); 84 nrk_led_clr (BLUE_LED); 85 nrk_wait_until_next_period (); 86 cnt++; 87 } 92 88 } 93 89 94 void Task3 ()90 void Task3 () 95 91 { 96 uint16_t cnt; 92 int8_t v; 93 int8_t i; 94 printf ("Task3 PID=%d\r\n", nrk_get_pid ()); 95 while (slip_started () != 1) 96 nrk_wait_until_next_period (); 97 97 98 printf( "Task3 PID=%d\r\n",nrk_get_pid()); 99 cnt=0; 100 while(1) { 101 nrk_led_set(GREEN_LED); 102 printf( "Task3 cnt=%d\r\n",cnt ); 103 nrk_wait_until_next_period(); 104 nrk_led_clr(GREEN_LED); 105 nrk_wait_until_next_period(); 106 cnt++; 107 } 98 while (1) { 99 nrk_led_toggle (GREEN_LED); 100 printf ("Task3\r\n"); 101 102 v = slip_rx (slip_buf, MAX_SLIP_BUF); 103 104 if (v > 0) { 105 nrk_kprintf (PSTR ("Task3 got data: ")); 106 for (i = 0; i < v; i++) 107 printf ("%c", slip_buf[i]); 108 printf ("\r\n"); 109 } 110 else 111 nrk_kprintf (PSTR ("Task3 data failed\r\n")); 112 113 nrk_wait_until_next_period (); 114 } 108 115 } 109 116 110 void Task4()111 {112 uint16_t cnt;113 117 114 printf( "Task4 PID=%d\r\n",nrk_get_pid());115 cnt=0;116 while(1) {117 nrk_led_set(RED_LED);118 printf( "Task4 cnt=%d\r\n",cnt );119 nrk_wait_until_next_period();120 nrk_led_clr(RED_LED);121 nrk_wait_until_next_period();122 cnt++;123 }124 }125 118 126 void 127 nrk_create_taskset() 119 void nrk_create_taskset () 128 120 { 129 121 TaskOne.task = Task1; 130 TaskOne.Ptos = (void *) &Stack1[NRK_APP_STACKSIZE ];122 TaskOne.Ptos = (void *) &Stack1[NRK_APP_STACKSIZE - 1]; 131 123 TaskOne.Pbos = (void *) &Stack1[0]; 132 124 TaskOne.prio = 1; … … 135 127 TaskOne.SchType = PREEMPTIVE; 136 128 TaskOne.period.secs = 1; 137 TaskOne.period.nano_secs = 500 *NANOS_PER_MS;129 TaskOne.period.nano_secs = 500 * NANOS_PER_MS; 138 130 TaskOne.cpu_reserve.secs = 0; 139 TaskOne.cpu_reserve.nano_secs = 500*NANOS_PER_MS;131 TaskOne.cpu_reserve.nano_secs = 500 * NANOS_PER_MS; 140 132 TaskOne.offset.secs = 0; 141 TaskOne.offset.nano_secs = 0;133 TaskOne.offset.nano_secs = 0; 142 134 nrk_activate_task (&TaskOne); 143 135 144 136 TaskTwo.task = Task2; 145 TaskTwo.Ptos = (void *) &Stack2[NRK_APP_STACKSIZE ];137 TaskTwo.Ptos = (void *) &Stack2[NRK_APP_STACKSIZE - 1]; 146 138 TaskTwo.Pbos = (void *) &Stack2[0]; 147 139 TaskTwo.prio = 2; … … 150 142 TaskTwo.SchType = PREEMPTIVE; 151 143 TaskTwo.period.secs = 0; 152 TaskTwo.period.nano_secs = 500*NANOS_PER_MS;144 TaskTwo.period.nano_secs = 250 * NANOS_PER_MS; 153 145 TaskTwo.cpu_reserve.secs = 0; 154 TaskTwo.cpu_reserve.nano_secs = 100 *NANOS_PER_MS;146 TaskTwo.cpu_reserve.nano_secs = 100 * NANOS_PER_MS; 155 147 TaskTwo.offset.secs = 0; 156 TaskTwo.offset.nano_secs= 0; 157 //nrk_activate_task (&TaskTwo); 158 148 TaskTwo.offset.nano_secs = 0; 149 nrk_activate_task (&TaskTwo); 159 150 160 151 TaskThree.task = Task3; 161 TaskThree.Ptos = (void *) &Stack3[NRK_APP_STACKSIZE ];152 TaskThree.Ptos = (void *) &Stack3[NRK_APP_STACKSIZE - 1]; 162 153 TaskThree.Pbos = (void *) &Stack3[0]; 163 154 TaskThree.prio = 3; … … 166 157 TaskThree.SchType = PREEMPTIVE; 167 158 TaskThree.period.secs = 0; 168 TaskThree.period.nano_secs = 750*NANOS_PER_MS;159 TaskThree.period.nano_secs = 250 * NANOS_PER_MS; 169 160 TaskThree.cpu_reserve.secs = 0; 170 TaskThree.cpu_reserve.nano_secs = 100 *NANOS_PER_MS;161 TaskThree.cpu_reserve.nano_secs = 100 * NANOS_PER_MS; 171 162 TaskThree.offset.secs = 0; 172 TaskThree.offset.nano_secs = 0;173 //nrk_activate_task (&TaskThree);163 TaskThree.offset.nano_secs = 0; 164 nrk_activate_task (&TaskThree); 174 165 175 166 176 TaskFour.task = Task4;177 TaskFour.Ptos = (void *) &Stack4[NRK_APP_STACKSIZE];178 TaskFour.Pbos = (void *) &Stack4[0];179 TaskFour.prio = 4;180 TaskFour.FirstActivation = TRUE;181 TaskFour.Type = BASIC_TASK;182 TaskFour.SchType = PREEMPTIVE;183 TaskFour.period.secs = 1;184 TaskFour.period.nano_secs = 0;185 TaskFour.cpu_reserve.secs = 0;186 TaskFour.cpu_reserve.nano_secs = 100*NANOS_PER_MS;187 TaskFour.offset.secs = 0;188 TaskFour.offset.nano_secs= 0;189 //nrk_activate_task (&TaskFour);190 167 191 192 //printf ("Create done\r\n");193 168 } 194 195 uint8_t kill_stack(uint8_t val)196 {197 char bad_memory[10];198 uint8_t i;199 for(i=0; i<10; i++ ) bad_memory[i]=i;200 for(i=0; i<10; i++ ) printf( "%d ", bad_memory[i]);201 printf( "Die Stack %d\r\n",val );202 if(val>1) kill_stack(val-1);203 return 0;204 }205 206 -
nano-RK/projects/basic_slip/makefile
r38 r114 1 1 # Platform name cc2420DK, firefly, micaZ, firefly2, firefly2_2 2 PLATFORM = firefly2 2 PLATFORM = firefly2_2 3 3 4 4 -
nano-RK/projects/basic_slip/nrk_cfg.h
r39 r114 22 22 #define NRK_NO_POWER_DOWN 23 23 24 #define NRK_MAX_TASKS 1 // Max number of tasks in your application 25 #define NRK_N_SYS_TASKS 1 // you need at least the idle task 26 #define NRK_N_RES 1 27 28 //#define NRK_DRIVER_FREQ 250 29 //#define NRK_MAX_DRIVER_CNT 1 24 // This must be greater than or equal to the highest priority task that uses 25 // the serial port (i.e. print of nrk_kprintf) 26 #define SLIP_PCP_CEILING 18 27 28 // Enable buffered and signal controlled serial RX 29 #define NRK_UART_BUF 1 30 // Set buffer to MAX slip packet size 31 #define MAX_RX_UART_BUF 128 32 33 34 #define NRK_MAX_TASKS 4 // Max number of tasks in your application 35 36 // Slip uses a single semaphore to control UART access 37 #define NRK_MAX_RESOURCE_CNT 2 30 38 31 39 #define NRK_TASK_IDLE_STK_SIZE 128 // Idle task stack size min=32 32 40 #define NRK_APP_STACKSIZE 128 33 41 #define NRK_KERNEL_STACKSIZE 128 34 #define NRK_MAX_RESOURCE_CNT 135 42 36 43 37 #define NRK_MBOX_EN 0 // Include code for MAILBOXES38 #define NRK_Q_EN 0 // Include code for QUEUES39 #define NRK_SEM_EN 0 // Include code for SEMAPHORES40 #define NRK_TASK_CHANGE_PRIO_EN 0 // Include code for OSTaskChangePrio()41 42 43 #define NRK_STAT_EXT 0 // Extended Status for OS44 45 44 #endif -
nano-RK/src/drivers/platform/firefly2_2/source/adc_driver.c
r99 r114 60 60 if(opt&READ_FLAG) 61 61 { 62 RETURNNRK_OK;62 return NRK_OK; 63 63 } 64 64 if(opt&WRITE_FLAG) 65 65 { 66 RETURNNRK_ERROR;66 return NRK_ERROR; 67 67 } 68 68 if(opt&APPEND_FLAG) 69 69 { 70 RETURNNRK_ERROR;70 return NRK_ERROR; 71 71 } 72 72 if(opt&(READ_FLAG|WRITE_FLAG|APPEND_FLAG)==0) … … 81 81 /* Conversion to 8-bit value*/ 82 82 uint16_t val=get_adc_val(); 83 buffer[count]=val >> 2 & 0xFF;83 buffer[count]=val >> 2 & 0xFF; 84 84 } 85 85 return count; -
nano-RK/src/drivers/platform/firefly2_2/source/ff_basic_sensor.c
r99 r114 89 89 /* Conversion to 8-bit value*/ 90 90 uint16_t val=get_adc_val(); 91 buffer[count]=val >>2& 0xFF;91 buffer[count]=val & 0xFF; 92 92 count++; 93 93 return count; -
nano-RK/src/kernel/include/nrk_error.h
r54 r114 54 54 #define NRK_UNIMPLEMENTED 13 55 55 #define NRK_SIGNAL_CREATE_ERROR 14 56 #define NRK_NUM_ERRORS 15 56 #define NRK_SEMAPHORE_CREATE_ERROR 15 57 #define NRK_NUM_ERRORS 16 57 58 typedef uint8_t NRK_ERRNO; 58 59 -
nano-RK/src/kernel/include/nrk_events.h
r91 r114 59 59 int8_t nrk_sem_post(uint8_t* rsrc); 60 60 int8_t nrk_sem_pend(uint8_t *rsrc ); 61 int8_t nrk_sem_query(uint8_t *rsrc ); 61 62 62 63 -
nano-RK/src/kernel/source/nrk_error.c
r97 r114 150 150 nrk_kprintf (PSTR ("Failed to create Signal")); 151 151 break; 152 case NRK_SEMAPHORE_CREATE_ERROR: 153 nrk_kprintf (PSTR ("Failed to create Semaphore")); 154 break; 152 155 default: 153 156 nrk_kprintf (PSTR ("UNKOWN")); -
nano-RK/src/kernel/source/nrk_events.c
r97 r114 208 208 } 209 209 210 int8_t nrk_sem_query(uint8_t *rsrc ) 211 { 212 int8_t id; 213 id=nrk_get_resource_index(rsrc); 214 if(id==-1) { _nrk_errno_set(1); return NRK_ERROR;} 215 if(id==NRK_MAX_RESOURCE_CNT) { _nrk_errno_set(2); return NRK_ERROR; } 216 217 return(nrk_resource_value[id]); 218 } 219 220 210 221 211 222 int8_t nrk_sem_pend(uint8_t *rsrc ) -
nano-RK/src/net/slip/slip.c
r39 r114 1 1 #include "slip.h" 2 #include <nrk_events.h> 3 #include <nrk_error.h> 4 #include <nrk_cfg.h> 2 5 3 6 … … 5 8 bool g_echo; 6 9 uint8_t g_delay; 10 int8_t _slip_started = NRK_ERROR; 11 nrk_sem_t *slip_tx_sem; 7 12 8 uint8_t slip_init( FILE *device_in, FILE *device_out, bool echo, uint8_t delay ) 13 int8_t slip_init (FILE * device_in, FILE * device_out, bool echo, 14 uint8_t delay) 9 15 { 10 g_dv_in=device_in;11 g_dv_out=device_out;12 g_echo=echo;13 g_delay=delay;16 g_dv_in = device_in; 17 g_dv_out = device_out; 18 g_echo = echo; 19 g_delay = delay; 14 20 15 return 1; 21 22 #ifndef UART_PCP_CEILING 23 #define UART_PCP_CEILING 255 24 #endif 25 slip_tx_sem = nrk_sem_create (1, UART_PCP_CEILING); 26 if (slip_tx_sem == NRK_ERROR) 27 nrk_kernel_error_add (NRK_SEMAPHORE_CREATE_ERROR, nrk_get_pid ()); 28 29 _slip_started = NRK_OK; 30 return NRK_OK; 16 31 } 17 32 18 void put_byte (uint8_t c)33 void put_byte (uint8_t c) 19 34 { 20 if(g_delay>0 ) nrk_spin_wait_us(g_delay*1000);21 fputc(c,g_dv_out);22 if(g_echo)23 {24 // Not IMPLEMENTED25 }35 if (g_delay > 0) 36 nrk_spin_wait_us (g_delay * 1000); 37 fputc (c, g_dv_out); 38 if (g_echo) { 39 // Not IMPLEMENTED 40 } 26 41 } 27 42 28 uint8_t get_byte (void)43 uint8_t get_byte (void) 29 44 { 30 return fgetc (g_dv_in);45 return fgetc (g_dv_in); 31 46 } 32 47 33 uint8_t slip_tx(uint8_t *buf, uint8_t size)48 int8_t slip_tx (uint8_t * buf, uint8_t size) 34 49 { 35 uint8_t i; 50 uint8_t i; 51 int8_t v; 52 uint8_t checksum; 53 54 // Make sure size is less than 128 so it doesn't act as a control 55 // message 56 if (size > 128) { 57 _nrk_errno_set (3); 58 return NRK_ERROR; 59 } 60 61 v = nrk_sem_pend (slip_tx_sem); 62 if (v == NRK_ERROR) { 63 nrk_kprintf (PSTR ("SLIP TX ERROR: Access to semaphore failed\r\n")); 64 _nrk_errno_set (1); 65 return NRK_ERROR; 66 } 36 67 37 68 // Send the start byte 38 put_byte(END); 69 put_byte (START); 70 put_byte (size); 71 72 checksum = 0; 73 39 74 // Send payload and stuff bytes as needed 40 for(i=0; i<size; i++ ) 41 { 42 if(buf[i]==END || buf[i]==ESC) put_byte(ESC); 43 put_byte(buf[i]); 44 } 45 // Send the end byte 46 put_byte(END); 75 for (i = 0; i < size; i++) { 76 if (buf[i] == END || buf[i] == ESC) 77 put_byte (ESC); 78 put_byte (buf[i]); 79 checksum += buf[i]; 80 } 47 81 82 // Make sure checksum is less than 128 so it doesn't act as a control 83 // message 84 checksum &= 0x7F; 85 // Send the end byte 86 put_byte (checksum); 87 put_byte (END); 88 v = nrk_sem_post (slip_tx_sem); 89 if (v == NRK_ERROR) { 90 nrk_kprintf (PSTR ("SLIP TX ERROR: Release of semaphore failed\r\n")); 91 _nrk_errno_set (2); 92 return NRK_ERROR; 93 } 94 return NRK_OK; 48 95 } 49 96 50 uint8_t slip_rx(uint8_t *buf,uint8_t max_len)97 int8_t slip_started () 51 98 { 52 uint8_t c; 53 uint8_t index; 54 uint8_t received; 55 bool start_flag; 56 57 received=0; 58 start_flag=0; 59 // Wait until you receive the packet start (END) command 60 while(1){ 61 c=get_byte(); 62 if(start_flag && c==END ) break; 63 if(c==ESC) start_flag=1; 64 else start_flag=0; 99 return _slip_started; 65 100 } 66 101 67 while(1) { 68 // get a character to process 69 c = get_byte(); 102 int8_t slip_rx (uint8_t * buf, uint8_t max_len) 103 { 104 uint8_t c; 105 uint8_t index, last_c; 106 uint8_t received, checksum, size; 107 nrk_sig_t uart_rx_signal; 108 nrk_sig_mask_t sm; 70 109 71 // handle bytestuffing if necessary 72 switch(c) { 110 // Register your task to wakeup on RX Data 111 if (uart_rx_signal == NRK_ERROR) 112 nrk_kprintf (PSTR ("Get Signal ERROR!\r\n")); 113 nrk_signal_register (uart_rx_signal); 73 114 74 // if it's an END character then we're done with75 // the packet76 case END:77 // a minor optimization: if there is no78 // data in the packet, ignore it. This is79 // meant to avoid bothering IP with all80 // the empty packets generated by the81 // duplicate END characters which are in82 // turn sent to try to detect line noise.83 if(received)84 return received;85 else86 break;87 115 88 // if it's the same code as an ESC character, wait89 // and get another character and then figure out90 // what to store in the packet based on that.91 case ESC:92 c = get_byte();93 // if "c" is not one of these two, then we94 // have a protocol violation. The best bet95 // seems to be to leave the byte alone and96 // just stuff it into the packet97 switch(c) {98 case END:99 c = END;100 break;101 case ESC:102 c = ESC;103 break;104 }105 116 106 // here we fall into the default handler and let 107 // it store the character for us 108 default: 109 if(received < max_len) 110 buf[received++] = c; 111 } 112 } 117 received = 0; 118 119 // Wait until you receive the packet start (START) command 120 while (1) { 121 // Wait for UART signal 122 while (nrk_uart_data_ready (NRK_DEFAULT_UART) != 0) { 123 // Read Character 124 c = getchar (); 125 if (c == START) 126 break; 127 //printf( "%c",c); 128 } 129 sm = nrk_event_wait (SIG (uart_rx_signal)); 130 // c=get_byte(); 131 if (c == START) 132 break; 133 } 134 135 size = get_byte (); 136 checksum = 0; 137 while (1) { 138 while (nrk_uart_data_ready (NRK_DEFAULT_UART) != 0) { 139 last_c = c; 140 c = getchar (); 141 142 143 // handle bytestuffing if necessary 144 switch (c) { 145 146 // if it's an END character then we're done with 147 // the packet 148 case END: 149 // a minor optimization: if there is no 150 // data in the packet, ignore it. This is 151 // meant to avoid bothering IP with all 152 // the empty packets generated by the 153 // duplicate END characters which are in 154 // turn sent to try to detect line noise. 155 if (received) { 156 checksum &= 0x7f; 157 if (last_c == checksum) 158 return received; 159 } 160 return NRK_ERROR; 161 break; 162 163 // if it's the same code as an ESC character, wait 164 // and get another character and then figure out 165 // what to store in the packet based on that. 166 case ESC: 167 // FIXME: Need to sleep here 168 last_c = c; 169 c = get_byte (); 170 // if "c" is not one of these two, then we 171 // have a protocol violation. The best bet 172 // seems to be to leave the byte alone and 173 // just stuff it into the packet 174 switch (c) { 175 case END: 176 c = END; 177 break; 178 case ESC: 179 c = ESC; 180 break; 181 } 182 183 // here we fall into the default handler and let 184 // it store the character for us 185 default: 186 if (received < max_len && received < size) { 187 buf[received++] = c; 188 checksum += c; 189 } 190 } 191 } 192 sm = nrk_event_wait (SIG (uart_rx_signal)); 193 } 113 194 114 195 115 196 } 116 -
nano-RK/src/net/slip/slip.h
r39 r114 9 9 #define ESC 219 10 10 #define END 192 11 #define START 193 11 12 12 13 uint8_t slip_init( FILE *device_in, FILE *device_out, bool echo, uint8_t delay );14 uint8_t slip_tx(uint8_t *buf, uint8_t size);15 uint8_t slip_rx(uint8_t *buf, uint8_t max_len);13 int8_t slip_started(); 14 int8_t slip_init( FILE *device_in, FILE *device_out, bool echo, uint8_t delay ); 15 int8_t slip_tx(uint8_t *buf, uint8_t size); 16 int8_t slip_rx(uint8_t *buf, uint8_t max_len); 16 17 void put_byte(uint8_t c); 17 18 uint8_t get_byte(void); -
nano-RK/src/platform/firefly2_2/source/ulib.c
r94 r114 7 7 #include <nrk_pin_define.h> 8 8 #include <nrk_error.h> 9 #include <nrk_events.h> 9 10 10 11 #ifdef NANORK … … 18 19 #define MAX_RX_UART_BUF 16 19 20 #endif 21 20 22 21 23 uint8_t uart_rx_buf_start,uart_rx_buf_end; … … 404 406 } 405 407 408 409 406 410 /** 407 411 * nrk_setup_uart() … … 421 425 stdout = fdevopen( putc1, getc1); 422 426 stdin = fdevopen( putc1, getc1); 427 423 428 #ifdef NRK_UART_BUF 424 429 uart_rx_signal=nrk_signal_create(); -
nano-RK/src/platform/include/ulib.h
r83 r114 15 15 void nrk_setup_ports(); 16 16 void nrk_setup_uart(uint16_t baudrate); 17 18 17 19 18
Note: See TracChangeset
for help on using the changeset viewer.
