Project

General

Profile

« Previous | Next » 

Revision 1e329241

Added by Robert Noland over 10 years ago

We need to at least setup the serial port before we try to blast
config data to it. My system was hanging during boot because cat
was couldn't output gps.init to the port.

View differences:

etc/inc/system.inc
1575 1575
	unlink_if_exists($gps_device);
1576 1576
	@symlink($serialport, $gps_device);
1577 1577

  
1578
	$gpsbaud = '4800';
1579
	if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['speed'])) {
1580
		switch ($config['ntpd']['gps']['speed']) {
1581
			case '16':
1582
				$gpsbaud = '9600';
1583
				break;
1584
			case '32':
1585
				$gpsbaud = '19200';
1586
				break;
1587
			case '48':
1588
				$gpsbaud = '38400';
1589
				break;
1590
			case '64':
1591
				$gpsbaud = '57600';
1592
				break;
1593
			case '80':
1594
				$gpsbaud = '115200';
1595
				break;
1596
		}
1597
	}
1598

  
1599
	/* Configure the serial port for raw IO and set the speed */
1600
	`stty -f {$serialport}.init raw speed {$gpsbaud}`
1601

  
1578 1602
	/* Send the following to the GPS port to initialize the GPS */
1579 1603
	if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['type'])) {
1580 1604
		$gps_init = base64_decode($config['ntpd']['gps']['initcmd']);
......
1588 1612

  
1589 1613
	/* Add /etc/remote entry in case we need to read from the GPS with tip */
1590 1614
	if (intval(`grep -c '^gps0' /etc/remote`) == 0) {
1591
		$gpsbaud = '4800';
1592
		if (is_array($config['ntpd']) && is_array($config['ntpd']['gps']) && !empty($config['ntpd']['gps']['speed'])) {
1593
			switch ($config['ntpd']['gps']['speed']) {
1594
				case '16':
1595
					$gpsbaud = '9600';
1596
					break;
1597
				case '32':
1598
					$gpsbaud = '19200';
1599
					break;
1600
				case '48':
1601
					$gpsbaud = '38400';
1602
					break;
1603
				case '64':
1604
					$gpsbaud = '57600';
1605
					break;
1606
				case '80':
1607
					$gpsbaud = '115200';
1608
					break;
1609
			}
1610
		}
1611 1615
		@file_put_contents("/etc/remote", "gps0:dv={$serialport}:br#{$gpsbaud}:pa=none:", FILE_APPEND);
1612 1616
	}
1613 1617

  

Also available in: Unified diff