Ejemplo n.º 1
0
/*!	do stuff every 1/4 second

	called from clock_10ms(), do not call directly
*/
static void clock_250ms(void) {
  if (heaters_all_zero()) {
		if (psu_timeout > (30 * 4)) {
			power_off();
		}
		else {
      ATOMIC_START
        psu_timeout++;
      ATOMIC_END
		}
	}

	ifclock(clock_flag_1s) {
		if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
			// current position
			update_current_position();
			sersendf_P(PSTR("Pos: %lq,%lq,%lq,%lq,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F);

			// target position
			sersendf_P(PSTR("Dst: %lq,%lq,%lq,%lq,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F);

			// Queue
			print_queue();

			// newline
			serial_writechar('\n');
		}
		// temperature
		/*		if (temp_get_target())
		temp_print();*/
	}
	#ifdef	TEMP_INTERCOM
	start_send();
	#endif
}
Ejemplo n.º 2
0
 bool check_tag_sent()
 {
     if(request_ready())
     {
         return start_send();
     }
     return next(&receiver::check_tag_sent);
 }
Ejemplo n.º 3
0
int coreconnector_send(struct core_connector *co, void *param)
{
	corebuf* buf = (corebuf*)param;
	int err = start_send(co->socket, buf);
	if (err) {
		fprintf(stderr, "coreconnector_send failure [%s]\n", errno_str(err));
	}
	return err;
}
Ejemplo n.º 4
0
void QNetTcpServer::server_start(int sk)
{
  socket = sk;
  quit = 0;
  start_send();
  start_treasmit();
  start_recv();
  //usleep(100000);

}
Ejemplo n.º 5
0
BOOL OTExtSnd::send(uint32_t numOTs, uint32_t bitlength, CBitVector& x0, CBitVector& x1, snd_ot_flavor stype,
		rec_ot_flavor rtype, uint32_t numThreads, MaskingFunction* maskfct) {
	m_nOTs = numOTs;
	m_nBitLength = bitlength;
	m_vValues[0] = x0;
	m_vValues[1] = x1;
	m_eSndOTFlav = stype;
	m_eRecOTFlav = rtype;
	m_fMaskFct = maskfct;

	return start_send(numThreads);
}
Ejemplo n.º 6
0
int
exec_list_cmd(char *params)
{
	if(session->trans_con == NULL)
	{
		send_proto(425, "Cant open data connection. User pasv command first."); 
		return 1;
	}
	else
	{
		send_proto(150, "File status ok, about to open data connection");
	}

	char *c_path = session->cur_path;
	char *ls_param = get_full_path(session->root_path,  &c_path, params);
	free(c_path);

	if(!verifi_ex_dir(ls_param))
	{
		free(ls_param);
		send_proto(550, "Requested action not taken.");
		return 1;
	}

	int trans_desc = start_send();
	pid_t son;
	if((son = fork()) == 0)//producent
	{	
		close(1); 
		dup(trans_desc); 
		execl("/bin/ls", "ls", "-la", ls_param, NULL);
	}
	close(trans_desc);
	free(ls_param);
	
	int status_prod = -1, status_trans = -1;
	pid_t x = waitpid(son, &status_prod, WCONTINUED);
	
	pid_t y = x == -1 || WEXITSTATUS(status_prod) ? -1 : waitpid(session->trans_con->pid, &status_trans, WCONTINUED);

	if(x == -1 || y == -1 ||  WEXITSTATUS(status_prod) || WEXITSTATUS(status_trans)) 
		send_proto(426, "Connection closed transfer aborted");
	else
		send_proto(226, "Closing data connection. Transfer complete");

	free_trans();
	return 1;	
}
Ejemplo n.º 7
0
/**
 * Called when the Send list element is released to send the file
 * @param sed pointer to the Up button
 * @param dispi pointer to the caller display input
 * @return LV_ACTION_RES_OK because the list is NOT deleted in the function
 */
static lv_action_res_t win_send_rel_action(lv_obj_t * send, lv_dispi_t * dispi)
{
    lv_app_inst_t * app = lv_obj_get_free_p(send);
    my_app_data_t * app_data = app->app_data;

    if(app_data->send_in_prog != 0) {
        lv_app_notice_add("File sending\nin progress");
        return LV_ACTION_RES_OK;
    }

    char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
    sprintf(path_fn, "%s/%s", app_data->path, app_data->fn);
    start_send(app, path_fn);

    return LV_ACTION_RES_OK;
}
Ejemplo n.º 8
0
void mb8795_device::device_reset()
{
	txstat = EN_TXS_READY;
	txmask = 0x00;
	rxstat = 0x00;
	rxmask = 0x00;
	txmode = 0x00;
	rxmode = 0x00;

	drq_tx = drq_rx = false;
	irq_tx = irq_rx = false;

	txlen = rxlen = txcount = 0;

	set_promisc(true);

	start_send();
}
Ejemplo n.º 9
0
/**
 * Read the data have been sent to this application
 * @param app_send pointer to an application which sent the message
 * @param app_rec pointer to an application which is receiving the message
 * @param type type of data from 'lv_app_com_type_t' enum
 * @param data pointer to the sent data
 * @param size length of 'data' in bytes
 */
static void my_com_rec(lv_app_inst_t * app_send, lv_app_inst_t * app_rec,
                       lv_app_com_type_t type , const void * data, uint32_t size)
{
    if(type == LV_APP_COM_TYPE_CHAR) {
        /*Check for file query. E.g. "U:/file.txt?"*/
        const char * path = data;
        if(path[size - 1] == '?') {
            if(size > LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN) {
                lv_app_notice_add("Can not send file:\ntoo long path");
            }

            char path_fn[LV_APP_FILES_PATH_MAX_LEN + LV_APP_FILES_FN_MAX_LEN];
            memcpy(path_fn, data, size - 1); /*-1 to ignore the '?' at the end*/
            path_fn[size - 1] = '\0';
            start_send(app_rec, path_fn);
        }
    }
}
Ejemplo n.º 10
0
int
exec_mlsd_cmd(char *params)
{
	if(session->trans_con == NULL)
	{
		send_proto(425, "Cant open data connection. User pasv command first."); 
		return 1;
	}
	else
	{
		send_proto(150, "File status ok, about to open data connection");
	}

	char *c_path = session->cur_path;
	char *dir_path = get_full_path(session->root_path,  &c_path, params);
	free(c_path);

	if(!verifi_ex_dir(dir_path))
	{
		free(dir_path);
		send_proto(550, "Requested action not taken.");
		return 1;
	}

	write_mlsd_data(start_send(), dir_path); 

	free(dir_path);
	
	int status_trans = -1;
	
	pid_t y = waitpid(session->trans_con->pid, &status_trans, WCONTINUED);

	if( y == -1 || WEXITSTATUS(status_trans)) 
		send_proto(426, "Connection closed transfer aborted");
	else
		send_proto(226, "Closing data connection. Transfer complete");

	free_trans();
	return 1;	
}
Ejemplo n.º 11
0
/*!	do stuff every 1/4 second

	called from clock_10ms(), do not call directly
*/
void clock_250ms() {
	#ifndef	NO_AUTO_IDLE
	if (temp_all_zero())	{
		if (steptimeout > (30 * 4)) {
			power_off();
		}
		else {
			uint8_t save_reg = SREG;
			cli();
			CLI_SEI_BUG_MEMORY_BARRIER();
			steptimeout++;
			MEMORY_BARRIER();
			SREG = save_reg;
		}
	}
	#endif

	ifclock(clock_flag_1s) {
		if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
			// current position
			sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F);

			// target position
			sersendf_P(PSTR("Dst: %ld,%ld,%ld,%ld,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F);

			// Queue
			print_queue();

			// newline
			serial_writechar('\n');
		}
		// temperature
		/*		if (temp_get_target())
		temp_print();*/
	}
	#ifdef	TEMP_INTERCOM
	start_send();
	#endif
}
Ejemplo n.º 12
0
void ClientICMP::measure_latency()
{
	start_send();
	start_receive();
}
Ejemplo n.º 13
0
void temp_sensor_tick() {
	temp_sensor_t i = 0;
	for (; i < NUM_TEMP_SENSORS; i++) {
		if (temp_sensors_runtime[i].next_read_time) {
			temp_sensors_runtime[i].next_read_time--;
		}
		else {
			uint16_t	temp = 0;
			//time to deal with this temp sensor
			switch(temp_sensors[i].temp_type) {
				#ifdef	TEMP_MAX6675
				case TT_MAX6675:
					#ifdef	PRR
						PRR &= ~MASK(PRSPI);
					#elif defined PRR0
						PRR0 &= ~MASK(PRSPI);
					#endif
					
					SPCR = MASK(MSTR) | MASK(SPE) | MASK(SPR0);
					
					// enable TT_MAX6675
					WRITE(SS, 0);
					
					// ensure 100ns delay - a bit extra is fine
					delay(1);
					
					// read MSB
					SPDR = 0;
					for (;(SPSR & MASK(SPIF)) == 0;);
					temp = SPDR;
					temp <<= 8;
					
					// read LSB
					SPDR = 0;
					for (;(SPSR & MASK(SPIF)) == 0;);
					temp |= SPDR;
					
					// disable TT_MAX6675
					WRITE(SS, 1);
					
					temp_sensors_runtime[i].temp_flags = 0;
					if ((temp & 0x8002) == 0) {
						// got "device id"
						temp_sensors_runtime[i].temp_flags |= PRESENT;
						if (temp & 4) {
							// thermocouple open
							temp_sensors_runtime[i].temp_flags |= TCOPEN;
						}
						else {
							temp = temp >> 3;
						}
					}
					
					// this number depends on how frequently temp_sensor_tick is called. the MAX6675 can give a reading every 0.22s, so set this to about 250ms
					temp_sensors_runtime[i].next_read_time = 25;
					
					break;
				#endif	/* TEMP_MAX6675	*/
					
				#ifdef	TEMP_THERMISTOR
				case TT_THERMISTOR:
					do {
						uint8_t j;
						//Read current temperature
						temp = analog_read(temp_sensors[i].temp_pin);

						//Calculate real temperature based on lookup table
						for (j = 1; j < NUMTEMPS; j++) {
							if (pgm_read_word(&(temptable[j][0])) > temp) {
								// Thermistor table is already in 14.2 fixed point
								if (debug_flags & DEBUG_PID)
									sersendf_P(PSTR("pin:%d Raw ADC:%d table entry: %d"),temp_sensors[i].temp_pin,temp,j);
								// Linear interpolating temperature value
								// y = ((x - x₀)y₁ + (x₁-x)y₀ ) / (x₁ - x₀)
								// y = temp
								// x = ADC reading
								// x₀= temptable[j-1][0]
								// x₁= temptable[j][0]
								// y₀= temptable[j-1][1]
								// y₁= temptable[j][1]
								// y = 
								// Wikipedia's example linear interpolation formula.
								temp = (
								//     ((x - x₀)y₁
									((uint32_t)temp - pgm_read_word(&(temptable[j-1][0]))) * pgm_read_word(&(temptable[j][1]))
								//                 +
									+
								//                   (x₁-x)
									(pgm_read_word(&(temptable[j][0])) - (uint32_t)temp)
								//                         y₀ )
									* pgm_read_word(&(temptable[j-1][1]))) 
								//                              /
									/
								//                                (x₁ - x₀)
									(pgm_read_word(&(temptable[j][0])) - pgm_read_word(&(temptable[j-1][0])));
								if (debug_flags & DEBUG_PID)
									sersendf_P(PSTR(" temp:%d.%d"),temp/4,(temp%4)*25);
								break;
							}
						}
						if (debug_flags & DEBUG_PID)
							sersendf_P(PSTR(" Sensor:%d\n"),i);
						

						//Clamp for overflows
						if (j == NUMTEMPS)
							temp = temptable[NUMTEMPS-1][1];

						temp_sensors_runtime[i].next_read_time = 0;
					} while (0);
					break;
				#endif	/* TEMP_THERMISTOR */
					
				#ifdef	TEMP_AD595
				case TT_AD595:
					temp = analog_read(temp_pin);
					
					// convert
					// >>8 instead of >>10 because internal temp is stored as 14.2 fixed point
					temp = (temp * 500L) >> 8;
					
					temp_sensors_runtime[i].next_read_time = 0;
					
					break;
				#endif	/* TEMP_AD595 */

				#ifdef	TEMP_PT100
				case TT_PT100:
					#warning TODO: PT100 code
					break
				#endif	/* TEMP_PT100 */

				#ifdef	TEMP_INTERCOM
				case TT_INTERCOM:
					temp = get_read_cmd() << 2;

					start_send();

					temp_sensors_runtime[i].next_read_time = 0;

					break;
				#endif	/* TEMP_INTERCOM */
				
				#ifdef	TEMP_DUMMY
				case TT_DUMMY:
					temp = temp_sensors_runtime[i].last_read_temp;

					if (temp_sensors_runtime[i].target_temp > temp)
						temp++;
					else if (temp_sensors_runtime[i].target_temp < temp)
						temp--;

					temp_sensors_runtime[i].next_read_time = 0;

					break;
				#endif	/* TEMP_DUMMY */
			}
			temp_sensors_runtime[i].last_read_temp = temp;
			
			if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) {
				if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
					temp_sensors_runtime[i].temp_residency++;
			}
			else {
				temp_sensors_runtime[i].temp_residency = 0;
			}
			
			if (temp_sensors[i].heater_index < NUM_HEATERS) {
				heater_tick(temp_sensors[i].heater_index, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
			}
		}
	}
Ejemplo n.º 14
0
void clock_250ms() {
        debug_led_step();

        if (steptimeout > (30 * 4)) {
                power_off();
        }
        else if (heaters_all_off())	{
                uint8_t save_reg = SREG;
                cli();
                CLI_SEI_BUG_MEMORY_BARRIER();
                steptimeout++;
                MEMORY_BARRIER();
                SREG = save_reg;
        }
        
#ifdef	TEMP_INTERCOM
        start_send();
#endif

        ifclock(clock_flag_1s) {
                if (DEBUG_POSITION && (debug_flags & DEBUG_CLOCK)) sersendf_P(PSTR("1s"));
                if (DEBUG_POSITION && (debug_flags & DEBUG_POSITION)) {
                        // current position
                        sersendf_P(PSTR("Pos: %ld,%ld,%ld,%ld,%lu\n"), current_position.X, current_position.Y, current_position.Z, current_position.E, current_position.F);

                        // target position
                        sersendf_P(PSTR("Dst: %ld,%ld,%ld,%ld,%lu\n"), movebuffer[mb_tail].endpoint.X, movebuffer[mb_tail].endpoint.Y, movebuffer[mb_tail].endpoint.Z, movebuffer[mb_tail].endpoint.E, movebuffer[mb_tail].endpoint.F);

                        // Queue
                        print_queue();

                        // newline
                        serial_writechar('\n');
                }

                check_temp_achieved();
                if (DEBUG_POSITION && (debug_flags & DEBUG_CLOCK)) sersendf_P(PSTR("t"));
                
                
                ++seconds_counter;
                
                if (++idle_seconds>60)
                	working_seconds=0;
               	else
	                ++working_seconds;
                #ifdef OK_WHEN_IDLE
		if (idle_seconds>OK_WHEN_IDLE && seconds_counter-last_ok_time>OK_WHEN_IDLE)
		{
			sersendf_P(PSTR("ok (idle)\n"));
			last_ok_time=seconds_counter;
		}
		#endif 
		
		
                if (DEBUG_POSITION && (debug_flags & DEBUG_CLOCK)) sersendf_P(PSTR("r\n"));
                
                #if defined ALWAYS_CHECK_Z_MIN && defined Z_MIN_PIN
		if (z_min_pushed_flag) {
			sersendf_P(PSTR("ALERT!! PUSHING UNDERGROUND!!\n"));
			z_min_pushed_flag=0;
		}
		#endif
        }
        
}
Ejemplo n.º 15
0
void temp_sensor_tick() {
	temp_sensor_t i = 0;
	for (; i < NUM_TEMP_SENSORS; i++) {
		if (temp_sensors_runtime[i].next_read_time) {
			temp_sensors_runtime[i].next_read_time--;
		}
		else {
			uint16_t	temp = 0;
			//time to deal with this temp sensor
			switch(temp_sensors[i].temp_type) {
				#ifdef	TEMP_MAX6675
				case TT_MAX6675:
					#ifdef	PRR
						PRR &= ~MASK(PRSPI);
					#elif defined PRR0
						PRR0 &= ~MASK(PRSPI);
					#endif
					
					SPCR = MASK(MSTR) | MASK(SPE) | MASK(SPR0);
					
					// enable TT_MAX6675
					WRITE(SS, 0);
					
					// ensure 100ns delay - a bit extra is fine
					delay(1);
					
					// read MSB
					SPDR = 0;
					for (;(SPSR & MASK(SPIF)) == 0;);
					temp = SPDR;
					temp <<= 8;
					
					// read LSB
					SPDR = 0;
					for (;(SPSR & MASK(SPIF)) == 0;);
					temp |= SPDR;
					
					// disable TT_MAX6675
					WRITE(SS, 1);
					
					temp_sensors_runtime[i].temp_flags = 0;
					if ((temp & 0x8002) == 0) {
						// got "device id"
						temp_sensors_runtime[i].temp_flags |= PRESENT;
						if (temp & 4) {
							// thermocouple open
							temp_sensors_runtime[i].temp_flags |= TCOPEN;
						}
						else {
							temp = temp >> 3;
						}
					}
					
					// this number depends on how frequently temp_sensor_tick is called. the MAX6675 can give a reading every 0.22s, so set this to about 250ms
					temp_sensors_runtime[i].next_read_time = 25;
					
					break;
				#endif	/* TEMP_MAX6675	*/
					
				#ifdef	TEMP_THERMISTOR
				case TT_THERMISTOR:
					do {
						uint8_t j;
						//Read current temperature
						temp = analog_read(temp_sensors[i].temp_pin);

						//Calculate real temperature based on lookup table
						for (j = 1; j < NUMTEMPS; j++) {
							if (pgm_read_word(&(temptable[j][0])) > temp) {
								// multiply by 4 because internal temp is stored as 14.2 fixed point
								temp = pgm_read_word(&(temptable[j][1])) * 4 + (temp - pgm_read_word(&(temptable[j-1][0]))) * 4 * (pgm_read_word(&(temptable[j][1])) - pgm_read_word(&(temptable[j-1][1]))) / (pgm_read_word(&(temptable[j][0])) - pgm_read_word(&(temptable[j-1][0])));
								break;
							}
						}

						//Clamp for overflows
						if (j == NUMTEMPS)
							temp = temptable[NUMTEMPS-1][1] * 4;

						temp_sensors_runtime[i].next_read_time = 0;
					} while (0);
					break;
				#endif	/* TEMP_THERMISTOR */
					
				#ifdef	TEMP_AD595
				case TT_AD595:
					temp = analog_read(temp_pin);
					
					// convert
					// >>8 instead of >>10 because internal temp is stored as 14.2 fixed point
					temp = (temp * 500L) >> 8;
					
					temp_sensors_runtime[i].next_read_time = 0;
					
					break;
				#endif	/* TEMP_AD595 */

				#ifdef	TEMP_PT100
				case TT_PT100:
					#warning TODO: PT100 code
					break
				#endif	/* TEMP_PT100 */

				#ifdef	TEMP_INTERCOM
				case TT_INTERCOM:
					temp = get_read_cmd() << 2;

					start_send();

					temp_sensors_runtime[i].next_read_time = 0;

					break;
				#endif	/* TEMP_INTERCOM */
				
				#ifdef	TEMP_DUMMY
				case TT_DUMMY:
					temp = temp_sensors_runtime[i].last_read_temp;

					if (temp_sensors_runtime[i].target_temp > temp)
						temp++;
					else if (temp_sensors_runtime[i].target_temp < temp)
						temp--;

					temp_sensors_runtime[i].next_read_time = 0;

					break;
				#endif	/* TEMP_DUMMY */
			}
			temp_sensors_runtime[i].last_read_temp = temp;
			
			if (labs(temp - temp_sensors_runtime[i].target_temp) < TEMP_HYSTERESIS) {
				if (temp_sensors_runtime[i].temp_residency < TEMP_RESIDENCY_TIME)
					temp_sensors_runtime[i].temp_residency++;
			}
			else {
				temp_sensors_runtime[i].temp_residency = 0;
			}
			
			if (temp_sensors[i].heater_index < NUM_HEATERS) {
				heater_tick(temp_sensors[i].heater_index, i, temp_sensors_runtime[i].last_read_temp, temp_sensors_runtime[i].target_temp);
			}
		}
	}