Saturday, November 16, 2024

The future of communication is Satellite Communication...

I started my true professional career in a global telecom giant during the '90s when the telecom sector of Bharat was privatised. I am a witness to the technological advancement of Bharat - from brickphones (early days' mobile phones) to 5G and 6G - and now satellite based connectivity - from network oriented technological development to mobile app based software development - everything I have observed that happened in Bharat and in the global technological advancement vis-a-vis telecom... I am of course lucky enough to experience the rural life of Bharat as well as the city life of Bharat.

My today's contribution is the following write up.

Satellite communication is the future of global connectivity.

Here are key aspects of why satellite communication is integral to the future:

Global Internet Access

Low Earth Orbit (LEO) Satellites

Companies like SpaceX (Starlink), Amazon (Project Kuiper), and OneWeb are deploying constellations of LEO satellites to provide high-speed, low-latency internet access globally. These systems are designed to bridge the digital divide by connecting remote and underserved regions.

Affordable Connectivity

By increasing competition and technological efficiency, satellite constellations are reducing the cost of broadband in areas where traditional infrastructure is expensive or impractical.

5G and Beyond

Integration with Terrestrial Networks

Satellites are being integrated into 5G networks, enabling seamless connectivity in rural areas, maritime and aviation sectors, and for emergency response where terrestrial networks fail.

6G Vision

In future 6G networks, satellites are expected to play a key role in delivering ultra-reliable, low-latency communications for applications like autonomous vehicles and smart cities.

Security and Defense

 Governments and defense organizations rely heavily on satellite communication for secure and resilient military operations. Satellites also support intelligence, surveillance, and reconnaissance (ISR) activities.


Emerging Technologies

Quantum Communication

Future satellites could enable secure quantum key distribution (QKD) for cybersecurity.

Internet of Things (IoT)

Satellites are enabling IoT devices to function in remote and inaccessible areas, driving applications in agriculture, logistics, and resource management.


Challenges

Space Debris

Increased satellite launches raise concerns about orbital congestion and debris management.

Satellite communication is not just transforming how we stay connected but is also expanding its impact across industries, from disaster management to precision agriculture and space exploration. Its future lies in enhancing global connectivity while addressing its associated challenges through innovation and regulation.

From the perspective of Bharat...

BSNL has made significant advancements in satellite communication, collaborating with global partners like Viasat. In recent trials, BSNL successfully demonstrated direct-to-device (D2D) satellite connectivity, enabling two-way messaging and SOS functionalities using commercial Android smartphones. This development eliminates the need for traditional mobile towers, making it ideal for remote areas, disaster recovery, and critical services. The technology uses Viasat's geostationary satellites to facilitate connectivity over non-terrestrial networks (NTNs).

Additionally, BSNL is working on integrating satellite communication with its existing services, potentially revolutionizing connectivity for IoT devices and enhancing rural access in India. Such initiatives align with global trends in satellite communication as a critical component of the future of telecommunications.

Role of ISRO in the future satellite based connectivity of Bharat...


ISRO (Indian Space Research Organisation) is expected to play a pivotal role in enhancing satellite-based connectivity in India (Bharat) as the demand for ubiquitous, high-speed communication grows. Here are the key aspects of ISRO's future contributions:

Satellite-Based Internet Services

BharatNet Expansion


ISRO's satellites will significantly enhance the BharatNet project, which aims to bring broadband connectivity to rural areas. High-capacity satellites like GSAT-11 and GSAT-29 are already deployed to support high-speed internet in remote regions.

Collaboration with Private Players

ISRO is fostering partnerships with Indian private firms and global tech companies, like OneWeb, for Low Earth Orbit (LEO) satellite deployments, further boosting connectivity.

5G and Beyond

ISRO is expected to complement terrestrial 5G infrastructure by offering satellite backhaul solutions, particularly in rural and hard-to-reach areas. This will ensure seamless connectivity in regions lacking traditional network infrastructure.

Disaster Management and Emergency Communication

Satellite communication will play a critical role in providing resilient communication during natural disasters, enabling real-time data sharing and facilitating rescue operations.

Support for IoT and Smart Applications

ISRO's satellite networks will be instrumental in expanding IoT-based services for applications in agriculture, logistics, and smart city projects, connecting devices in the most remote corners of the country.

Indigenous Satellite Constellations

ISRO is exploring its own LEO satellite constellation projects to reduce reliance on international providers and ensure self-reliant, secure satellite communications for strategic and civilian uses.

ISRO's continued innovation in satellite technology, supported by government and private sector initiatives, will play a transformative role in making Bharat a digitally inclusive and connected nation.

Wednesday, October 30, 2024

Signals and Slots in C++ using Boost's Library...

 I remember in the early part of my Bangalore stay, two C++ libraries attracted me - Boost and Loki. However, with the daily grinding in the office, i never got time to deep dive into it. And finally i got a chance to look into the Boost library in 2007, during my stay in Japan. But it was difficult - without a proper hand holding. I just got a chance to delve into the Boost pointers. 

Today, i will discuss about another important aspect of Boost library - Signals and Slots. These are Boost's answer to publisher-subscriber or Observer pattern or as the Java people call it - the event listener pattern - and for all others - simply the event driven programming.

You should use this pattern in case of...

Event-Driven Programming:

Signals and slots are ideal for event-driven programming, where objects need to react to events triggered by other objects.

GUI Development:

Boost.Signals2 is commonly used in GUI development to connect UI elements to actions or events.

Decoupling Components:

Signals and slots allow you to decouple components of your application, making it easier to modify and maintain the code.

Example : 

The following example writes "Hello, World!" using signals and slots. 

Here are the two function objects.

class Hello

{

public:

void operator()() const

{

cout << "Hello";

}

};


class World

{

public:

void operator()() const

{

cout << ", World!" << endl;

}

};

Then, we create a signal sig1, a signal that takes no arguments and has a void return value. 

boost::signals2::signal<void()> sig1;

Next, we connect the hello and world function objects to the signal using the connect method.

boost::signals2::connection c1 = sig1.connect(hello);


boost::signals2::connection c2 = sig1.connect(world);


By default, slots are pushed onto the back of the slot

list, so the output of this program will be as expected.


Hello, World!


The way signals and slots are connected, they can

be disconnected as wellas we have done here.


c1.disconnect(); // Disconnect the Hello object


Signals can propagate arguments to each of the slots

they call. For instance, a signal that propagates mouse

motion events might want to pass along the new mouse

coordinates and whether the mouse buttons are pressed.


//Slot Arguments

void print_args(float x, float y)

{

cout << "The arguments are " << x << " and " << y << endl;

}


void print_sum(float x, float y)

{

cout << "The sum is " << x + y << endl;

}


void print_product(float x, float y)

{

cout << "The product is " << x * y << endl;

}


void print_difference(float x, float y)

{

cout << "The difference is " << x - y << endl;

}


void print_quotient(float x, float y)

{

cout << "The quotient is " << x / y << endl;

}


And this is how we create the signals


boost::signals2::signal<void (float, float)> sig;


sig.connect(&print_args);

sig.connect(&print_sum);

sig.connect(&print_product);

sig.connect(&print_difference);

sig.connect(&print_quotient);


sig(5., 3.);


And the output will be as follows:


The arguments are 5 and 3 The sum is 8 The product is 15 The difference is 2 The quotient is 1.66667


Here is the complete source code of my

exploration.


Enjoy...


//============================================================================

// Name : BoostSignal2Test.cpp

// Author : Som

// Version :

// Copyright : som-itsolutions

// Description : Hello World in C++, Ansi-style

//============================================================================


#include <boost/signals2/signal.hpp>

#include <iostream>

using namespace std;

class Hello

{

public:

void operator()() const

{

cout << "Hello";

}

};


class World

{

public:

void operator()() const

{

cout << ", World!" << endl;

}

};

//Slot Arguments

void print_args(float x, float y)

{

cout << "The arguments are " << x << " and " << y << endl;

}


void print_sum(float x, float y)

{

cout << "The sum is " << x + y << endl;

}


void print_product(float x, float y)

{

cout << "The product is " << x * y << endl;

}


void print_difference(float x, float y)

{

cout << "The difference is " << x - y << endl;

}


void print_quotient(float x, float y)

{

cout << "The quotient is " << x / y << endl;

}



int main() {

boost::signals2::signal<void()> sig1;


Hello hello;

World world;


boost::signals2::connection c1 = sig1.connect(hello);

boost::signals2::connection c2 = sig1.connect(world);


sig1();


    c1.disconnect(); // Disconnect the HelloWorld object

    cout << "c1 is disconnected\n";


    sig1();


    c2.disconnect();

    cout << "c2 is disconnected\n";

    sig1();



    //parameter passing


    boost::signals2::signal<void (float, float)> sig;


    sig.connect(&print_args);

    sig.connect(&print_sum);

    sig.connect(&print_product);

    sig.connect(&print_difference);

    sig.connect(&print_quotient);


    sig(5., 3.);


return 0;

}


Friday, October 11, 2024

Do you want your python code to access C/C++ code? use SWIG...

 SWIG (Simplifies Wrapper and Interface Generator) is an interface compiler that connects programs written in C and C++ with scripting languages such as Perl, Python, Ruby, and Tcl. It works by taking the declarations found in C/C++ header files and using them to generate the wrapper code that scripting languages need to access the underlying C/C++ code.

Using SWIG, you can replace the main() function of a C/C++ program with a scripting interpreter from which you can control the application. This adds quite a lot of flexibility and makes the program "programmable." 

SWIG allows C/C++ programs to be placed in a scripting environment that can be used for testing and debugging. For example, you might test a library with a collection of scripts or use the scripting interpreter as an interactive debugger.

With SWIG, different C/C++ programs can be turned into scripting language extension modules. These modules can then be combined together to create new and interesting applications.

SWIG is sometimes compared to interface definition language (IDL) compilers such as those you find with systems such as CORBA and COM. Although there are a few similarities, the whole point of SWIG is to make it so you don't have to add an extra layer of IDL specifications to your application.

SWIG requires little, if any, modifications to existing code. For the most part, it encourages you to keep a clean separation between C/C++ and its scripting interface.

The primary audience of SWIG is C/C++ programmers who want to add a scripting language component to their applications.

So... here we go...

My experimentation with SWIG...

Step I. MyClass.h

#ifndef MYCLASS_H
#define MYCLASS_H

class MyClass {
public:
    MyClass();
    ~MyClass();
    void set_value(int val);
    int get_value() const;

private:
    int value;
};

#endif

Step II

MyClass.cpp

#include "MyClass.h"

MyClass::MyClass() : value(0) {}

MyClass::~MyClass() {}

void MyClass::set_value(int val) {
    value = val;
}

int MyClass::get_value() const {
    return value;
}


Step III


MyClass.i - the SWIG interface file...


%module MyClass
%{
#include "MyClass.h"
%}

%include "MyClass.h"


Step IV


Generate the Wrapper Code Using SWIG


Run in terminal the following command


swig -python -c++ MyClass.i


This generates two files:

  • MyClass_wrap.cxx: The C++ wrapper code SWIG generates.
  • MyClass.py: The Python module that SWIG creates, which interfaces with the C++ code.

Step V

Then compile the C++ code and the SWIG-generated wrapper using g++ or another compiler. Make sure to link against Python libraries as shown below


g++ -fPIC -shared MyClass_wrap.cxx MyClass.cpp -I/usr/include/python3.x -o _MyClass.so


Here:

  • -fPIC ensures that the code is position-independent (required for shared libraries).
  • -shared tells the compiler to generate a shared library (_MyClass.so).
  • The -I flag specifies the path to Python headers.

Step VI

Once compiled, you can use the MyClass module in Python:

import MyClass

# Create an instance of MyClass
obj = MyClass.MyClass()

# Set and get value using the wrapped C++ methods
obj.set_value(100)
print(obj.get_value())  # Output: 100


Tuesday, September 24, 2024

And miles to go before I sleep - delving into the FreeCAD source code...

 There are many differences between learning a programming language and implementing it in a big real-life project. Hence as a guru of my young son, Ridit, I was looking for a real-life software source code to teach him the practicality of programming languages. I built the Blender source code, but Blender is a mix of various software languages, and many parts of it are written in C. As my son knows C++, Python and Java, i was on the look out for an open source project written purely in these languages.

And Voila... 

I got FreeCAD which is written in modern C++ (C++ 17 and 20) and Python.

So, today I cloned the FreeCAD source code from Github and can build it using QTCreator.

FreeCAD is an open-source parametric 3D modeler, and its source code is written in C++ and Python, making it a rich resource for learning programming concepts. Here are some benefits and considerations for using FreeCAD as a learning platform:

- Real-world application: 

Working with FreeCAD's code exposes learners to a large, professional-grade software project, helping them understand how C++ is applied in real-world engineering applications.

- Object-Oriented Programming: 

Since FreeCAD uses a lot of object-oriented principles, it provides a solid opportunity to understand OOP in-depth, including classes, inheritance, polymorphism, and design patterns.

- Boost Library:

FreeCAD uses the Boost C++ libraries, which are widely used in the C++ community. Learning Boost can significantly improve one's C++ skills.

- Multi-threading and Concurrency:

In advanced projects like FreeCAD, learners can explore more complex topics like multi-threading, resource management, and optimization.

- Cross-language interaction:

FreeCAD integrates Python as a scripting interface. This allows learners to see how different languages can work together, which is valuable in software development.

- Community support:

The FreeCAD community is active, and a young learner can interact with experienced developers, get feedback, and participate in discussions to enhance their skills.

As my son is getting ready for a future career in 3D Software Engineering, I am sure, this journey through the source code of FreeCAD will be a really great yet challenging experience.

So... here we go...

Our journey is about to start...



amader jatra hala shuru

আমাদের   যাত্রা হল শুরু   এখন,   ওগো কর্ণধার।

                   তোমারে         করি নমস্কার।

এখন        বাতাস ছুটুক, তুফান উঠুক, ফিরব না গো আর--

                   তোমারে         করি নমস্কার॥

আমরা   দিয়ে তোমার জয়ধ্বনি   বিপদ বাধা নাহি গণি

                                  ওগো কর্ণধার।

এখন    মাভৈঃ বলি ভাসাই তরী, দাও গো করি পার--

                   তোমারে    করি নমস্কার॥

এখন    রইল যাত্রা আপন ঘরে   চাব না পথ তাদের তরে

                                  ওগো কর্ণধার।

যখন    তোমার সময় এল কাছে তখন কে বা কার--

                   তোমারে         করি নমস্কার।

মোদেরকেবা আপন, কে বা অপর, কোথায় বাহির, কোথা বা ঘর

                                  ওগো কর্ণধার।

চেয়ে    তোমার মুখে   মনের সুখে   নেব সকল ভার--

                   তোমারে         করি নমস্কার ॥

আমরা  নিয়েছি দাঁড়, তুলেছি পাল,   তুমি এখন ধরো গো হাল

                                  ওগো কর্ণধার।

মোদের   মরণ বাঁচন ঢেউয়ের নাচন, ভাবনা কী বা তার--

                   তোমারে         করি নমস্কার।

আমরা  সহায় খুঁজে পরের দ্বারে   ফিরব না আর বারে বারে

                                  ওগো কর্ণধার।

কেবল  তুমিই আছ আমরা আছি     এই জেনেছি সার--

                   তোমারে         করি নমস্কার ॥

Saturday, September 21, 2024

Composite Pattern in Rust - my exploration continues...

In this ever evolving world of programming languages when each day a new language pops up, it's difficult to maintain sanity - that's why impostor syndrome is very common in the software industry. But whatever may be the case, there are some fundamental concepts which remain intact. For example, the event handler loops are almost for every event driven OS. Similarly, the design pattern concepts - it's truly language-agnostic.

Language syntax may change. But the basic principles of software design will remain the same - the same abstraction, encapsulation, inheritance, composition - all remain same.

That's why learning design pattern is such an important goal in the software industry.

Design patterns provide reusable solutions to common problems in software design. The language may differ (like using inheritance in object-oriented languages or using traits in Rust), but the patterns are language-agnostic in concept.

It enforces us to rise above the language and look into a piece of code from a designer's perspective.

So.... here we go...

My implementation of composite pattern in Rust.

use std::vec;
use std::any::type_name;

// Define a trait with a default method to print the type name
trait GetTypeName {
fn get_type_name(&self) -> &'static str {
type_name::<Self>()
}
}

// Implement the trait for any type
impl<T> GetTypeName for T {}

fn print_type_name(obj: &dyn GetTypeName) {
println!("The type name is: {}", obj.get_type_name());
}
trait Shape : ShapeClone{
fn new() -> Self where Self: Sized;
fn add(&mut self, shape : Box<dyn Shape>){
println!("Aloha... It's a leaf.... can't add more components to it...");//default behavior
}
fn remove(&mut self,shape : Box<dyn Shape>){
println!("Aloha... It's a leaf.... can't remove components from it...");//default behaviour
}
fn get_parent(&self) -> Option<Box<dyn Shape>>;
fn set_parent(&mut self, shape: Box<dyn Shape>);
fn display(&self);
}
trait ShapeClone {
fn clone_box(&self) -> Box<dyn Shape>;
}

impl<T> ShapeClone for T
where
T: 'static + Shape + Clone,
{
fn clone_box(&self) -> Box<dyn Shape> {
Box::new(self.clone())
}
}

impl Clone for Box<dyn Shape> {
fn clone(&self) -> Box<dyn Shape> {
self.clone_box()
}
}

#[derive(Clone)]
struct Point{
x:i32,
y:i32,
parent: Option<Box<dyn Shape>>,
}
#[derive(Clone)]
struct CompositeShape{
parent : Option<Box<dyn Shape>>,
list_of_shapes : Vec<Box<dyn Shape>>,
}

impl Shape for CompositeShape{
fn new() -> Self
where
Self: Sized
{
Self {
parent: None,
list_of_shapes: Vec::new(),
}
}

fn add(&mut self, shape: Box<dyn Shape>){
self.list_of_shapes.push(shape.clone());
}
fn remove(&mut self, shape: Box<dyn Shape>){
self.list_of_shapes.pop();
}
fn get_parent(&self) -> Option<Box<dyn Shape>>{
self.parent.clone()
}
fn set_parent(&mut self, shape: Box<dyn Shape>){
self.parent = Option::from(shape);
}
fn display(&self){
for shape in self.list_of_shapes.iter(){
shape.display();
}
}
}

impl Shape for Point{
fn new() -> Self
where
Self: Sized
{
Self { x:0, y:0, parent: None } // Can also write Point { x, y }
}

fn get_parent(&self) -> Option<Box<dyn Shape>>{
self.parent.clone()
}

fn set_parent(&mut self, shape: Box<dyn Shape>) {
self.parent = Option::from(shape);
}

fn display(&self) {
println!("X : {}, Y: {}", self.x, self.y);
}
}

fn main() {
let mut line1 : Box<dyn Shape> = Box ::new(CompositeShape::new());
let mut quadrilateral1 : Box<dyn Shape> = Box ::new(CompositeShape::new());
// Create points
let mut p1:Box<dyn Shape> = Box::new(Point { x: 1, y: 1, parent: None });
let mut p2:Box <dyn Shape> = Box::new(Point { x: 2, y: 2, parent: None });
let mut p3:Box<dyn Shape> = Box::new(Point { x: 10, y: 20, parent: None });
let mut p4:Box <dyn Shape> = Box::new(Point { x: 60, y: 90, parent: None });

line1.add(p1.clone());
line1.add(p2.clone());

quadrilateral1.add(p1.clone());
quadrilateral1.add(p2.clone());
quadrilateral1.add(p3.clone());
quadrilateral1.add(p4.clone());

//setting the parents of the two points
p1.set_parent(line1.clone());
p2.set_parent(line1.clone());

//Trying to add to a leaf
p1.add(p2.clone());

println!("The starting and ending points of the line1 are...");
line1.display();
println!("The four vertices of the quadrilateral are...");
quadrilateral1.display();
}
And here's my exploration of the Composite Design Pattern back in 2008 using C++.



And here we go... Composite Design Pattern in Python...


Enjoy...